public void Create_WithEmptyName_ThrowsInvalidNameException(string directoryName)
        {
            // Arrange
              var testManager = new FileSystemContainerManager("test", MockedDirectory());

              // Act & Assert
              Assert.Throws<InvalidNameException>(() => testManager.Create(directoryName));
        }
        public void Get_WithNonExistentContainer_ReturnsNull(string directoryName)
        {
            // Arrange
              var mockedDirectory = MockRepository.GenerateStub<IDirectoryWrap>();
              mockedDirectory.Stub(x => x.GetDirectories("test")).Return(new[] { "foo", "bar" });
              var testManager = new FileSystemContainerManager("test", mockedDirectory);

              // Act
              var container = testManager.Get("baz");

              // Assert
              Assert.That(container, Is.Null);
        }
        public void List_ReturnsDirectoryListing(string rootPath)
        {
            // Arrange
              var mockedDirectory = MockedDirectory();
              mockedDirectory.Stub(x => x.GetDirectories(rootPath)).Return(new[] { "a", "b", "c" });

              var testManager = new FileSystemContainerManager(rootPath, mockedDirectory);

              // Act
              var results = testManager.List();

              // Assert
              Assert.That(results.Count(), Is.EqualTo(3));
              Assert.IsTrue(results.OfType<FileSystemContainer>().Any(x => x.DirectoryPath == "a"));
              Assert.IsTrue(results.OfType<FileSystemContainer>().Any(x => x.DirectoryPath == "b"));
              Assert.IsTrue(results.OfType<FileSystemContainer>().Any(x => x.DirectoryPath == "c"));
        }
        public void Get_WithExistingContainer_ReturnsSelectedContainer(string directoryName)
        {
            // Arrange
              var mockedDirectory = MockRepository.GenerateStub<IDirectoryWrap>();
              mockedDirectory.Stub(x => x.GetDirectories("test")).Return(new[] { "foo", "bar" });
              var testManager = new FileSystemContainerManager("test", mockedDirectory);

              // Act
              var container = testManager.Get(directoryName);

              // Assert
              Assert.That(container.Name, Is.EqualTo(directoryName));
        }
        public void Get_WithInvalidName_ThrowsInvalidNameException(string name)
        {
            // Arrange
              var testManager = new FileSystemContainerManager("test", MockedDirectory());

              // Act & Assert
              Assert.Throws<InvalidNameException>(() => testManager.Get(name));
        }
        public void Delete_WithValidName_DeletesContainer(string directoryName)
        {
            // Arrange
              var expectedPath = "test" + System.IO.Path.DirectorySeparatorChar + directoryName;

              var mockedDirectory = MockedDirectory();
              mockedDirectory.Expect(x => x.Delete(expectedPath, true));
              var testManager = new FileSystemContainerManager("test", mockedDirectory);

              // Act
              testManager.Delete(directoryName);

              // Assert
              mockedDirectory.AssertWasCalled(x => x.Delete(expectedPath, true));
        }
        public void Delete_WithDirectoryName_ChecksProperPath(string directoryName)
        {
            // Arrange
              var expectedPath = "test" + Path.DirectorySeparatorChar + directoryName;

              var mockedDirectory = MockRepository.GenerateMock<IDirectoryWrap>();
              mockedDirectory.Expect(x => x.Exists(expectedPath)).Return(false);
              var testManager = new FileSystemContainerManager("test", mockedDirectory);

              // Act
              testManager.Delete(directoryName);

              // Assert
              mockedDirectory.AssertWasCalled(x => x.Exists(expectedPath));
        }
        public void Delete_DirectoryDoesNotExist_DoesNotCallDelete(string directoryName)
        {
            // Arrange
              var mockedDirectory = MockedDirectory(false);
              mockedDirectory.Expect(x => x.Delete(directoryName, true));
              var testManager = new FileSystemContainerManager("test", mockedDirectory);

              // Act
              testManager.Delete(directoryName);

              // Assert
              mockedDirectory.AssertWasNotCalled(x => x.Delete(directoryName, true));
        }
        public void Create_WithValidName_ReturnsCreatedContainer(string newDirectory)
        {
            // Arrange
              var mockedDirectory = MockedDirectory();
              mockedDirectory.Stub(x => x.CreateDirectory(newDirectory));
              var testManager = new FileSystemContainerManager("test", mockedDirectory);

              // Act
              var result = testManager.Create(newDirectory);

              // Assert
              Assert.That(((FileSystemContainer)result).DirectoryPath, Is.EqualTo(newDirectory));
        }
        public void Create_WithValidName_CreatesDirectory(string newDirectory)
        {
            // Arrange
              var expectedPath = "test" + Path.DirectorySeparatorChar + newDirectory;

              var mockedDirectory = MockedDirectory();
              mockedDirectory.Expect(x => x.CreateDirectory(expectedPath));
              var testManager = new FileSystemContainerManager("test", mockedDirectory);

              // Act
              testManager.Create(newDirectory);

              // Assert
              mockedDirectory.AssertWasCalled(x => x.CreateDirectory(expectedPath));
        }