public void GetModelsTestWithoutAttribute() { EdmLibTestModelExtractor extractor = new EdmLibTestModelExtractor(); var models = extractor.GetModels <IEdmModel>(typeof(ModelBuilder), EdmVersion.V40, new ValidationTestInvalidModelAttribute(), false); Assert.AreEqual(models.Count(), 1); }
public void GetModelsTest() { EdmLibTestModelExtractor extractor = new EdmLibTestModelExtractor(); var models = extractor.GetModels <IEdmModel>(typeof(ModelBuilder), EdmVersion.V40); Assert.AreEqual(models.Count(), 3); }
protected void VerifyValidTestModels(Type modelBuilder) { var csdlsElements = new EdmLibTestModelExtractor().GetModels <IEnumerable <XElement> >(modelBuilder, this.EdmVersion, new ValidationTestInvalidModelAttribute(), false); foreach (var csdls in csdlsElements) { IEnumerable <EdmError> edmErrors; var edmModel = this.GetParserResult(csdls.Value); edmModel.Validate(out edmErrors); Assert.IsFalse(edmErrors.Any(), "The test model of {0} has unexpected validation errors", csdls.Key); } }
private void BasicXsdValidationTestForSerializerOutputCsdl(Type modelBuilder) { var edmVersions = new EdmVersion[] { EdmVersion.V40 }; var modelExtractor = new EdmLibTestModelExtractor(); foreach (var edmVersion in edmVersions) { var testModels = new Dictionary <string, IEdmModel>(); // The Key of the testModels dictionary is for the functiona name that returns a specfic model. // This is not directly used at runtime, but it can be used for debugging purpose. modelExtractor.GetModels <IEdmModel>(modelBuilder, edmVersion, new CustomCsdlSchemaCompliantTestAttribute(), false).ToList().ForEach(n => testModels.Add(n.Key, n.Value)); foreach (var testModel in testModels) { this.BasicXsdValidationTestForSerializerOutputCsdl(testModel.Value, edmVersion); } } }
private void BasicValidationConsistencyTest(Type modelBuilder) { var versions = new EdmVersion[] { EdmVersion.V40 }; var modelExtractor = new EdmLibTestModelExtractor(); foreach (var version in versions) { var testModels = new Dictionary <string, IEdmModel>(); modelExtractor.GetModels <IEdmModel>(modelBuilder, version, new CustomConsistentValidationTestAttribute(), false).ToList().ForEach(n => testModels.Add(n.Key, n.Value)); modelExtractor.GetModels <EdmModel>(modelBuilder, version, new CustomConsistentValidationTestAttribute(), false).ToList().ForEach(n => testModels.Add(n.Key, n.Value)); foreach (var testModel in testModels) { this.BasicValidationConsistencyTest(testModel.Value, version); } } }
public void ConstructibleVocabularyTestOnVocabularyTestModels() { var stubEdmModels = new EdmLibTestModelExtractor().GetModels<IEdmModel>(typeof(VocabularyTestModelBuilder), this.EdmVersion, new CustomConstructibleVocabularyTestAttribute(), false); foreach (var stubEdmModel in stubEdmModels) { var csdls = new List<XElement>(); csdls.AddRange(new VocabularyDefinitionCsdlGenerator().GenerateDefinitionCsdl(this.EdmVersion, stubEdmModel.Value)); csdls.Add(new VocabularyApplicationCsdlGenerator().GenerateApplicationCsdl(this.EdmVersion, stubEdmModel.Value)); var edmModel = this.GetParserResult(csdls); var stockModel = new EdmToStockModelConverter().ConvertToStockModel(edmModel); var comparer = new VocabularyModelComparer(); var compareErrorMessages = comparer.CompareModels(edmModel, stockModel); compareErrorMessages.ToList().ForEach(e => Console.WriteLine(e)); Assert.AreEqual(0, compareErrorMessages.Count, "Comparison errors"); } }
public void ConstructibleVocabularyTestOnVocabularyTestModels() { var stubEdmModels = new EdmLibTestModelExtractor().GetModels <IEdmModel>(typeof(VocabularyTestModelBuilder), this.EdmVersion, new CustomConstructibleVocabularyTestAttribute(), false); foreach (var stubEdmModel in stubEdmModels) { var csdls = new List <XElement>(); csdls.AddRange(new VocabularyDefinitionCsdlGenerator().GenerateDefinitionCsdl(this.EdmVersion, stubEdmModel.Value)); csdls.Add(new VocabularyApplicationCsdlGenerator().GenerateApplicationCsdl(this.EdmVersion, stubEdmModel.Value)); var edmModel = this.GetParserResult(csdls); var stockModel = new EdmToStockModelConverter().ConvertToStockModel(edmModel); var comparer = new VocabularyModelComparer(); var compareErrorMessages = comparer.CompareModels(edmModel, stockModel); compareErrorMessages.ToList().ForEach(e => Console.WriteLine(e)); Assert.AreEqual(0, compareErrorMessages.Count, "Comparison errors"); } }
public void VocabularySerializingVocabularyTestModels() { var edmModels = new EdmLibTestModelExtractor().GetModels<IEdmModel>(typeof(VocabularyTestModelBuilder), this.EdmVersion, new CustomVocabularySerializerTestAttribute(), false); foreach (var edmModel in edmModels) { var csdls = new List<XElement>(); csdls.AddRange(new VocabularyDefinitionCsdlGenerator().GenerateDefinitionCsdl(this.EdmVersion, edmModel.Value)); csdls.Add(new VocabularyApplicationCsdlGenerator().GenerateApplicationCsdl(this.EdmVersion, edmModel.Value)); IEdmModel parsedModel = this.GetParserResult(csdls); var expectedResults = CombineSchemaElements(csdls); var actualResults = this.GetSerializerResult(parsedModel).Select(n => XElement.Parse(n)); Assert.AreEqual(expectedResults.Count(), actualResults.Count(), "The number of the expected CSDLs is different from that of the actual CSDLs."); foreach (var expected in expectedResults) { var actual = actualResults.Single(n => this.GetSchemaId(expected) == this.GetSchemaId(n)); new CsdlXElementComparer().Compare(expected, actual); } } }
public void VocabularySerializingVocabularyTestModels() { var edmModels = new EdmLibTestModelExtractor().GetModels <IEdmModel>(typeof(VocabularyTestModelBuilder), this.EdmVersion, new CustomVocabularySerializerTestAttribute(), false); foreach (var edmModel in edmModels) { var csdls = new List <XElement>(); csdls.AddRange(new VocabularyDefinitionCsdlGenerator().GenerateDefinitionCsdl(this.EdmVersion, edmModel.Value)); csdls.Add(new VocabularyApplicationCsdlGenerator().GenerateApplicationCsdl(this.EdmVersion, edmModel.Value)); IEdmModel parsedModel = this.GetParserResult(csdls); var expectedResults = CombineSchemaElements(csdls); var actualResults = this.GetSerializerResult(parsedModel).Select(n => XElement.Parse(n)); Assert.AreEqual(expectedResults.Count(), actualResults.Count(), "The number of the expected CSDLs is different from that of the actual CSDLs."); foreach (var expected in expectedResults) { var actual = actualResults.Single(n => this.GetSchemaId(expected) == this.GetSchemaId(n)); new CsdlXElementComparer().Compare(expected, actual); } } }
private void BasicXsdValidationTestForParserInputCsdl(Type modelBuilder) { var edmVersions = new EdmVersion[] { EdmVersion.V40 }; var modelExtractor = new EdmLibTestModelExtractor(); foreach (var edmVersion in edmVersions) { // The Key of the testModels dictionary is for the functiona name that returns a specfic model. // This is not directly used at runtime, but it can be used for debugging purpose. var testModels = new Dictionary<string, IEnumerable<XElement>>(); // Extract test models in IEnumerable<XElement> modelExtractor.GetModels<IEnumerable<XElement>>(modelBuilder, edmVersion, new CustomCsdlSchemaCompliantTestAttribute(), false).ToList().ForEach(n => testModels.Add(n.Key, n.Value)); // Extract test models in XElement[] modelExtractor.GetModels<XElement[]>(modelBuilder, edmVersion, new CustomCsdlSchemaCompliantTestAttribute(), false).ToList().ForEach(n => testModels.Add(n.Key, n.Value)); // Extract test models in IEdmModel modelExtractor.GetModels<IEdmModel>(modelBuilder, edmVersion, new CustomCsdlSchemaCompliantTestAttribute(), false).ToList().ForEach(n => testModels.Add(n.Key, this.GetSerializerResult(n.Value).Select(XElement.Parse))); foreach (var testModel in testModels) { this.BasicXsdValidationTestForParserInputCsdl(testModel.Value, edmVersion); } } }
private void BasicValidationConsistencyTest(Type modelBuilder) { var versions = new EdmVersion[] { EdmVersion.V40 }; var modelExtractor = new EdmLibTestModelExtractor(); foreach (var version in versions) { var testModels = new Dictionary<string, IEdmModel>(); modelExtractor.GetModels<IEdmModel>(modelBuilder, version, new CustomConsistentValidationTestAttribute(), false).ToList().ForEach(n => testModels.Add(n.Key, n.Value)); modelExtractor.GetModels<EdmModel>(modelBuilder, version, new CustomConsistentValidationTestAttribute(), false).ToList().ForEach(n => testModels.Add(n.Key, n.Value)); foreach (var testModel in testModels) { this.BasicValidationConsistencyTest(testModel.Value, version); } } }
public void GetModelsTestWithoutAttribute() { EdmLibTestModelExtractor extractor = new EdmLibTestModelExtractor(); var models = extractor.GetModels<IEdmModel>(typeof(ModelBuilder), EdmVersion.V40, new ValidationTestInvalidModelAttribute(), false); Assert.AreEqual(models.Count(), 1); }
public void GetModelsTest() { EdmLibTestModelExtractor extractor = new EdmLibTestModelExtractor(); var models = extractor.GetModels<IEdmModel>(typeof(ModelBuilder), EdmVersion.V40); Assert.AreEqual(models.Count(), 3); }