public void TestGenerateAllFiles_Static_File()
        {
            IFile        file         = mocks.DynamicMock <IFile>();
            ProviderInfo providerMock = mocks.DynamicMock <ProviderInfo>();

            using (mocks.Record())
            {
                SetupFolder(folder, new IFolder[0], new IScript[0], new[] { file }, "");
                SetupProject();
                SetupLoader();
                SetupStaticFile(file);
                SetupProvider(providerMock);
                SetupController();
                Expect.Call(() => projectInfo.AddGeneratedFile(new GeneratedFile(
                                                                   "file.jpg", "C:\\Temp\\file.jpg", "file.jpg", "", "Iterator")));
            }

            GenerationHelper helper = new GenerationHelper(progressHelper, loader, projectInfo, fileController);
            ProjectFileTree  tree   = new ProjectFileTree();

            helper.GenerateAllFiles("", folder, tree, scriptObject, "C:\\Temp");

            Assert.That(tree.AllNodes.Count, Is.EqualTo(1));
            Assert.That(tree.AllNodes[0].Status, Is.EqualTo(ProjectFileStatusEnum.UnAnalysedFile));
            Assert.That(tree.AllNodes[0].Text, Is.EqualTo("file.jpg"));
            Assert.That(tree.ChildNodes[0].AssociatedFile.RelativeFilePath, Is.EqualTo("file.jpg"));
            BinaryFileInformation bfi = (BinaryFileInformation)tree.ChildNodes[0].AssociatedFile;

            Assert.That(bfi.NewGenFile.FilePath,
                        Is.EqualTo(Path.Combine(controller.GetTempFilePathForComponent(ComponentKey.Workbench_FileGenerator), tree.ChildNodes[0].AssociatedFile.RelativeFilePath)),
                        "New Gen file was not assigned to");
            mocks.VerifyAll();
        }
        public void TestGenerateAllFiles_Folder_Sub_File()
        {
            IFile        staticFile   = mocks.DynamicMock <IFile>();
            IScript      scriptFile   = mocks.DynamicMock <IScript>();
            IFolder      subFolder    = mocks.DynamicMock <IFolder>();
            ProviderInfo providerMock = mocks.DynamicMock <ProviderInfo>();

            using (mocks.Record())
            {
                SetupFolder(subFolder, new IFolder[0], new[] { scriptFile }, new[] { staticFile }, "folder");
                SetupFolder(folder, new[] { subFolder }, new IScript[0], new IFile[0], "");
                SetupProject();
                SetupStaticFile(staticFile);
                SetupScriptFile(scriptFile);
                SetupProvider(providerMock);
                SetupController();
                SetupLoader(scriptFile);
                Expect.Call(() => projectInfo.AddGeneratedFile(new GeneratedFile(
                                                                   "Class.cs", "C:\\Temp\\folder\\Class.cs", "folder\\Class.cs", "Class", "Iterator")));
                Expect.Call(() => projectInfo.AddGeneratedFile(new GeneratedFile(
                                                                   "file.jpg", "C:\\Temp\\folder\\file.jpg", "folder\\file.jpg", "", "Iterator")));
            }

            GenerationHelper helper = new GenerationHelper(progressHelper, loader, projectInfo, fileController);
            ProjectFileTree  tree   = new ProjectFileTree();

            helper.GenerateAllFiles("", folder, tree, scriptObject, "C:\\Temp");

            Assert.That(tree.AllNodes.Count, Is.EqualTo(3));
            ProjectFileTreeNode subfolder = tree.ChildNodes[0];

            Assert.That(subfolder.Status, Is.EqualTo(ProjectFileStatusEnum.Folder));
            Assert.That(subfolder.Text, Is.EqualTo("folder"));
            Assert.That(subfolder.ChildNodes.Count, Is.EqualTo(2));

            ProjectFileTreeNode childNode = subfolder.ChildNodes[0];

            Assert.That(childNode.Status, Is.EqualTo(ProjectFileStatusEnum.UnAnalysedFile));
            Assert.That(childNode.Text, Is.EqualTo("Class.cs"));
            Assert.That(childNode.ChildNodes, Is.Empty);
            Assert.That(childNode.AssociatedFile.RelativeFilePath, Is.EqualTo(Path.Combine("folder", "Class.cs")));
            TextFileInformation tfi = (TextFileInformation)childNode.AssociatedFile;

            Assert.That(tfi.NewGenFile.FilePath,
                        Is.EqualTo(Path.Combine(controller.GetTempFilePathForComponent(ComponentKey.Workbench_FileGenerator), childNode.AssociatedFile.RelativeFilePath)),
                        "New Gen file was not assigned to");

            childNode = subfolder.ChildNodes[1];
            Assert.That(childNode.Status, Is.EqualTo(ProjectFileStatusEnum.UnAnalysedFile));
            Assert.That(childNode.Text, Is.EqualTo("file.jpg"));
            Assert.That(childNode.ChildNodes, Is.Empty);
            Assert.That(childNode.AssociatedFile.RelativeFilePath, Is.EqualTo(Path.Combine("folder", "file.jpg")));
            BinaryFileInformation bfi = (BinaryFileInformation)childNode.AssociatedFile;

            Assert.That(bfi.NewGenFile.FilePath,
                        Is.EqualTo(Path.Combine(controller.GetTempFilePathForComponent(ComponentKey.Workbench_FileGenerator), childNode.AssociatedFile.RelativeFilePath)),
                        "New Gen file was not assigned to");

            mocks.VerifyAll();
        }
        public void TestGenerateAllFiles_No_Files()
        {
            using (mocks.Record())
            {
                SetupFolder(folder, new IFolder[0], new IScript[0], new IFile[0], "");
                SetupProject();
            }

            GenerationHelper helper = new GenerationHelper(progressHelper, loader, projectInfo, new FileController());
            ProjectFileTree  tree   = new ProjectFileTree();

            helper.GenerateAllFiles("fasdkj", folder, tree, scriptObject, "C:\\Temp");

            Assert.That(tree.AllNodes, Is.Empty);
        }