public void AddFolder_ShouldCreateNewFolderInProjectFolderAndNotifyWithEvent() { // Arrange object?eventSender = null; ProjectFolderAddedEventArgs?eventArgs = null; _folder.FolderAdded += (sender, args) => { eventSender = sender; eventArgs = args; }; // Act var newFolder = _folder.AddFolder("New folder"); // Assert Assert.That(_folder.Folders, Has.Count.EqualTo(1)); Assert.That(newFolder, Is.EqualTo(_folder.Folders.Single())); Assert.That(newFolder.FolderName, Is.EqualTo("New folder")); Assert.That(newFolder.FolderPath, Is.EqualTo(Path.Combine(_folder.FolderPath, "New folder"))); Assert.That(Directory.Exists(newFolder.FolderPath), Is.True); Assert.That(eventSender, Is.EqualTo(_folder)); Debug.Assert(eventArgs != null, nameof(eventArgs) + " != null"); Assert.That(eventArgs.Folder, Is.EqualTo(newFolder)); }
public IProjectFolder AddFolder(string dirName, IProjectFolder parentFolder) { IProjectFolder folder = new ProjectFolder(this, dirName); parentFolder.AddFolder(folder); return(folder); }
private void RecurseReadFolders(XmlTextReader reader, ref IProjectFolder folder) { if (reader.IsEmptyElement) { return; } while (reader.Read()) { if (reader.NodeType == XmlNodeType.EndElement) { return; } if (reader.Name == "Folder") { IProjectFolder subFolder = new ProjectFolder(this, reader.GetAttribute("Name")); folder.AddFolder(subFolder); RecurseReadFolders(reader, ref subFolder); } else if (reader.Name == "File") { IProjectFile file = new ProjectFile(this, reader.GetAttribute("Path")); folder.AddFile(file); } else { return; } } }