public void Returns_An_Empty_Collection()
        {
            CodeRootMap root = new CodeRootMap();

            root.AddCodeRoot(controller.Root, Version.NewGen);

            ReadOnlyCollection <IBaseConstruct> children =
                root.ChildNodes[0].GetSiblingsOfSameType(Version.User);

            Assert.That(children.Count, Is.EqualTo(0));
        }
        public void Returns_Three_Siblings()
        {
            CodeRootMap root = new CodeRootMap();

            root.AddCodeRoot(controller.Root, Version.NewGen);

            ReadOnlyCollection <IBaseConstruct> children =
                root.ChildNodes[0].ChildNodes[0].GetSiblingsOfSameType(Version.NewGen);

            Assert.That(children.Count, Is.EqualTo(3));
            Assert.That(children.Contains(func2), "Contains second function");
            Assert.That(children.Contains(func3), "Contains third function");
            Assert.That(children.Contains(func4), "Contains fourth function");
        }
        public void BasicRun()
        {
            AnalysisProgressHelperStub helperStub = new AnalysisProgressHelperStub();

            AnalysisHelper ah = new AnalysisHelper();

            ah.StartAnalysis(helperStub, controller, new ProjectFileTree());

            Assert.That(helperStub.Count, Is.EqualTo(0));
            Assert.That(helperStub.LastProgressObjectList.Count, Is.EqualTo(2));

            AnalyseFilesProgress progress = (AnalyseFilesProgress)helperStub.LastProgressObjectList[1];

            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));
        }
        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 + "}"));
        }