public void RemoveComponent_TheCurrentFolderDoesNotContainTheRemovableComponent_ReturnsFalse() { //Arrange Component removableFolder = SimpleComponentFactory.CreateComponent("Folder", "removableFolder"); //Act bool resultAfterRemoving = _currentFolder.Remove(removableFolder); //Assert Assert.False(resultAfterRemoving); }
public void CreateComponent_CreatingFolder_ReturnsNewObjectOfTypeFolder(string componentType) { //Arrange //Act Component resultAfterCreatingFolder1 = SimpleComponentFactory.CreateComponent(componentType, componentType); Component resultAfterCreatingFolder2 = SimpleComponentFactory.CreateComponent(componentType, componentType); //Assert Assert.AreEqual(resultAfterCreatingFolder1.GetType(), typeof(Folder)); Assert.AreEqual(resultAfterCreatingFolder2.GetType(), typeof(Folder)); }
public void CreateComponent_CreatingFile_ReturnsNewObjectOfTypeFile(string componentType) { //Arrange //Act Component resultAfterCreatingFile1 = SimpleComponentFactory.CreateComponent(componentType, componentType); Component resultAfterCreatingFile2 = SimpleComponentFactory.CreateComponent(componentType, componentType); //Assert Assert.AreEqual(typeof(File), resultAfterCreatingFile1.GetType()); Assert.AreEqual(typeof(File), resultAfterCreatingFile2.GetType()); }
public void CreateComponent_CreatingSomethingThatIsNotAComponent_ReturnsNull(string componentType) { //Arrange //Act Component resultAfterCreatingFolder = SimpleComponentFactory.CreateComponent(componentType, "Folder"); Component resultAfterCreatingFile = SimpleComponentFactory.CreateComponent(componentType, "File"); //Assert Assert.AreEqual(null, resultAfterCreatingFolder); Assert.AreEqual(null, resultAfterCreatingFile); }
public void AddNewFile_ThereIsAlreadyAComponentWithTheSameName_GiveAnErrorMessage() { //Arrange Component fileWithTheSameName = SimpleComponentFactory.CreateComponent("File", "SameName"); //Act _consoleFileManager.AddNewFileToTheCurrentDirectory(fileWithTheSameName.Name); //Assert string expectedMessage = "A component with this name already exists"; string actualMessage = _lastMessageFromViewer; Assert.AreEqual(expectedMessage, actualMessage); }
public void AddNewComponent_AnyAttemptToAddAComponentInFile_ReturnsFalse() { //Arrange Component newFolder = SimpleComponentFactory.CreateComponent("Folder", "newFolder"); Component newFile = SimpleComponentFactory.CreateComponent("File", "newFile"); //Act bool resultAfterAddingFolder = _currentFile.Add(newFolder); bool resultAfterAddingFile = _currentFile.Add(newFile); //Assert Assert.False(resultAfterAddingFolder); Assert.False(resultAfterAddingFile); }
public void RemoveComponent_AnyAttemptToRemoveAComponentFromFile_ReturnsFalse() { //Arrange Component removableFolder = SimpleComponentFactory.CreateComponent("Folder", "removableFolder"); Component removableFile = SimpleComponentFactory.CreateComponent("File", "removableFile"); //Act bool resultAfterRemovingFolder = _currentFile.Remove(removableFolder); bool resultAfterRemovingFile = _currentFile.Remove(removableFile); //Assert Assert.False(resultAfterRemovingFolder); Assert.False(resultAfterRemovingFile); }
public void RemoveComponent_TheCurrentFolderContainsTheRemovableComponent_RemovingComponentAndReturnsTrue() { //Arrange Component newFolder = SimpleComponentFactory.CreateComponent("Folder", "newFolder"); _currentFolder.Add(newFolder); //Act bool resultAfterRemoving = _currentFolder.Remove(newFolder); //Assert bool IsTheRemovedComponentAppearInTheCurrentFolder = isThereComponent("newFolder"); Assert.False(IsTheRemovedComponentAppearInTheCurrentFolder); Assert.True(resultAfterRemoving); }
public void GetPathOfTheCurrentDirectory_AddNewFolderAfterRootAndGoDownThere_ReturnPathWithNewFolderAfterRoot() { //Arrange Component newFolder = SimpleComponentFactory.CreateComponent("Folder", "newFolder"); Component rootFolder = _currentDirectory.GetCurrentComponent(); rootFolder.Add(newFolder); _currentDirectory.Down("newFolder"); //Act string actualPathOfCurrentDirectory = _currentDirectory.GetPathOfTheCurrentDirectory(); //Assert string expectedPathOfCurrentDirectory = "Root/newFolder/"; Assert.AreEqual(actualPathOfCurrentDirectory, expectedPathOfCurrentDirectory); }
public void GetPathOfTheCurrentDirectory_WeAreNotInTheRoot_ReturnTheFullPath(string nameOfFolderOnTheLowerLevel) { //Arrange Component componentOnTheLowerLevel = SimpleComponentFactory.CreateComponent("Folder", nameOfFolderOnTheLowerLevel); _currentDirectory.GetCurrentComponent().Add(componentOnTheLowerLevel); _currentDirectory.Down(nameOfFolderOnTheLowerLevel); //Act string actualPathOfCurrentDirectory = _currentDirectory.GetPathOfTheCurrentDirectory(); //Assert string expectedPathOfCurrentDirectory = $"Root/{nameOfFolderOnTheLowerLevel}/"; Assert.AreEqual(actualPathOfCurrentDirectory, expectedPathOfCurrentDirectory); }
public void GetCurrentComponent_AddNewFolderAfterRootAndGoDownThere_ReturnNameOfNewAddedFolder() { //Arrange Component newFolder = SimpleComponentFactory.CreateComponent("Folder", "newFolder"); Component rootFolder = _currentDirectory.GetCurrentComponent(); rootFolder.Add(newFolder); _currentDirectory.Down("newFolder"); //Act string actualNameOfCurrentComponent = _currentDirectory.GetCurrentComponent().Name; //Assert string expectedNameOfCurrentComponent = "newFolder"; Assert.AreEqual(actualNameOfCurrentComponent, expectedNameOfCurrentComponent); }
public void GetContents_FromNotEmptyFolder_ReturnsContentsOfThisFolder() { //Arrange Component folder = SimpleComponentFactory.CreateComponent("Folder", "folder"); Component file = SimpleComponentFactory.CreateComponent("File", "file"); _currentFolder.Add(folder); _currentFolder.Add(file); //Act List <Component> resultAfterGettingContentsFromNotEmptyFolder = _currentFolder.GetContents(); //Assert Assert.NotNull(resultAfterGettingContentsFromNotEmptyFolder); Assert.True(resultAfterGettingContentsFromNotEmptyFolder.Any(f => f.Name == "folder")); Assert.True(resultAfterGettingContentsFromNotEmptyFolder.Any(f => f.Name == "file")); }
public void GoDown_ComponentInWhichWeWantToGoDownIsComposite_GoDownIntoAComponentAndReturnsTrue() { //Arrange Component newFolder = SimpleComponentFactory.CreateComponent("Folder", "lowerFolder"); Component rootFolder = _currentDirectory.GetCurrentComponent(); rootFolder.Add(newFolder); //Act bool resultOfGoDown = _currentDirectory.Down("lowerFolder"); //Assert string expectedNameOfCurrentComponent = "lowerFolder"; string actualNameOfCurrentComponent = _currentDirectory.GetCurrentComponent().Name; Assert.AreEqual(expectedNameOfCurrentComponent, actualNameOfCurrentComponent); Assert.True(resultOfGoDown); }
public void GoDown_ComponentInWhichWeWantToGoDownIsNotComposite_NotGoDownAndReturnsFalse() { //Arrange Component newFile = SimpleComponentFactory.CreateComponent("File", "lowerFile"); Component rootFolder = _currentDirectory.GetCurrentComponent(); rootFolder.Add(newFile); //Act bool resultOfGoDown = _currentDirectory.Down("lowerFile"); //Assert string expectedNameOfCurrentComponent = "Root"; string actualNameOfCurrentComponent = _currentDirectory.GetCurrentComponent().Name; Assert.AreEqual(expectedNameOfCurrentComponent, actualNameOfCurrentComponent); Assert.False(resultOfGoDown); }
public void GoDownToTheLowerLevel_ComponentExistButIsNotAComposite_GiveAnErrorMessage() { //Arrange List <Component> fakeListWithNonCompositeComponent = new List <Component>(); fakeListWithNonCompositeComponent.Add(SimpleComponentFactory.CreateComponent("File", "nameOfNonCompositeComponent")); FakeComponent.Setup(method => method.GetContents()) .Returns(fakeListWithNonCompositeComponent); //Act _consoleFileManager.GoDownToTheLowerLevel("nameOfNonCompositeComponent"); //Assert string expectedMessage = "The component nameOfNonCompositeComponent can not be descended because it is not a composite"; string actualMessage = _lastMessageFromViewer; Assert.AreEqual(expectedMessage, actualMessage); }
public void RiseUp_WeAreNotInTheRoot_RiseUpAndReturnsTrue() { //Arrange Component newFolder = SimpleComponentFactory.CreateComponent("Folder", "lowerFolder"); Component rootFolder = _currentDirectory.GetCurrentComponent(); rootFolder.Add(newFolder); _currentDirectory.Down("lowerFolder"); //Act bool resultOfRiseUp = _currentDirectory.Up(); //Assert string expectedNameOfCurrentComponent = "Root"; string actualNameOfCurrentComponent = _currentDirectory.GetCurrentComponent().Name; Assert.AreEqual(expectedNameOfCurrentComponent, actualNameOfCurrentComponent); Assert.True(resultOfRiseUp); }
public void AddNewComponent_ThereIsNotComponentWithTheSameName_AddingANewComponentAndReturnsTrue() { //Arrange Component newFolder = SimpleComponentFactory.CreateComponent("Folder", "newFolder"); Component newFile = SimpleComponentFactory.CreateComponent("File", "newFile"); //Act bool resultAfterAddingFolder = _currentFolder.Add(newFolder); bool resultAfterAddingFile = _currentFolder.Add(newFile); //Assert bool IsTheAddedFolderAppearInTheCurrentFolder = isThereComponent("newFolder"); bool IsTheAddedFileAppearInTheCurrentFolder = isThereComponent("newFile"); Assert.True(IsTheAddedFolderAppearInTheCurrentFolder); Assert.True(IsTheAddedFileAppearInTheCurrentFolder); Assert.True(resultAfterAddingFolder); Assert.True(resultAfterAddingFile); }
public void AddNewComponent_ThereIsAComponentWithTheSameName_NotAddingANewComponentAndReturnsFalse() { //Arrange Component newFolder = SimpleComponentFactory.CreateComponent("Folder", "newFolder"); Component fileWithTheSameName = SimpleComponentFactory.CreateComponent("File", "newFolder"); _currentFolder.Add(newFolder); //Act bool resultAfterAddingFolderWithTheSameName = _currentFolder.Add(newFolder); bool resultAfterAddingFileWithTheSameName = _currentFolder.Add(fileWithTheSameName); //Assert int countOfComponentsInCurrentFolderAfterAdding = _currentFolder.GetContents().Count; int actualNumberOfComponentsInCurrentFolderAfterAdding = 1; Assert.AreEqual(countOfComponentsInCurrentFolderAfterAdding, actualNumberOfComponentsInCurrentFolderAfterAdding); Assert.False(resultAfterAddingFolderWithTheSameName); Assert.False(resultAfterAddingFileWithTheSameName); }
public FileTests() { _currentFile = SimpleComponentFactory.CreateComponent("File", "TestFile"); }
public FolderTests() { _currentFolder = SimpleComponentFactory.CreateComponent("Folder", "TestFolder"); }
public void SetUp() { _currentFolder = SimpleComponentFactory.CreateComponent("Folder", "TestFolder"); }