public void Test() { var person = JSectionReader.Section("Example5ReadingObject.json").GetSection("person").GetObject <Person>(); Assert.AreEqual("richard", person.Name); Assert.AreEqual(22, person.Age); }
public void Test() { var word = "Mädchen"; var actualWord = JSectionReader.Section("Example3Encoding.json", Encoding.UTF8).GetSection("words", 2).GetObject <string>(); Assert.AreEqual(word, actualWord); }
public void Test() { var data = new JSectionReader().Read("Example8ListOfList.json").GetSection("data") .GetTable(typeof(int), typeof(string), typeof(string)); var expectedData = new List <List <object> >() { new List <object>() { 1, "Monday", "Morning" }, new List <object>() { 2, "Monday", "Afternoon" }, new List <object>() { 3, "Tuesday", "Morning" }, new List <object>() { 4, "Tuesday", "Afternoon" }, }; for (int i = 0; i < expectedData.Count; i++) { for (int j = 0; j < expectedData[i].Count; j++) { Assert.AreEqual(data[i][j], expectedData[i][j]); } } }
public void Test() { var employees = new JSectionReader().Read("Example9ListOfObject.json").GetSection("data") .GetTableAsObjectList <Employee, int, string, int>( (id, name, age) => new Employee() { Id = id, Name = name, Age = age, }); var expectedEmployees = new List <Employee>() { new Employee() { Id = 2432, Name = "John", Age = 32 }, new Employee() { Id = 2222, Name = "Nash", Age = 33 }, new Employee() { Id = 3421, Name = "Peter", Age = 33 }, }; for (int i = 0; i < expectedEmployees.Count; i++) { Assert.AreEqual(expectedEmployees[i].Id, employees[i].Id); Assert.AreEqual(expectedEmployees[i].Name, employees[i].Name); Assert.AreEqual(expectedEmployees[i].Age, employees[i].Age); } }
public void Test() { var expectedJson = "{\"name\":\"Nash\",\"id\":31433}"; var data = new JSectionReader().Read("Example7ReadingAsJson.json").GetSection("employees", 1).GetJson(); Assert.AreEqual(expectedJson, data); }
public void Test(string testCaseName, string fileName, string sectionName, object expected, Type objectType) { var section = new JSectionReader().Read(fileName, Encoding.UTF8).GetSection(sectionName); var result = GetObjectAtSection(section, objectType); AssertAreEqual(expected, result); }
public void Test(string testCaseName, string fileName, Encoding encoding, List <string> expected) { var section = JSectionReader.Section(fileName, encoding).GetSection("table"); var result = section.GetTableAsObjectList <string, string>((val) => val); result.Should().BeEquivalentTo(expected); }
public void Tests() { var reader = new JSectionReader(); var actual = reader.Read("TablePartOfArrayTests.json").GetSection("node1", 1).GetTable(typeof(int), typeof(int)); var expected = reader.Read("TablePartOfArrayTests.json").GetSection("node2").GetTable(typeof(int), typeof(int)); actual.Should().BeEquivalentTo(expected); }
public void Test(string testCaseName, object[] initialFilter, object[] later1Filter, object[] later2Filter) { var reader = new JSectionReader(); var actual = reader.Read("NarrowingSectionsTests.json", Encoding.Default, initialFilter).GetSection(later1Filter).GetSection(later2Filter) .GetTable(typeof(int), typeof(string)); actual.Should().BeEquivalentTo(GetExpected()); }
public void Test3() { var actualWord = JSectionReader .Section("Boo.Example4FileDiscovery.json") .GetSection("animal").GetObject <string>(); Assert.AreEqual("elephant", actualWord); }
public void Test(string searchPath, Type[] tableTypes, List <List <object> > expected) { var reader = new JSectionReader(); var actual = reader.Read("TableDataTests.json").GetSection(searchPath) .GetTable(tableTypes); actual.Should().BeEquivalentTo(expected); }
public void ReadJson(string testCaseName) { var testDataSection = new JSectionReader().Read("ReadJsonTests.json", Encoding.UTF8, testCaseName); string json = testDataSection.GetSection("value").GetJson(); string expectedJson = testDataSection.GetSection("serializedValue").GetObject <string>(); Assert.AreEqual(expectedJson, json); }
public void Test() { var numbers = JSectionReader.Section("Example6ReadingList.json").GetSection("numbers").GetObject <List <int> >(); CollectionAssert.AreEqual(new List <int>() { 5, 4, 3, 2, 1 }, numbers); }
public static Exception GetExceptionAttemptingToGetJsonSegment(string file, params object[] tokens) { try { var reader = new JSectionReader(); reader.Read(file).GetSection(tokens); } catch (Exception e) { return(e); } throw new Exception(); }
public void Tests(string segment, Type exceptionType, string errorMessage, params Type[] tableTypes) { Exception GetExceptionInTable() { try { var reader = new JSectionReader(); var table = reader.Read("TableAccessErrorTests.json").GetSection(segment).GetTable(tableTypes); } catch (Exception e) { return(e); } throw new Exception("no exception"); } var exception = GetExceptionInTable(); Assert.AreEqual(exceptionType, exception.GetType()); Assert.AreEqual(errorMessage, exception.Message); }
public void Setup() { _runner = MongoDbRunner.Start(); testData = JSectionReader.Section("movieDetailsTestData.json", Encoding.UTF8); }
public void Test1() { var name = JSectionReader.Section("Example1Sectioning.json").GetSection("name").GetObject <string>(); Assert.AreEqual("john", name); }
public void Setup() { _runner = MongoDbRunner.Start(); testData = JSectionReader.Section("AirTravel.json", Encoding.UTF8); }
public void AirTravelCollectionMongoDbSetUp() { travelCollection = new MongoClient(_connectionString).GetDatabase("testdb").GetCollection <AirTravel>("travel"); testData = JSectionReader.Section("AirTravel.json", Encoding.UTF8); }
public void Test3() { var name = new JSectionReader().Read("Example1Sectioning.json", Encoding.Default, "name").GetObject <string>(); Assert.AreEqual("john", name); }
public void Test() { var name = JSectionReader.Section("Example2Sectioning.json").GetSection("employees", 1, "name").GetObject <string>(); Assert.AreEqual("richard", name); }
public void Setup() { _runner = MongoDbRunner.Start(); mongoCollection = new MongoClient(_runner.ConnectionString).GetDatabase("testdb").GetCollection <Test>("testcollection"); testData = JSectionReader.Section("AirTravel.json", Encoding.UTF8); }