Execute() 공개 메소드

public Execute ( ) : bool
리턴 bool
        public void Execute_PublishingFails_FailureResultIsWrittenTouUserInterface()
        {
            // Arrange
            var buildOutputPackagingService = new Mock<IBuildOutputPackagingService>();
            var publishingService = new Mock<IPublishingService>();

            buildOutputPackagingService.Setup(b => b.Package(It.IsAny<string>())).Returns(new SuccessResult());

            string publishingFailureMessage = "Publishing failed. yada yada. " + Guid.NewGuid().ToString();
            publishingService.Setup(p => p.PublishPackage(It.IsAny<string>(), It.IsAny<string>())).Returns(new FailureResult(publishingFailureMessage));

            var packageBuildOutputCommand = new PackageBuildOutputCommand(this.loggingUserInterface.UserInterface, buildOutputPackagingService.Object, publishingService.Object);

            // prepare arguments
            string publishConfigurationName = "Some Publish Configuration";
            string buildOutputFolderPath = "C:\\build-output";
            packageBuildOutputCommand.Arguments.Add(PackageBuildOutputCommand.ArgumentNameBuildOutputFolderPath, buildOutputFolderPath);
            packageBuildOutputCommand.Arguments.Add(PackageBuildOutputCommand.ArgumentNamePublishingConfiguration, publishConfigurationName);

            // Act
            packageBuildOutputCommand.Execute();

            // Assert
            Assert.IsTrue(
                this.loggingUserInterface.UserInterfaceOutput.Contains(publishingFailureMessage),
                "The user interface should contain the failure message \"{0}\" but contains this \"{1}\"",
                publishingFailureMessage,
                this.loggingUserInterface.UserInterfaceOutput);
        }
        public void Execute_PublishingSucceeds_SuccessMessageIsWrittenTouUserInterface()
        {
            // Arrange
            var buildOutputPackagingService = new Mock<IBuildOutputPackagingService>();
            var publishingService = new Mock<IPublishingService>();

            string packagePath = @"C:\some-package.nupkg";
            buildOutputPackagingService.Setup(b => b.Package(It.IsAny<string>())).Returns(new SuccessResult { ResultArtefact = packagePath });
            publishingService.Setup(p => p.PublishPackage(It.IsAny<string>(), It.IsAny<string>())).Returns(new SuccessResult());

            var packageBuildOutputCommand = new PackageBuildOutputCommand(this.loggingUserInterface.UserInterface, buildOutputPackagingService.Object, publishingService.Object);

            // prepare arguments
            string publishConfigurationName = "Some Publish Configuration";
            string buildOutputFolderPath = "C:\\build-output";
            packageBuildOutputCommand.Arguments.Add(PackageBuildOutputCommand.ArgumentNameBuildOutputFolderPath, buildOutputFolderPath);
            packageBuildOutputCommand.Arguments.Add(PackageBuildOutputCommand.ArgumentNamePublishingConfiguration, publishConfigurationName);

            // Act
            packageBuildOutputCommand.Execute();

            // Assert
            Assert.IsTrue(
                this.loggingUserInterface.UserInterfaceOutput.Contains(packagePath)
                && this.loggingUserInterface.UserInterfaceOutput.Contains(publishConfigurationName),
                "The user interface should contain the package path \"{0}\" and the publish configuration name \"{1}\" but contains this \"{2}\"",
                packagePath,
                publishConfigurationName,
                this.loggingUserInterface.UserInterfaceOutput);
        }
        public void Execute_PackagingSucceeds_ResultIsTrue()
        {
            // Arrange
            var userInterface = new Mock<IUserInterface>();
            var buildOutputPackagingService = new Mock<IBuildOutputPackagingService>();
            var publishingService = new Mock<IPublishingService>();

            buildOutputPackagingService.Setup(b => b.Package(It.IsAny<string>())).Returns(new SuccessResult());

            var packageBuildOutputCommand = new PackageBuildOutputCommand(userInterface.Object, buildOutputPackagingService.Object, publishingService.Object);

            // prepare arguments
            string buildOutputFolderPath = "C:\\build-output";
            packageBuildOutputCommand.Arguments.Add(PackageBuildOutputCommand.ArgumentNameBuildOutputFolderPath, buildOutputFolderPath);

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

            // Assert
            Assert.IsTrue(result);
        }
        public void Execute_PublishConfigurationIsSet_PublishIsExecuted()
        {
            // Arrange
            var userInterface = new Mock<IUserInterface>();
            var buildOutputPackagingService = new Mock<IBuildOutputPackagingService>();
            var publishingService = new Mock<IPublishingService>();

            buildOutputPackagingService.Setup(b => b.Package(It.IsAny<string>())).Returns(new SuccessResult());
            publishingService.Setup(p => p.PublishPackage(It.IsAny<string>(), It.IsAny<string>())).Returns(new SuccessResult());

            var packageBuildOutputCommand = new PackageBuildOutputCommand(userInterface.Object, buildOutputPackagingService.Object, publishingService.Object);

            // prepare arguments
            string publishConfigurationName = "Some Publish Configuration";
            string buildOutputFolderPath = "C:\\build-output";
            packageBuildOutputCommand.Arguments.Add(PackageBuildOutputCommand.ArgumentNameBuildOutputFolderPath, buildOutputFolderPath);
            packageBuildOutputCommand.Arguments.Add(PackageBuildOutputCommand.ArgumentNamePublishingConfiguration, publishConfigurationName);

            // Act
            packageBuildOutputCommand.Execute();

            // Assert
            publishingService.Verify(p => p.PublishPackage(It.IsAny<string>(), publishConfigurationName), Times.Once());
        }
        public void Execute_BuildOutputPathArgumentIsNotSet_ResultIsFalse()
        {
            // Arrange
            var buildOutputPackagingService = new Mock<IBuildOutputPackagingService>();
            var publishingService = new Mock<IPublishingService>();
            var packageBuildOutputCommand = new PackageBuildOutputCommand(this.loggingUserInterface.UserInterface, buildOutputPackagingService.Object, publishingService.Object);

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

            // Assert
            Assert.AreEqual(false, result);
        }
        public void Execute_PackagingSucceeds_MessageIsWrittenToUserInterface()
        {
            // Arrange
            var buildOutputPackagingService = new Mock<IBuildOutputPackagingService>();
            var publishingService = new Mock<IPublishingService>();

            buildOutputPackagingService.Setup(b => b.Package(It.IsAny<string>())).Returns(new SuccessResult());

            var packageBuildOutputCommand = new PackageBuildOutputCommand(this.loggingUserInterface.UserInterface, buildOutputPackagingService.Object, publishingService.Object);

            // prepare arguments
            string buildOutputFolderPath = "C:\\build-output";
            packageBuildOutputCommand.Arguments.Add(PackageBuildOutputCommand.ArgumentNameBuildOutputFolderPath, buildOutputFolderPath);

            // Act
            packageBuildOutputCommand.Execute();

            // Assert
            Assert.IsFalse(string.IsNullOrEmpty(this.loggingUserInterface.UserInterfaceOutput));
        }
        public void Execute_BuildOutputPathArgumentIsNotSet_PackageSolutionIsNotExecuted()
        {
            // Arrange
            var buildOutputPackagingService = new Mock<IBuildOutputPackagingService>();
            var publishingService = new Mock<IPublishingService>();
            var packageBuildOutputCommand = new PackageBuildOutputCommand(this.loggingUserInterface.UserInterface, buildOutputPackagingService.Object, publishingService.Object);

            // Act
            packageBuildOutputCommand.Execute();

            // Assert
            buildOutputPackagingService.Verify(s => s.Package(It.IsAny<string>()), Times.Never());
        }
        public void Execute_BuildOutputPathArgumentIsNotSet_MessageIsWrittenToUserInterface()
        {
            // Arrange
            var buildOutputPackagingService = new Mock<IBuildOutputPackagingService>();
            var publishingService = new Mock<IPublishingService>();
            var packageBuildOutputCommand = new PackageBuildOutputCommand(this.loggingUserInterface.UserInterface, buildOutputPackagingService.Object, publishingService.Object);

            // Act
            packageBuildOutputCommand.Execute();

            // Assert
            Assert.IsNotNullOrEmpty(this.loggingUserInterface.UserInterfaceOutput);
        }
        public void Execute_BuildOutputPathArgumentIsInvalid_ResultIsFalse(string buildOutputPath)
        {
            // Arrange
            var buildOutputPackagingService = new Mock<IBuildOutputPackagingService>();
            var publishingService = new Mock<IPublishingService>();
            var packageBuildOutputCommand = new PackageBuildOutputCommand(this.loggingUserInterface.UserInterface, buildOutputPackagingService.Object, publishingService.Object);

            // prepare command arguments
            packageBuildOutputCommand.Arguments.Add(PackageBuildOutputCommand.ArgumentNameBuildOutputFolderPath, buildOutputPath);

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

            // Assert
            Assert.AreEqual(false, result);
        }
        public void Execute_BuildOutputPathArgumentIsInvalid_PackageSolutionIsNotExecuted(string buildOutputPath)
        {
            // Arrange
            var buildOutputPackagingService = new Mock<IBuildOutputPackagingService>();
            var publishingService = new Mock<IPublishingService>();
            var packageBuildOutputCommand = new PackageBuildOutputCommand(this.loggingUserInterface.UserInterface, buildOutputPackagingService.Object, publishingService.Object);

            // prepare command arguments
            packageBuildOutputCommand.Arguments.Add(PackageBuildOutputCommand.ArgumentNameBuildOutputFolderPath, buildOutputPath);

            // Act
            packageBuildOutputCommand.Execute();

            // Assert
            buildOutputPackagingService.Verify(s => s.Package(It.IsAny<string>()), Times.Never());
        }
        public void Execute_BuildOutputPathArgumentIsInvalid_MessageIsWrittenToUserInterface(string buildOutputPath)
        {
            // Arrange
            var buildOutputPackagingService = new Mock<IBuildOutputPackagingService>();
            var publishingService = new Mock<IPublishingService>();
            var packageBuildOutputCommand = new PackageBuildOutputCommand(this.loggingUserInterface.UserInterface, buildOutputPackagingService.Object, publishingService.Object);

            // prepare command arguments
            packageBuildOutputCommand.Arguments.Add(PackageBuildOutputCommand.ArgumentNameBuildOutputFolderPath, buildOutputPath);

            // Act
            packageBuildOutputCommand.Execute();

            // Assert
            Assert.IsNotNullOrEmpty(this.loggingUserInterface.UserInterfaceOutput);
        }