GetPublishConfiguration() public method

public GetPublishConfiguration ( string configurationName ) : PublishConfiguration
configurationName string
return PublishConfiguration
        public void GetPublishConfiguration_ConfigurationNameParameterIsValid_PublishConfigurationPersistenceReturnsNoMatchingEntries_ResultIsNull()
        {
            // 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 publishConfigurations = 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(publishConfigurations);

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

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

            // Assert
            Assert.IsNull(result);
        }
        public void GetPublishConfiguration_ConfigurationNameParameterIsValid_PublishConfigurationPersistenceReturnsNull_ResultIsNull()
        {
            // Arrange
            string configurationName = "Some non existing Configuration";

            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.GetPublishConfiguration(configurationName);

            // Assert
            Assert.IsNull(result);
        }
        public void GetPublishConfiguration_ConfigurationNameParameterIsInvalid_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.GetPublishConfiguration(configurationName);
        }