Пример #1
0
        public async Task CheckBaselineIntegrityOnly()
        {
            const int AllowedVariance = 5;

            ImageSizeData[] imageSizes = new[]
            {
                new ImageSizeData(RuntimeDepsRepo, RuntimeDeps1RelativeDir, RuntimeDeps1Tag, 100, 99),
                new ImageSizeData(RuntimeDepsRepo, RuntimeDeps2RelativeDir, RuntimeDeps2Tag, 2, actualSize: null),
                new ImageSizeData(RuntimeRepo, RuntimeRelativeDir, RuntimeTag, 3, 3),
                new ImageSizeData(AspnetRepo, AspnetRelativeDir, AspnetTag, 100, 200),
                new ImageSizeData(SdkRepo, SdkRelativeDir, SdkTag, baselineSize: null, 5)
            };

            // This will configure the test so that an exception will be thrown should the logic ever attempt to
            // retrieve an image size. Image sizes should not be retrieved when we're only validating baseline integrity.
            bool localImagesExist = false;

            TestContext testContext = new TestContext(imageSizes, AllowedVariance, checkBaselineIntegrityOnly: true,
                                                      localImagesExist: localImagesExist);
            ValidateImageSizeCommand command = await testContext.RunTestAsync();

            testContext.Verify(isValidationErrorExpected: true);

            ImageSizeValidationResults results = command.ValidationResults;

            Assert.Empty(results.ImagesWithNoSizeChange);
            Assert.Empty(results.ImagesWithAllowedSizeChange);
            Assert.Empty(results.ImagesWithDisallowedSizeChange);
            Assert.Single(results.ImagesWithMissingBaseline);
            Assert.Equal(SdkRelativeDir, results.ImagesWithMissingBaseline.First().Id);
            Assert.Single(results.ImagesWithExtraneousBaseline);
            Assert.Equal(RuntimeDeps2RelativeDir, results.ImagesWithExtraneousBaseline.First().Id);
        }
Пример #2
0
        public async Task ExtraneousBaseline()
        {
            // Specifying null for the actual size prevents the image from being defined in the manifest. But since
            // a baseline size is defined, it'll end up in the baseline file. This is the scenario that we want to
            // identify because there will be extraneous data in the baseline file for which no image exists.
            ImageSizeData[] imageSizes = new[]
            {
                new ImageSizeData(RuntimeDepsRepo, RuntimeDeps1RelativeDir, RuntimeDeps1Tag, 1, actualSize: null),
                new ImageSizeData(RuntimeDepsRepo, RuntimeDeps2RelativeDir, RuntimeDeps2Tag, 2, 2),
                new ImageSizeData(RuntimeRepo, RuntimeRelativeDir, RuntimeTag, 3, 3),
                new ImageSizeData(AspnetRepo, AspnetRelativeDir, AspnetTag, 4, actualSize: null),
                new ImageSizeData(SdkRepo, SdkRelativeDir, SdkTag, 5, 5)
            };

            TestContext testContext          = new TestContext(imageSizes);
            ValidateImageSizeCommand command = await testContext.RunTestAsync();

            testContext.Verify(isValidationErrorExpected: true);

            ImageSizeValidationResults results = command.ValidationResults;

            Assert.Equal(3, results.ImagesWithNoSizeChange.Count());
            Assert.Equal(RuntimeDeps2RelativeDir, results.ImagesWithNoSizeChange.ElementAt(0).Id);
            Assert.Equal(RuntimeRelativeDir, results.ImagesWithNoSizeChange.ElementAt(1).Id);
            Assert.Equal(SdkRelativeDir, results.ImagesWithNoSizeChange.ElementAt(2).Id);
            Assert.Empty(results.ImagesWithAllowedSizeChange);
            Assert.Empty(results.ImagesWithDisallowedSizeChange);
            Assert.Empty(results.ImagesWithMissingBaseline);
            Assert.Equal(2, results.ImagesWithExtraneousBaseline.Count());
            Assert.Equal(RuntimeDeps1RelativeDir, results.ImagesWithExtraneousBaseline.ElementAt(0).Id);
            Assert.Equal(AspnetRelativeDir, results.ImagesWithExtraneousBaseline.ElementAt(1).Id);
        }
Пример #3
0
        public async Task SizeDifferences()
        {
            const int AllowedVariance = 5;

            // Define the test data such that some of the image sizes are within the allowed range and others are
            // just out of the allowed range. These numbers are all in relation to the AllowedVariance.
            ImageSizeData[] imageSizes = new[]
            {
                // Within range (under)
                new ImageSizeData(RuntimeDepsRepo, RuntimeDeps1RelativeDir, RuntimeDeps1Tag, 100, 95),

                // Out of range (under)
                new ImageSizeData(RuntimeDepsRepo, RuntimeDeps2RelativeDir, RuntimeDeps2Tag, 100, 94),

                // Within range (over)
                new ImageSizeData(RuntimeRepo, RuntimeRelativeDir, RuntimeTag, 100, 101),

                // Out of range (over)
                new ImageSizeData(AspnetRepo, AspnetRelativeDir, AspnetTag, 100, 106),

                // Same size
                new ImageSizeData(SdkRepo, SdkRelativeDir, SdkTag, 100, 100)
            };

            TestContext testContext          = new TestContext(imageSizes, AllowedVariance);
            ValidateImageSizeCommand command = await testContext.RunTestAsync();

            testContext.Verify(isValidationErrorExpected: true);

            ImageSizeValidationResults results = command.ValidationResults;

            Assert.Single(results.ImagesWithNoSizeChange);
            Assert.Equal(SdkRelativeDir, results.ImagesWithNoSizeChange.First().Id);
            Assert.Equal(2, results.ImagesWithAllowedSizeChange.Count());
            Assert.Equal(RuntimeDeps1RelativeDir, results.ImagesWithAllowedSizeChange.ElementAt(0).Id);
            Assert.Equal(RuntimeRelativeDir, results.ImagesWithAllowedSizeChange.ElementAt(1).Id);
            Assert.Equal(2, results.ImagesWithDisallowedSizeChange.Count());
            Assert.Equal(RuntimeDeps2RelativeDir, results.ImagesWithDisallowedSizeChange.ElementAt(0).Id);
            Assert.Equal(AspnetRelativeDir, results.ImagesWithDisallowedSizeChange.ElementAt(1).Id);
            Assert.Empty(results.ImagesWithMissingBaseline);
            Assert.Empty(results.ImagesWithExtraneousBaseline);
        }
Пример #4
0
        public async Task NoSizeDifferences()
        {
            ImageSizeData[] imageSizes = new []
            {
                new ImageSizeData(RuntimeDepsRepo, RuntimeDeps1RelativeDir, RuntimeDeps1Tag, 1, 1),
                new ImageSizeData(RuntimeDepsRepo, RuntimeDeps2RelativeDir, RuntimeDeps2Tag, 2, 2),
                new ImageSizeData(RuntimeRepo, RuntimeRelativeDir, RuntimeTag, 3, 3),
                new ImageSizeData(AspnetRepo, AspnetRelativeDir, AspnetTag, 4, 4),
                new ImageSizeData(SdkRepo, SdkRelativeDir, SdkTag, 5, 5)
            };

            TestContext testContext          = new TestContext(imageSizes);
            ValidateImageSizeCommand command = await testContext.RunTestAsync();

            testContext.Verify(isValidationErrorExpected: false);

            ImageSizeValidationResults results = command.ValidationResults;

            Assert.Equal(5, results.ImagesWithNoSizeChange.Count());
            Assert.Empty(results.ImagesWithAllowedSizeChange);
            Assert.Empty(results.ImagesWithDisallowedSizeChange);
            Assert.Empty(results.ImagesWithMissingBaseline);
            Assert.Empty(results.ImagesWithExtraneousBaseline);
        }