public void TestAddChildNodeWithAssociatedFile() { // We don't need this to do anything except be not null. IFileInformation fileInformation = MockRepository.GenerateStub <IFileInformation>(); ProjectFileTree tree = new ProjectFileTree(); ProjectFileTreeNode child = tree.AddChildNode(fileInformation); Assert.That(tree.ChildNodes[0].AssociatedFile, Is.SameAs(fileInformation), "The child must be constructed with the supplied AssociatedFile."); Assert.That(tree.ChildNodes[0], Is.SameAs(child), "The first ChildNode must be the new child node."); Assert.That(tree.AllNodes[0], Is.SameAs(child), "The first node in the AllNodes collection must be the new child."); }
public void TestAddChildNodeWithNullFile() { ProjectFileTree tree = new ProjectFileTree(); ProjectFileTreeNode child = tree.AddChildNode(); Assert.That(tree.ChildNodes.Count, Is.EqualTo(1), "The child should have been added to the tree's ChildNodes"); Assert.That(tree.AllNodes.Count, Is.EqualTo(1), "The child should have been added to the tree's Nodes"); Assert.That(tree.ChildNodes[0], Is.SameAs(child), "The first ChildNode must be the new child node."); Assert.That(tree.AllNodes[0], Is.SameAs(child), "The first node in the AllNodes collection must be the new child."); Assert.That(tree.ChildNodes[0].AssociatedFile, Is.Null, "The child must be constructed with a null AssociatedFile."); Assert.That(tree.ChildNodes[0].ParentNode, Is.SameAs(tree), "The ParentNode must be the tree."); Assert.That(tree.ChildNodes[0].ParentTree, Is.SameAs(tree), "The ParentTree must be the tree."); Assert.That(tree.ChildNodes[0].Status, Is.EqualTo(ProjectFileStatusEnum.UnAnalysedFile), "A ProjectFileTreeNode's status must be UnanalysedFile by default."); }
public void Test_LoadPrevGenFile() { TextFileInformation tfi = new TextFileInformation(); tfi.RelativeFilePath = RelativePath; ProjectFileTree tree = new ProjectFileTree(); tree.AddChildNode(tfi, RelativePath); tree.LoadPrevGenFiles(controller); // loading a non existant file will result in tfi.PrevGenFile being set to TextFile.Blank Assert.That(tfi.PrevGenFile.FilePath, Is.Null); Assert.That(tfi.PrevGenFile.HasContents, Is.False); Assert.That(tfi.PrevGenFile.IsFileOnDisk, Is.False); }
public void Folder_And_File() { AnalysisProgressHelperStub helperStub = new AnalysisProgressHelperStub(); ProjectFileTree tree = new ProjectFileTree(); TextFileInformation tfi = new TextFileInformation(); tfi.RelativeFilePath = "Class.cs"; tfi.PrevGenFile = tfi.NewGenFile = tfi.UserFile = new TextFile("public class SomeClass { }"); tree.AddChildNode("folder").AddChildNode(tfi, "Class.cs"); AnalysisHelper ah = new AnalysisHelper(); ah.StartAnalysis(helperStub, controller, tree); Assert.That(tfi.CurrentDiffResult.DiffType, Is.EqualTo(TypeOfDiff.ExactCopy)); Assert.That(helperStub.Count, Is.EqualTo(0)); Assert.That(helperStub.LastProgressObjectList.Count, Is.EqualTo(4)); AnalyseFilesProgress progress = (AnalyseFilesProgress)helperStub.LastProgressObjectList[2]; Assert.That(progress, Is.Not.Null); Assert.That(progress.NumberOfConflicts, Is.EqualTo(0)); Assert.That(progress.NumberOfResolved, Is.EqualTo(0)); Assert.That(progress.NumberOfExactCopies, Is.EqualTo(0)); Assert.That(progress.ChangedFilePath, Is.EqualTo("folder\\Class.cs")); Assert.That(progress.ChangedFileStatus, Is.EqualTo(ProjectFileStatusEnum.Busy)); progress = (AnalyseFilesProgress)helperStub.LastProgressObjectList[3]; Assert.That(progress, Is.Not.Null); Assert.That(progress.NumberOfConflicts, Is.EqualTo(0)); Assert.That(progress.NumberOfResolved, Is.EqualTo(0)); Assert.That(progress.NumberOfExactCopies, Is.EqualTo(1)); Assert.That(progress.ChangedFilePath, Is.EqualTo("folder\\Class.cs")); Assert.That(progress.ChangedFileStatus, Is.EqualTo(ProjectFileStatusEnum.AnalysedFile)); string nl = Environment.NewLine; Assert.That(tfi.CalculateMergedFile(), Is.True); Assert.That(tfi.MergedFile.HasContents, Is.True); Assert.That(tfi.MergedFile.GetContents(), Is.EqualTo(nl + "public class SomeClass" + nl + "{" + nl + nl + "}")); }