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_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_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); }
public DuplicateFileNameChecker(GenerationHelper helper, IWorkbenchProject project, string outputFolder) { this.helper = helper; _Project = project; _outputFolder = outputFolder; }
private void TestGenerateProject() { // Check whether the debug project exists. if (Controller.Instance.CheckDebugOptions(true) == false) return; Cursor = Cursors.WaitCursor; try { using (var worker = new BackgroundWorker()) { worker.DoWork += delegate { var project = new WorkbenchProject(); SharedData.CurrentProject = project; Utility.DisplayMessagePanel(this, "Generating Files", MessagePanel.ImageType.Hourglass); Utility.UpdateMessagePanelStatus(this, "Compiling Project"); // Compile the template to the new temporary location. bool compileResult = FunctionRunner.CreateTemplateFile(false, false); if (compileResult == false) { //ErrorReportingService.ReportError(ErrorLevel.Error, "Could not compile project"); throw new Exception("Could not compile project"); //return; } Utility.UpdateMessagePanelStatus(this, "Loading Project File"); // Load the project bool loadResult = project.Load(Project.Instance.DebugProjectFile, this, false, CompileHelper.CompiledAssemblyFileName); if (loadResult == false) { //ErrorReportingService.ReportError(ErrorLevel.Error, "Could not load project file. Open in ArchAngel Workbench for more information."); throw new Exception("Could not load project file. Open in ArchAngel Workbench for more information."); //return; } var helper = new GenerationHelper(new NullTaskProgressHelper<GenerateFilesProgress>(), project.TemplateLoader, project, new FileController()); Utility.UpdateMessagePanelStatus(this, "Writing Files"); project.PerformPreAnalysisActions(); helper.GenerateAllFiles("", project.CombinedOutput.RootFolder, null, null, Project.Instance.TestGenerateDirectory); }; worker.RunWorkerCompleted += (sndr, evnt) => Utility.HideMessagePanel(this); worker.RunWorkerAsync(); } } finally { Cursor = Cursors.Default; } }