datamanager and stubs working
continuous-integration/drone/push Build is passing Details

pull/39/head
Alexandre AGOSTINHO 2 years ago
parent 0d25ee5598
commit c8c1986e39

@ -12,10 +12,9 @@ Console.WriteLine("Hello, World!\n\n");
// TESTS: // TESTS:
DataManager dataMgr = new DataManager(new Stubs()); DataManager dataMgr = new DataManager(new Stubs());
List<object> allRecipes = dataMgr.Data["recipes"]; RecipeCollection rc = new RecipeCollection("All recipes", dataMgr.Data["recipes"].Cast<Recipe>().ToArray());
Recipe? ret = SearcherRecipe.ResearchOn(rc);
Recipe? ret = SearcherRecipe.ResearchOn(allRecipes);
Console.WriteLine(ret); Console.WriteLine(ret);
// press any key to quit // press any key to quit

@ -14,14 +14,14 @@ namespace DataPersistence
public DataManager(IDataManager dataMgr, string? path = null) public DataManager(IDataManager dataMgr, string? path = null)
{ {
if (path is null) path = "..//..//..//..//data"; //if (path is null) path = "..//..//..//..//data";
Directory.SetCurrentDirectory(Path.Combine(Directory.GetCurrentDirectory(), path)); //Directory.SetCurrentDirectory(Path.Combine(Directory.GetCurrentDirectory(), path));
Serializer = dataMgr; Serializer = dataMgr;
Data = Serializer.LoadAll(); Data = Serializer.Load();
} }
public void Reload() public void Reload()
=> Data = Serializer.LoadAll(); => Data = Serializer.Load();
} }
} }

@ -11,7 +11,7 @@ namespace DataPersistence
//void Save<T>(List<T> values); //void Save<T>(List<T> values);
//List<T> Load<T>(); //List<T> Load<T>();
void SaveAll(); void Save();
Dictionary<string, List<object>> LoadAll(); Dictionary<string, List<object>> Load();
} }
} }

@ -9,7 +9,7 @@ namespace DataPersistence
{ {
public class Stubs : IDataManager public class Stubs : IDataManager
{ {
public Dictionary<string, List<object>> LoadAll() public Dictionary<string, List<object>> Load()
{ {
Dictionary<string, List<object>> data = new Dictionary<string, List<object>> Dictionary<string, List<object>> data = new Dictionary<string, List<object>>
{ {
@ -87,7 +87,7 @@ namespace DataPersistence
return data; return data;
} }
public void SaveAll() public void Save()
{ {
// Stubs dont' have to save. // Stubs dont' have to save.
} }

Loading…
Cancel
Save