public void DataDoesNotNeedCorrectionTest() { var mockVersionHelper = new Mock<IDataVersioningHelper>(); var mockRepository = new Mock<IRepository<CV_RelationshipType>>(); var testQualityCheckingRule = new StringCompareCheckingRule("Water", true, "test"); var testTool = new SampleMatrixTypeCheckingTool(mockVersionHelper.Object, mockRepository.Object); var correctResult = testTool.Correct(new Hatfield.EnviroData.Core.Action(), testQualityCheckingRule); Assert.NotNull(correctResult); Assert.AreEqual("Sample data meets quality checking rule. No correction is needed.", correctResult.Message); Assert.AreEqual(QualityCheckingResultLevel.Info, correctResult.Level); Assert.False(correctResult.NeedCorrection); }
public void DataNeedCorrectionTest() { var testActionData = CreateTestAction(); var testQualityCheckingRule = new StringCompareCheckingRule("Water", true, "test"); var mockVersionHelper = new Mock<IDataVersioningHelper>(); var mockRepository = new Mock<IRepository<CV_RelationshipType>>(); mockRepository.Setup(x => x.GetAll()) .Returns(() => (new List<CV_RelationshipType> { new CV_RelationshipType{ Name = "Is new version of" } }) .AsQueryable()); var mockDefaultValueProvider = new Mock<IWQDefaultValueProvider>(); mockDefaultValueProvider.Setup(x => x.ActionRelationshipTypeSubVersion).Returns("is new version of"); var testTool = new SampleMatrixTypeCheckingTool(new DataVersioningHelper(mockDefaultValueProvider.Object), mockRepository.Object); var correctedResult = testTool.Correct(testActionData, testQualityCheckingRule); Assert.NotNull(correctedResult); Assert.AreEqual("Create new version for correction data.", correctedResult.Message); Assert.AreEqual(QualityCheckingResultLevel.Info, correctedResult.Level); Assert.False(correctedResult.NeedCorrection); var relationShips = testActionData.RelatedActions; Assert.AreEqual(1, relationShips.Count); Assert.AreEqual("Is new version of", relationShips.ElementAt(0).RelationshipTypeCV); Assert.AreEqual("Is new version of", relationShips.ElementAt(0).CV_RelationshipType.Name); var newVersionAction = relationShips.ElementAt(0).Action1; Assert.NotNull(newVersionAction); foreach(var featureAction in newVersionAction.FeatureActions) { foreach(var result in featureAction.Results) { var extension = result.ResultExtensionPropertyValues.Where(x => x.ExtensionProperty.PropertyName == "Matrix Type").FirstOrDefault(); if(extension != null) { Assert.AreEqual("test", extension.PropertyValue); } } } }
public void InvalidDataCorrectTest() { var mockVersionHelper = new Mock<IDataVersioningHelper>(); var mockRepository = new Mock<IRepository<CV_RelationshipType>>(); var mockQualityCheckingRule = new Mock<IDataQualityCheckingRule>(); var testTool = new SampleMatrixTypeCheckingTool(mockVersionHelper.Object, mockRepository.Object); var correctResult = testTool.Correct(1, mockQualityCheckingRule.Object); Assert.NotNull(correctResult); Assert.AreEqual("Sample data/Data checking rule is not valid. No correction could be applied.", correctResult.Message); Assert.AreEqual(QualityCheckingResultLevel.Error, correctResult.Level); Assert.False(correctResult.NeedCorrection); }