Exemple #1
0
        public void FallsBackToItemSpecWhenIdentityDoesNotExist()
        {
            // Arrange
            var errorMessages = new List <string>();
            var buildEngine   = new Mock <IBuildEngine>();

            buildEngine.Setup(e => e.LogErrorEvent(It.IsAny <BuildErrorEventArgs>()))
            .Callback <BuildErrorEventArgs>(args => errorMessages.Add(args.Message));

            File.Create(ItemSpec);

            var asset = new StaticWebAsset()
            {
                Identity         = ItemSpec,
                OriginalItemSpec = OriginalItemSpec
            };

            var task = new ComputeBlazorFilesToCompress
            {
                BuildEngine = buildEngine.Object,
                Assets      = new[] { asset.ToTaskItem() }
            };

            // Act
            var result = task.Execute();

            // Assert
            result.Should().BeTrue();
            task.AssetsToCompress.Should().HaveCount(1);
            task.AssetsToCompress[0].ItemSpec.Should().Be(ItemSpec);
        }
Exemple #2
0
        public void FailsWhenNeitherIdentityNorOriginalItemSpecExist()
        {
            // Arrange
            var errorMessages = new List <string>();
            var buildEngine   = new Mock <IBuildEngine>();

            buildEngine.Setup(e => e.LogErrorEvent(It.IsAny <BuildErrorEventArgs>()))
            .Callback <BuildErrorEventArgs>(args => errorMessages.Add(args.Message));

            var asset = new StaticWebAsset()
            {
                Identity         = ItemSpec,
                OriginalItemSpec = OriginalItemSpec
            };

            var task = new ComputeBlazorFilesToCompress
            {
                BuildEngine = buildEngine.Object,
                Assets      = new[] { asset.ToTaskItem() }
            };

            // Act
            var result = task.Execute();

            // Assert
            result.Should().BeFalse();
            task.AssetsToCompress.Should().BeEmpty();
        }