DeletePublishConfiguration() public method

public DeletePublishConfiguration ( string configurationName ) : IServiceResult
configurationName string
return IServiceResult
        public void DeletePublishConfiguration_PublishConfigurationPersistenceReturnsNull_ResultIsFalse()
        {
            // Arrange
            string configurationName = "Some Configuration Name";

            var applicationInformation = new ApplicationInformation { ConfigurationFileFolder = Environment.CurrentDirectory };
            var publishConfigurationFactory = new Mock<IPublishConfigurationFactory>();
            var publishConfigurationPersistence = new Mock<IFilesystemPersistence<PublishConfiguration[]>>();

            PublishConfiguration[] persitedConfigurations = null;
            publishConfigurationPersistence.Setup(p => p.Load(It.IsAny<string>())).Returns(persitedConfigurations);

            var configFilePublishConfigurationAccessor = new ConfigFilePublishConfigurationAccessor(
                applicationInformation, publishConfigurationFactory.Object, publishConfigurationPersistence.Object);

            // Act
            var result = configFilePublishConfigurationAccessor.DeletePublishConfiguration(configurationName);

            // Assert
            Assert.AreEqual(ServiceResultType.Failure, result.Status);
        }
        public void DeletePublishConfiguration_PublishConfigurationPersistenceReturnsAMatchingEntry_ReducedListIsPersisted(string configurationName)
        {
            // Arrange
            var applicationInformation = new ApplicationInformation { ConfigurationFileFolder = Environment.CurrentDirectory };
            var publishConfigurationFactory = new Mock<IPublishConfigurationFactory>();
            var publishConfigurationPersistence = new Mock<IFilesystemPersistence<PublishConfiguration[]>>();

            var persitedConfigurations = new[]
                {
                    new PublishConfiguration { Name = "Some Name 1", PublishLocation = "http://some-nuget-server-1.com/api/v2" },
                    new PublishConfiguration { Name = "Some Name 2", PublishLocation = "http://some-nuget-server-2.com/api/v2" },
                    new PublishConfiguration { Name = "Some Name 3", PublishLocation = "http://some-nuget-server-3.com/api/v2" }
                };

            publishConfigurationPersistence.Setup(p => p.Load(It.IsAny<string>())).Returns(persitedConfigurations);

            var configFilePublishConfigurationAccessor = new ConfigFilePublishConfigurationAccessor(
                applicationInformation, publishConfigurationFactory.Object, publishConfigurationPersistence.Object);

            // Act
            configFilePublishConfigurationAccessor.DeletePublishConfiguration(configurationName);

            // Assert
            publishConfigurationPersistence.Verify(
                p =>
                p.Save(
                    It.Is<PublishConfiguration[]>(
                        configs => configs.Length == persitedConfigurations.Length - 1 && configs.Any(c => c.Name.Equals(configurationName)) == false),
                    It.IsAny<string>()),
                Times.Once());
        }
        public void DeletePublishConfiguration_PublishConfigurationPersistenceReturnsNoMatchingEntries_ResultIsFalse()
        {
            // Arrange
            string configurationName = "Some Other Name";

            var applicationInformation = new ApplicationInformation { ConfigurationFileFolder = Environment.CurrentDirectory };
            var publishConfigurationFactory = new Mock<IPublishConfigurationFactory>();
            var publishConfigurationPersistence = new Mock<IFilesystemPersistence<PublishConfiguration[]>>();

            var persitedConfigurations = new[]
                {
                    new PublishConfiguration { Name = "Some Name 1", PublishLocation = "http://some-nuget-server-1.com/api/v2" },
                    new PublishConfiguration { Name = "Some Name 2", PublishLocation = "http://some-nuget-server-2.com/api/v2" },
                    new PublishConfiguration { Name = "Some Name 3", PublishLocation = "http://some-nuget-server-3.com/api/v2" }
                };

            publishConfigurationPersistence.Setup(p => p.Load(It.IsAny<string>())).Returns(persitedConfigurations);

            var configFilePublishConfigurationAccessor = new ConfigFilePublishConfigurationAccessor(
                applicationInformation, publishConfigurationFactory.Object, publishConfigurationPersistence.Object);

            // Act
            var result = configFilePublishConfigurationAccessor.DeletePublishConfiguration(configurationName);

            // Assert
            Assert.AreEqual(ServiceResultType.Failure, result.Status);
        }
        public void DeletePublishConfiguration_ConfigurationNameIsInvalid_ArgumentExceptionIsThrown(string configurationName)
        {
            // Arrange
            var applicationInformation = new ApplicationInformation { ConfigurationFileFolder = Environment.CurrentDirectory };
            var publishConfigurationFactory = new Mock<IPublishConfigurationFactory>();
            var publishConfigurationPersistence = new Mock<IFilesystemPersistence<PublishConfiguration[]>>();

            var configFilePublishConfigurationAccessor = new ConfigFilePublishConfigurationAccessor(
                applicationInformation, publishConfigurationFactory.Object, publishConfigurationPersistence.Object);

            // Act
            configFilePublishConfigurationAccessor.DeletePublishConfiguration(configurationName);
        }