Ejemplo n.º 1
0
        public void IgnoredNewUsagesAreNotOnGeneratedBaseline()
        {
            var mockEngine = new Mock <IBuildEngine>(MockBehavior.Loose);
            var task       = new ValidateUsageAgainstBaseline {
                BuildEngine = mockEngine.Object
            };

            var baseline = SimpleUsageData();

            baseline.IgnorePatterns = new[]
            {
                new UsagePattern {
                    IdentityGlob = "A/*"
                },
                new UsagePattern {
                    IdentityGlob = "B/*"
                },
                new UsagePattern {
                    IdentityRegex = "Ca[tr]/.*"
                },
            };

            var used = SimpleUsageData("A/1.0.0", "B/1.0.0", "Cat/1.2.3", "Car/1.4.5");

            var data = task.GetUsageValidationData(baseline, used);

            Assert.Empty(data.ActualUsageData.Usages);
        }
Ejemplo n.º 2
0
        public void IgnorePatternsPassThroughToGeneratedBaseline()
        {
            var mockEngine = new Mock <IBuildEngine>(MockBehavior.Loose);
            var task       = new ValidateUsageAgainstBaseline {
                BuildEngine = mockEngine.Object
            };

            var baseline = SimpleUsageData();

            baseline.IgnorePatterns = new[]
            {
                new UsagePattern {
                    IdentityGlob = "*/*"
                },
                new UsagePattern {
                    IdentityGlob = "Pizza/42.0.0"
                },
                new UsagePattern {
                    IdentityRegex = "[Az]*"
                },
            };

            var used = SimpleUsageData();

            var data = task.GetUsageValidationData(baseline, used);

            Assert.Equal(baseline.IgnorePatterns.Length, data.ActualUsageData.IgnorePatterns.Length);

            foreach (var(a, b) in baseline.IgnorePatterns.Zip(data.ActualUsageData.IgnorePatterns, (a, b) => (a, b)))
            {
                Assert.Equal(a.IdentityGlob, b.IdentityGlob);
                Assert.Equal(a.IdentityRegex, b.IdentityRegex);
            }
        }
Ejemplo n.º 3
0
        public void NewUsageShowsInReport()
        {
            var mockEngine = new Mock <IBuildEngine>(MockBehavior.Loose);
            var task       = new ValidateUsageAgainstBaseline {
                BuildEngine = mockEngine.Object
            };

            var baseline = SimpleUsageData("A/1.0.0");
            var used     = SimpleUsageData("A/1.0.0", "B/1.0.0");
            var data     = task.GetUsageValidationData(baseline, used);

            Assert.Equal(
                XElement
                .Parse(@"<BaselineComparison> <New> <Usage Id=""B"" Version=""1.0.0"" /> </New> </BaselineComparison>")
                .ToString(),
                data.Report.ToString());
        }
Ejemplo n.º 4
0
        public void IgnoredBaselineUsagesAreRemoved()
        {
            var mockEngine = new Mock <IBuildEngine>(MockBehavior.Loose);
            var task       = new ValidateUsageAgainstBaseline {
                BuildEngine = mockEngine.Object
            };

            var baseline = SimpleUsageData("A/1.0.0", "B/1.0.0");

            baseline.IgnorePatterns = new[]
            {
                new UsagePattern {
                    IdentityGlob = "A/*"
                },
            };

            var used = SimpleUsageData("A/1.0.0", "B/1.0.0");

            var data = task.GetUsageValidationData(baseline, used);

            Assert.Equal(
                baseline.Usages.Skip(1).Select(u => u.PackageIdentity).ToArray(),
                data.ActualUsageData.Usages.Select(u => u.PackageIdentity).ToArray());
        }