public DeleteRepositoryConfiguration ( string repositoryName ) : IServiceResult | ||
repositoryName | string | |
return | IServiceResult |
public void Delete_RepositoryDoesNotExist_FailureResultMessageContainsRepositoryName(string repositoryName) { // Arrange var applicationInformation = new ApplicationInformation { ConfigurationFileFolder = Environment.CurrentDirectory }; var sourceRepositoryConfigurationFactory = new Mock<ISourceRepositoryConfigurationFactory>(); var filesystemPersistence = new Mock<IFilesystemPersistence<SourceRepositoryConfiguration[]>>(); filesystemPersistence.Setup(f => f.Load(It.IsAny<string>())).Returns(new SourceRepositoryConfiguration[] { }); var configFileSourceRepositoryProvider = new ConfigFileSourceRepositoryProvider( applicationInformation, sourceRepositoryConfigurationFactory.Object, filesystemPersistence.Object); // Act var result = configFileSourceRepositoryProvider.DeleteRepositoryConfiguration(repositoryName); // Assert Assert.IsTrue(result.Message.Contains(repositoryName), "The failure result should contain the name of the repository that shall be deleted."); }
public void Delete_RepositoryDoesNotExist_FailureResultIsReturned() { // Arrange string repositoryName = "Some Repository"; var applicationInformation = new ApplicationInformation { ConfigurationFileFolder = Environment.CurrentDirectory }; var sourceRepositoryConfigurationFactory = new Mock<ISourceRepositoryConfigurationFactory>(); var filesystemPersistence = new Mock<IFilesystemPersistence<SourceRepositoryConfiguration[]>>(); filesystemPersistence.Setup(f => f.Load(It.IsAny<string>())).Returns(new SourceRepositoryConfiguration[] { }); var configFileSourceRepositoryProvider = new ConfigFileSourceRepositoryProvider( applicationInformation, sourceRepositoryConfigurationFactory.Object, filesystemPersistence.Object); // Act var result = configFileSourceRepositoryProvider.DeleteRepositoryConfiguration(repositoryName); // Assert Assert.AreEqual(ServiceResultType.Failure, result.Status); }
public void Delete_RepositoryExists_TheSpecificRepostoryIsExcludedFromTheRepositoryList_CaseIsIgnored(string repositoryName) { // Arrange var applicationInformation = new ApplicationInformation { ConfigurationFileFolder = Environment.CurrentDirectory }; var sourceRepositoryConfigurationFactory = new Mock<ISourceRepositoryConfigurationFactory>(); var filesystemPersistence = new Mock<IFilesystemPersistence<SourceRepositoryConfiguration[]>>(); var existingRepositories = new[] { new SourceRepositoryConfiguration { Name = "Repo A", Url = new Uri("http://1.example.com/api/v2") }, new SourceRepositoryConfiguration { Name = "Repo B", Url = new Uri("http://2.example.com/api/v2") } }; filesystemPersistence.Setup(f => f.Load(It.IsAny<string>())).Returns(existingRepositories); filesystemPersistence.Setup(f => f.Save(It.IsAny<SourceRepositoryConfiguration[]>(), It.IsAny<string>())).Returns(true); var configFileSourceRepositoryProvider = new ConfigFileSourceRepositoryProvider( applicationInformation, sourceRepositoryConfigurationFactory.Object, filesystemPersistence.Object); // Act configFileSourceRepositoryProvider.DeleteRepositoryConfiguration(repositoryName); // Assert filesystemPersistence.Verify( f => f.Save( It.Is<SourceRepositoryConfiguration[]>(configurations => configurations.Length == 1 && configurations.First().Name == "Repo A"), It.IsAny<string>()), Times.Once()); }
public void Delete_RepositoryNameIsInvalid_ArgumentExceptionIsThrown(string repositoryName) { // Arrange var applicationInformation = new ApplicationInformation { ConfigurationFileFolder = Environment.CurrentDirectory }; var sourceRepositoryConfigurationFactory = new Mock<ISourceRepositoryConfigurationFactory>(); var filesystemPersistence = new Mock<IFilesystemPersistence<SourceRepositoryConfiguration[]>>(); var configFileSourceRepositoryProvider = new ConfigFileSourceRepositoryProvider( applicationInformation, sourceRepositoryConfigurationFactory.Object, filesystemPersistence.Object); // Act configFileSourceRepositoryProvider.DeleteRepositoryConfiguration(repositoryName); }
public void Delete_RepositoryExists_SaveSucceeds_SuccessResultIsReturned() { // Arrange string repositoryName = "Repo B"; var applicationInformation = new ApplicationInformation { ConfigurationFileFolder = Environment.CurrentDirectory }; var sourceRepositoryConfigurationFactory = new Mock<ISourceRepositoryConfigurationFactory>(); var filesystemPersistence = new Mock<IFilesystemPersistence<SourceRepositoryConfiguration[]>>(); var existingRepositories = new[] { new SourceRepositoryConfiguration { Name = "Repo A", Url = new Uri("http://1.example.com/api/v2") }, new SourceRepositoryConfiguration { Name = "Repo B", Url = new Uri("http://2.example.com/api/v2") } }; filesystemPersistence.Setup(f => f.Load(It.IsAny<string>())).Returns(existingRepositories); filesystemPersistence.Setup(f => f.Save(It.IsAny<SourceRepositoryConfiguration[]>(), It.IsAny<string>())).Returns(true); var configFileSourceRepositoryProvider = new ConfigFileSourceRepositoryProvider( applicationInformation, sourceRepositoryConfigurationFactory.Object, filesystemPersistence.Object); // Act var result = configFileSourceRepositoryProvider.DeleteRepositoryConfiguration(repositoryName); // Assert Assert.AreEqual(ServiceResultType.Success, result.Status); }