Skip to content
This repository has been archived by the owner on Apr 12, 2023. It is now read-only.

Commit

Permalink
read settings from json
Browse files Browse the repository at this point in the history
  • Loading branch information
agabor committed May 17, 2022
1 parent 6b06794 commit 6624d8c
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 44 deletions.
24 changes: 2 additions & 22 deletions BootGenTest/DataModelTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,7 @@ public void TestLoadModel()
{
var data = JObject.Parse(File.ReadAllText("example_input.json"));
var dataModel = new DataModel();
dataModel.ClassSettings["Task"] = new ClassSettings {
HasTimestamps = true,
PropertySettings = new Dictionary<string, PropertySettings> {
{
"Tags",
new PropertySettings {
IsManyToMany = true
}
}
}
};
dataModel.ClassSettings = JObject.Parse(File.ReadAllText("example_input_settings.json")).ToObject<Dictionary<string, ClassSettings>>();
dataModel.Load(data);
var resourceCollection = new ResourceCollection(dataModel);
Assert.AreEqual(5, dataModel.Classes.Count);
Expand Down Expand Up @@ -98,17 +88,7 @@ public void TestLoadRecursiveModel()
{
var data = JObject.Parse(File.ReadAllText("example_recursive_input.json"));
var dataModel = new DataModel();
dataModel.ClassSettings["User"] = new ClassSettings {
PropertySettings = new Dictionary<string, PropertySettings> {
{
"Friends",
new PropertySettings {
ClassName = "User",
IsManyToMany = true
}
}
}
};
dataModel.ClassSettings = JObject.Parse(File.ReadAllText("example_recursive_input_settings.json")).ToObject<Dictionary<string, ClassSettings>>();
dataModel.Load(data);
var userClass = dataModel.Classes.First(c => c.Name.Singular == "User");
Assert.AreEqual(4, userClass.Properties.Count);
Expand Down
24 changes: 2 additions & 22 deletions BootGenTest/SeedTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,7 @@ public void TestSeed()
{
var data = JObject.Parse(File.ReadAllText("example_input.json"));
var dataModel = new DataModel();
dataModel.ClassSettings["Task"] = new ClassSettings {
HasTimestamps = true,
PropertySettings = new Dictionary<string, PropertySettings> {
{
"Tags",
new PropertySettings {
IsManyToMany = true
}
}
}
};
dataModel.ClassSettings = JObject.Parse(File.ReadAllText("example_input_settings.json")).ToObject<Dictionary<string, ClassSettings>>();
dataModel.Load(data);
var resourceCollection = new ResourceCollection(dataModel);
var seedStore = new SeedDataStore(resourceCollection);
Expand Down Expand Up @@ -72,17 +62,7 @@ public void TestSeed2()
{
var data = JObject.Parse(File.ReadAllText("example_recursive_input.json"));
var dataModel = new DataModel();
dataModel.ClassSettings["User"] = new ClassSettings {
PropertySettings = new Dictionary<string, PropertySettings> {
{
"Friends",
new PropertySettings {
ClassName = "User",
IsManyToMany = true
}
}
}
};
dataModel.ClassSettings = JObject.Parse(File.ReadAllText("example_recursive_input_settings.json")).ToObject<Dictionary<string, ClassSettings>>();
dataModel.Load(data);
var resourceCollection = new ResourceCollection(dataModel);
var seedStore = new SeedDataStore(resourceCollection);
Expand Down
10 changes: 10 additions & 0 deletions BootGenTest/example_input_settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"Task": {
"HasTimeStamps": true,
"PropertySettings": {
"Tags": {
"IsManyToMany": true
}
}
}
}
10 changes: 10 additions & 0 deletions BootGenTest/example_recursive_input_settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"User": {
"PropertySettings": {
"Friends": {
"ClassName": "User",
"IsManyToMany": true
}
}
}
}

0 comments on commit 6624d8c

Please sign in to comment.