public void TestComplexTypes() { RuntimeCsvRepresentation rcr = new RuntimeCsvRepresentation(); rcr.Headers = new CsvHeader[1]; rcr.Headers[0] = new CsvHeader("Contained (NonGraphicalTests.IO.Csv.TypeToDeserialize)"); rcr.Records = new List <string[]>(); rcr.Records.Add(new string[1]); rcr.Records[0][0] = "X = 4"; List <Container> listToPopulate = new List <Container>(); rcr.CreateObjectList(typeof(Container), listToPopulate); if (listToPopulate[0].Contained.X != 4) { throw new Exception("Complex types are not being deserialized properly"); } rcr.Records[0][0] = "AvailableEnemies = (\"Dragon\")"; listToPopulate = new List <Container>(); rcr.CreateObjectList(typeof(Container), listToPopulate); if (listToPopulate[0].Contained.AvailableEnemies[0] != "Dragon") { throw new Exception("Inline lists in complex objects are not deserializing properly"); } }
public void TestCreateObjectList() { RuntimeCsvRepresentation rcr = new RuntimeCsvRepresentation(); rcr.Headers = new CsvHeader[3]; rcr.Headers[0] = new CsvHeader("X (float)"); rcr.Headers[1] = new CsvHeader("Visible (bool)"); rcr.Headers[2] = new CsvHeader("AvailableEnemies (List<string>)"); rcr.Records = new List <string[]>(); rcr.Records.Add(new string[3]); rcr.Records[0][0] = "3"; rcr.Records[0][1] = "true"; rcr.Records[0][2] = "Dragon"; List <TypeToDeserialize> listToPopulate = new List <TypeToDeserialize>(); rcr.CreateObjectList(typeof(TypeToDeserialize), listToPopulate); if (listToPopulate[0].AvailableEnemies.Count != 1 || listToPopulate[0].AvailableEnemies[0] != "Dragon") { throw new Exception("Lists are not being deserialized properly"); } }
public void TestCreateObjectList() { RuntimeCsvRepresentation rcr = new RuntimeCsvRepresentation(); rcr.Headers = new CsvHeader[3]; rcr.Headers[0] = new CsvHeader("X (float)"); rcr.Headers[1] = new CsvHeader("Visible (bool)"); rcr.Headers[2] = new CsvHeader("AvailableEnemies (List<string>)"); rcr.Records = new List<string[]>(); rcr.Records.Add(new string[3]); rcr.Records[0][0] = "3"; rcr.Records[0][1] = "true"; rcr.Records[0][2] = "Dragon"; List<TypeToDeserialize> listToPopulate = new List<TypeToDeserialize>(); rcr.CreateObjectList(typeof(TypeToDeserialize), listToPopulate); if (listToPopulate[0].AvailableEnemies.Count != 1 || listToPopulate[0].AvailableEnemies[0] != "Dragon") { throw new Exception("Lists are not being deserialized properly"); } }
public void TestComplexTypes() { RuntimeCsvRepresentation rcr = new RuntimeCsvRepresentation(); rcr.Headers = new CsvHeader[1]; rcr.Headers[0] = new CsvHeader("Contained (NonGraphicalTests.IO.Csv.TypeToDeserialize)"); rcr.Records = new List<string[]>(); rcr.Records.Add(new string[1]); rcr.Records[0][0] = "X = 4"; List<Container> listToPopulate = new List<Container>(); rcr.CreateObjectList(typeof(Container), listToPopulate); if (listToPopulate[0].Contained.X != 4) { throw new Exception("Complex types are not being deserialized properly"); } rcr.Records[0][0] = "AvailableEnemies = (\"Dragon\")"; listToPopulate = new List<Container>(); rcr.CreateObjectList(typeof(Container), listToPopulate); if (listToPopulate[0].Contained.AvailableEnemies[0] != "Dragon") { throw new Exception("Inline lists in complex objects are not deserializing properly"); } }