public void SerializeOutputDescriptionWithJSONPaths_Expected_DeserializationToWork() { IDataSourceShape dataSourceShape = DataSourceShapeFactory.CreateDataSourceShape(); dataSourceShape.Paths.Add(new JsonPath("Name", "Name", "[[ScalarName]]")); dataSourceShape.Paths.Add(new JsonPath("Departments().Name", "Departments.Name", "[[Names().DepartmentName]]")); dataSourceShape.Paths.Add(new JsonPath("Departments().Employees().Name", "Departments.Employees.Name", "[[Names().EmployeeName]]")); dataSourceShape.Paths.Add(new JsonPath("PrimitiveRecordset()", "PrimitiveRecordset", "[[OtherNames().Name]]")); IOutputDescription testOutputDescription = OutputDescriptionFactory.CreateOutputDescription(OutputFormats.ShapedXML); testOutputDescription.DataSourceShapes.Add(dataSourceShape); IOutputDescriptionSerializationService outputDescriptionSerializationService = OutputDescriptionSerializationServiceFactory.CreateOutputDescriptionSerializationService(); string serializedData = outputDescriptionSerializationService.Serialize(testOutputDescription); IOutputDescription deserializedOutputDescription = outputDescriptionSerializationService.Deserialize(serializedData); string expected = testOutputDescription.Format.ToString() + "^" + string.Join("|", testOutputDescription.DataSourceShapes.SelectMany(d => d.Paths).Select(p => p.ActualPath)) + "^" + string.Join("|", testOutputDescription.DataSourceShapes.SelectMany(d => d.Paths).Select(p => p.DisplayPath)) + "^" + string.Join("|", testOutputDescription.DataSourceShapes.SelectMany(d => d.Paths).Select(p => p.OutputExpression)); string actual = deserializedOutputDescription.Format.ToString() + "^" + string.Join("|", deserializedOutputDescription.DataSourceShapes.SelectMany(d => d.Paths).Select(p => p.ActualPath)) + "^" + string.Join("|", deserializedOutputDescription.DataSourceShapes.SelectMany(d => d.Paths).Select(p => p.DisplayPath)) + "^" + string.Join("|", deserializedOutputDescription.DataSourceShapes.SelectMany(d => d.Paths).Select(p => p.OutputExpression)); Assert.AreEqual(expected, actual); }
public void SerializeOutputDescriptionWithXMLPaths_Expected_DeserializationToWork() { IDataSourceShape dataSourceShape = DataSourceShapeFactory.CreateDataSourceShape(); dataSourceShape.Paths.Add(new XmlPath("Company:Name", "Company:Name", "[[Names().CompanyName]]")); dataSourceShape.Paths.Add(new XmlPath("Company.Departments().Department:Name", "Company.Departments.Department:Name", "[[Names().DepartmentName]]")); dataSourceShape.Paths.Add(new XmlPath("Company.Departments().Department.Employees().Person:Name", "Company.Departments.Department.Employees.Person:Name", "[[Names().EmployeeName]]")); IOutputDescription testOutputDescription = OutputDescriptionFactory.CreateOutputDescription(OutputFormats.ShapedXML); testOutputDescription.DataSourceShapes.Add(dataSourceShape); IOutputDescriptionSerializationService outputDescriptionSerializationService = OutputDescriptionSerializationServiceFactory.CreateOutputDescriptionSerializationService(); string serializedData = outputDescriptionSerializationService.Serialize(testOutputDescription); IOutputDescription deserializedOutputDescription = outputDescriptionSerializationService.Deserialize(serializedData); string expected = testOutputDescription.Format.ToString() + "^" + string.Join("|", testOutputDescription.DataSourceShapes.SelectMany(d => d.Paths).Select(p => p.ActualPath)) + "^" + string.Join("|", testOutputDescription.DataSourceShapes.SelectMany(d => d.Paths).Select(p => p.DisplayPath)) + "^" + string.Join("|", testOutputDescription.DataSourceShapes.SelectMany(d => d.Paths).Select(p => p.OutputExpression)); string actual = deserializedOutputDescription.Format.ToString() + "^" + string.Join("|", deserializedOutputDescription.DataSourceShapes.SelectMany(d => d.Paths).Select(p => p.ActualPath)) + "^" + string.Join("|", deserializedOutputDescription.DataSourceShapes.SelectMany(d => d.Paths).Select(p => p.DisplayPath)) + "^" + string.Join("|", deserializedOutputDescription.DataSourceShapes.SelectMany(d => d.Paths).Select(p => p.OutputExpression)); Assert.AreEqual(expected, actual); }