Ejemplo n.º 1
0
        public static void run_writes_the_expected_files_to_disk()
        {
            var mockFileSystem = GenerateMockFileSystem();

            mockFileSystem.GetFileInfoMock = (path) =>
            {
                var generalMock = new MockFileWrapper(path, Path.GetDirectoryName(path), new DateTime(1, 1, 1));
                generalMock.ExistsMock = () => { return(true); };
                return(generalMock);
            };

            var codegenJob = new StubCodegenJob(OutputDirectory, mockFileSystem, new List <string>()
            {
                "TestSchema.schema"
            }, new List <string>()
            {
                "TestOutput.h", "TestOutput.cpp"
            });

            codegenJob.Run();

            Assert.That(mockFileSystem.WriteToFileCallCount == 2);
            Assert.That(mockFileSystem.WrittenFiles.Contains(Path.Combine(OutputDirectory, "TestOutput.h")));
            Assert.That(mockFileSystem.WrittenFiles.Contains(Path.Combine(OutputDirectory, "TestOutput.cpp")));
        }
Ejemplo n.º 2
0
        public static void is_dirty_returns_true_if_not_all_output_files_of_a_job_are_present()
        {
            var mockFileSystem = GenerateMockFileSystem();

            mockFileSystem.GetFileInfoMock = (path) =>
            {
                var fileName = Path.GetFileName(path);
                if (fileName == "TestOutput.h")
                {
                    var schemaMock = new MockFileWrapper(path, Path.GetDirectoryName(path), new DateTime(1, 1, 1));
                    schemaMock.ExistsMock = () => { return(false); };
                    return(schemaMock);
                }

                var generalMock = new MockFileWrapper(path, Path.GetDirectoryName(path), new DateTime(1, 1, 1));
                generalMock.ExistsMock = () => { return(true); };
                return(generalMock);
            };

            var codegenJob = new StubCodegenJob(OutputDirectory, mockFileSystem, new List <string>()
            {
                "TestSchema.schema"
            }, new List <string>()
            {
                "TestOutput.h", "TestOutput.cpp"
            });

            Assert.That(codegenJob.IsDirty(), "Is dirty was not true when one of the output files was missing");
        }
Ejemplo n.º 3
0
        public static void run_executes_the_expected_file_operations_when_running_an_unrealcommandjob()
        {
            var mockFileSystem = GenerateMockFileSystem();

            mockFileSystem.GetFileInfoMock = (path) =>
            {
                var file = new MockFileWrapper(path, Path.GetDirectoryName(path), new DateTime(1, 1, 1));
                file.ExistsMock = () => { return(false); };
                return(file);
            };
            mockFileSystem.GetFilesInDirectoryMock = (path, searchpattern, recursive) => { return(new List <IFile>()); };

            var unrealPackageDetails  = new UnrealPackageDetails("improbable.codegen.TestComponent", TestSchemaPath, "improbable.codegen");
            var responseTypeReference = new UnrealBuiltInTypeReference(GenerateTypeReferenceRaw());
            var requestTypeReference  = new UnrealBuiltInTypeReference(GenerateTypeReferenceRaw());
            var unrealCommandDetails  = new UnrealCommandDetails(GenerateCommandDefinition(), "TestCommand", "improbable.codegen.TestComponent", "TestComponent", requestTypeReference, responseTypeReference, unrealPackageDetails);
            var commandJob            = new UnrealCommandJob(unrealCommandDetails, Path.Combine("OutputDir", "test"), mockFileSystem);

            var jobRunner = new JobRunner(mockFileSystem);

            jobRunner.Run(new List <ICodegenJob>()
            {
                commandJob
            }, new List <string>()
            {
                OutputDirectory
            });

            Assert.That(mockFileSystem.DirectoryExistsCallCount == 2);
            Assert.That(mockFileSystem.WriteToFileCallCount == 2);
            Assert.That(mockFileSystem.WrittenFiles.Count == 2);
            Assert.That(mockFileSystem.WrittenFiles.Contains(Path.Combine(OutputDirectory, "TestCommandCommandResponder.h")));
            Assert.That(mockFileSystem.WrittenFiles.Contains(Path.Combine(OutputDirectory, "TestCommandCommandResponder.cpp")));
        }
Ejemplo n.º 4
0
        public static void run_executes_the_expected_file_operations_when_running_an_unrealcallbackdispatcherjob()
        {
            var mockFileSystem = GenerateMockFileSystem();

            mockFileSystem.GetFileInfoMock = (path) =>
            {
                var file = new MockFileWrapper(path, Path.GetDirectoryName(path), new DateTime(1, 1, 1));
                file.ExistsMock = () => { return(false); };
                return(file);
            };
            mockFileSystem.GetFilesInDirectoryMock = (path, searchpattern, recursive) => { return(new List <IFile>()); };

            var unrealPackageDetails   = new UnrealPackageDetails("improbable.codegen.TestComponent", "improbable\\codegen\\Test.schema", "improbable.codegen");
            var unrealComponentDetails = new UnrealComponentDetails(GenerateComponentDefinition(), "TestComponent", null, null, null, unrealPackageDetails);
            var callbackDispatcherJob  = new UnrealCallbackDispatcherJob(new List <UnrealComponentDetails> {
                unrealComponentDetails
            }, new HashSet <string>(), Path.Combine("OutputDir", "test"), mockFileSystem);

            var jobRunner = new JobRunner(mockFileSystem);

            jobRunner.Run(new List <ICodegenJob>()
            {
                callbackDispatcherJob
            }, new List <string>()
            {
                OutputDirectory
            });

            Assert.That(mockFileSystem.DirectoryExistsCallCount == 2);
            Assert.That(mockFileSystem.WriteToFileCallCount == 2);
            Assert.That(mockFileSystem.WrittenFiles.Count == 2);
            Assert.That(mockFileSystem.WrittenFiles.Contains(Path.Combine(Path.Combine("OutputDir", "test"), "CallbackDispatcher.h")));
            Assert.That(mockFileSystem.WrittenFiles.Contains(Path.Combine(Path.Combine("OutputDir", "test"), "CallbackDispatcher.cpp")));
        }
Ejemplo n.º 5
0
        public static void run_executes_the_expected_file_operations_when_running_an_unrealenumjob()
        {
            var mockFileSystem = GenerateMockFileSystem();

            mockFileSystem.GetFileInfoMock = (path) =>
            {
                var file = new MockFileWrapper(path, Path.GetDirectoryName(path), new DateTime(1, 1, 1));
                file.ExistsMock = () => { return(false); };
                return(file);
            };
            mockFileSystem.GetFilesInDirectoryMock = (path, searchpattern, recursive) => { return(new List <IFile>()); };

            var unrealPackageDetails = new UnrealPackageDetails("improbable.codegen.TestComponent", TestSchemaPath, "improbable.codegen");
            var unrealEnumDetails    = new UnrealEnumDetails(GenerateEnumDefinition(), "TestEnum", unrealPackageDetails);
            var enumJob = new UnrealEnumJob(unrealEnumDetails, OutputDirectory, mockFileSystem);

            var jobRunner = new JobRunner(mockFileSystem);

            jobRunner.Run(new List <ICodegenJob>()
            {
                enumJob
            }, new List <string>()
            {
                OutputDirectory
            });

            Assert.That(mockFileSystem.DirectoryExistsCallCount == 1);
            Assert.That(mockFileSystem.WriteToFileCallCount == 1);
            Assert.That(mockFileSystem.WrittenFiles.Count == 1);
            Assert.That(mockFileSystem.WrittenFiles.Contains(Path.Combine(OutputDirectory, "TestEnum.h")));
        }
Ejemplo n.º 6
0
        public static void is_dirty_returns_false_if_any_of_the_output_files_is_newer_than_the_latest_schema()
        {
            var mockFileSystem = GenerateMockFileSystem();

            mockFileSystem.GetFileInfoMock = (path) =>
            {
                var fileName = Path.GetFileName(path);
                if (fileName == "TestSchema.schema")
                {
                    var schemaMock = new MockFileWrapper(path, Path.GetDirectoryName(path), new DateTime(1, 1, 1));
                    schemaMock.ExistsMock = () => { return(true); };
                    return(schemaMock);
                }

                var generalMock = new MockFileWrapper(path, Path.GetDirectoryName(path), new DateTime(1, 1, 2));
                generalMock.ExistsMock = () => { return(true); };
                return(generalMock);
            };

            var codegenJob = new StubCodegenJob(OutputDirectory, mockFileSystem, new List <string>()
            {
                "TestSchema.schema"
            }, new List <string>()
            {
                "TestOutput.h", "TestOutput.cpp"
            });

            Assert.That(codegenJob.IsDirty() == false, "Is dirty was true when latest schema was older than newest output file");
        }
Ejemplo n.º 7
0
        public static void run_writes_the_expected_output_files_to_disk()
        {
            var fileSystem = GenerateMockFileSystem();

            fileSystem.GetFileInfoMock = (path) =>
            {
                var fileWrapper = new MockFileWrapper(path, Path.GetDirectoryName(path), new DateTime(1, 1, 1));
                fileWrapper.ExistsMock = () => { return(true); };
                fileWrapper.DeleteMock = () => { };
                return(fileWrapper);
            };

            var schemaFileRaw = TestUtils.GetRawJsonDataFromResource <SchemaFileRaw>("Improbable.CodeGeneration.Resources.json.test.command.json");

            var schemaFileProcessor = new UnrealSchemaProcessor(new List <SchemaFileRaw>()
            {
                schemaFileRaw
            });
            var job = new UnrealCommanderJob(schemaFileProcessor.unrealCommandDetails, new HashSet <string>(), outputDir, fileSystem);

            job.Run();

            Assert.That(fileSystem.WrittenFiles.Count == 2, "UnrealCommanderJob did not write the expected number of files");

            var fullOutputDir = Path.Combine("Codegen", "Test");

            Assert.That(fileSystem.WrittenFiles.Contains(Path.Combine(fullOutputDir, "Commander.h")), "UnrealCommanderJob did not write the expected files");
            Assert.That(fileSystem.WrittenFiles.Contains(Path.Combine(fullOutputDir, "Commander.cpp")), "UnrealCommanderJob did not write the expected files");
        }
Ejemplo n.º 8
0
        public void SimulateFileWriting_CheckResult()
        {
            var m       = new Mock <IGetFile>();
            var wrapper = new MockFileWrapper();

            m.Setup((x) => x.GetFile(It.IsAny <string>())).Returns(wrapper);

            AutoCurrentFileList autoCurrentFileList = new AutoCurrentFileList(_settingsFileWatcher, _settingsAutoCurrentFileList, m.Object);


            Action <object, WatcherCallbackArgs> actionFileChanges = null;
            Action <object> actionScanning = null;

            void FilterCallback(FilterAndCallbackArgument callback)
            {
                actionFileChanges = callback.ActionChanges;
                actionScanning    = callback.ActionScanning;
            }

            var mwatcher = new Mock <IFileSystemWatcher>();

            mwatcher.Setup((x) => x.Open(It.IsAny <FilterAndCallbackArgument>())).Callback((Action <FilterAndCallbackArgument>)FilterCallback).Returns(true);

            autoCurrentFileList.Start(mwatcher.Object);
            string         mustBeThis   = "must be this";
            string         lastOutput   = String.Empty;
            string         lastFileName = String.Empty;
            AutoResetEvent waitForInput = new AutoResetEvent(false);
            var            task         = autoCurrentFileList.BlockingReadAsyncNewOutput((output, token) =>
            {
                lastOutput   = output.Lines;
                lastFileName = output.FileName;
                waitForInput.Set();
            });

            wrapper.CurrentOutput = mustBeThis;
            actionFileChanges(null, new WatcherCallbackArgs("file1.txt", IFileSystemWatcherChangeType.Changed));
            Assert.True(waitForInput.WaitOne(100));
            Assert.True(lastOutput == mustBeThis);
            Assert.True(lastFileName == "file1.txt");

            string mustBeThis2 = "### !CHANGED! öäüÖÄÜ ###";

            wrapper.CurrentOutput = mustBeThis2;
            actionFileChanges(null, new WatcherCallbackArgs("file2.txt", IFileSystemWatcherChangeType.Changed));
            Assert.True(waitForInput.WaitOne(100));
            Assert.True(lastOutput == mustBeThis2);
            Assert.True(lastFileName == "file2.txt");
        }
Ejemplo n.º 9
0
        public static void clean_removes_empty_folders_in_output_directory_if_they_are_empty()
        {
            var mockFileSystem = GenerateMockFileSystem();

            mockFileSystem.GetFileInfoMock = (path) =>
            {
                var generalMock = new MockFileWrapper(path, Path.GetDirectoryName(path), new DateTime(1, 1, 1));
                generalMock.ExistsMock = () => { return(true); };
                generalMock.DeleteMock = () => { };
                return(generalMock);
            };

            var remainingFileCount = 2;

            mockFileSystem.GetFilesInDirectoryMock = (path, searchpattern, recursive) =>
            {
                remainingFileCount--;

                if (remainingFileCount > 0)
                {
                    return(new List <IFile>()
                    {
                        new MockFileWrapper("filetodelete", "filetodelete", new DateTime(1, 1, 1))
                    });
                }

                return(new List <IFile>());
            };
            var deletedDirectory = string.Empty;

            mockFileSystem.DeleteDirectoryMock = (path) => { deletedDirectory = path; };

            var codegenJob = new StubCodegenJob(OutputDirectory, mockFileSystem, new List <string>()
            {
                "TestSchema.schema"
            }, new List <string>()
            {
                Path.Combine("FolderToDelete", "TestOutput.h"), Path.Combine("FolderToDelete", "TestOutput.cpp")
            });

            codegenJob.Clean();

            Assert.That(mockFileSystem.GetFilesInDirectoryCallCount == 2);
            Assert.That(mockFileSystem.DeleteDirectoryCallCount == 1);
            Assert.That(deletedDirectory == Path.Combine(OutputDirectory, "FolderToDelete"));
        }
Ejemplo n.º 10
0
        public static void run_does_not_clean_output_folders_of_jobs_if_the_output_folder_contains_the_files_to_be_generated()
        {
            var mockFileSystem = GenerateMockFileSystem();

            mockFileSystem.GetFilesInDirectoryMock = (path, searchpatter, recursive) =>
            {
                return(new List <IFile>()
                {
                    new MockFileWrapper(Path.Combine(path, "TestType.h"), path, new DateTime(1, 1, 1)),
                    new MockFileWrapper(Path.Combine(path, "TestType.cpp"), path, new DateTime(1, 1, 1))
                });
            };

            mockFileSystem.GetFileInfoMock = (path) =>
            {
                var fileMock = new MockFileWrapper(path, Path.GetDirectoryName(path), new DateTime(1, 1, 1));
                fileMock.ExistsMock = () => { return(true); };
                return(fileMock);
            };

            var unrealPackageDetails   = new UnrealPackageDetails("improbable.codegen.TestComponent", TestSchemaPath, "improbable.codegen");
            var cleanUnrealTypeDetails = new UnrealTypeDetails(GenerateTypeDefinition("TestType", "improbable.codegen.TestType"), "TestType", new List <UnrealFieldDetails>(), unrealPackageDetails);
            var cleanTypeJob           = new UnrealTypeJob(cleanUnrealTypeDetails, new HashSet <string>(), new HashSet <string>(), new HashSet <string>(), OutputDirectory, mockFileSystem);

            var jobRunner = new JobRunner(mockFileSystem);

            jobRunner.Run(new List <ICodegenJob>()
            {
                cleanTypeJob
            }, new List <string>()
            {
                OutputDirectory
            });


            //This validates that the output folder was not deleted
            Assert.That(mockFileSystem.DeleteDirectoryCallCount == 0);
            Assert.That(mockFileSystem.GetFilesInDirectoryCallCount == 1);

            //This validates that no codegen jobs were run as they were expected to not be dirty.
            Assert.That(mockFileSystem.WriteToFileCallCount == 0);
            Assert.That(mockFileSystem.DirectoryExistsCallCount == 0);
            Assert.That(mockFileSystem.DirectoryExistsCallCount == 0);
            Assert.That(mockFileSystem.WriteToFileCallCount == 0);
            Assert.That(cleanTypeJob.IsDirty() == false);
        }
Ejemplo n.º 11
0
        public static void clean_removes_the_expected_files()
        {
            var fileSystem      = GenerateMockFileSystem();
            var fileWrapperList = new List <MockFileWrapper>();

            fileSystem.GetFileInfoMock = (path) =>
            {
                var fileWrapper = new MockFileWrapper(path, Path.GetDirectoryName(path), new DateTime(1, 1, 1));
                fileWrapper.ExistsMock = () => { return(true); };
                fileWrapper.DeleteMock = () => { };
                fileWrapperList.Add(fileWrapper);
                return(fileWrapper);
            };

            fileSystem.GetFilesInDirectoryMock = (path, searchpattern, recursive) => { return(new List <IFile>()
                {
                    new MockFileWrapper(path, Path.GetDirectoryName(path), new DateTime(1, 1, 1))
                }); };

            var schemaFileRaw = TestUtils.GetRawJsonDataFromResource <SchemaFileRaw>("Improbable.CodeGeneration.Resources.json.test.enum.json");

            var schemaFileProcessor = new UnrealSchemaProcessor(new List <SchemaFileRaw>()
            {
                schemaFileRaw
            });
            var job = new UnrealComponentJob(schemaFileProcessor.unrealComponentDetails.First(), outputDir, fileSystem);

            job.Clean();

            Assert.That(fileWrapperList.Count == 5, "clean did not scan for the expected files to be deleted");

            foreach (var fileWrapper in fileWrapperList)
            {
                Assert.That(fileWrapper.DeleteCallCount == 1, "Did not call Delete the expected number of times for a filewrapper");
                Assert.That(fileWrapper.ExistsCallCount == 1, "Did not call Exists the expected number of times for a filewrapper");
            }

            var fullOutputDir = Path.Combine("Codegen", "Test");

            Assert.That(fileWrapperList.Exists((fileWrapper) => fileWrapper.CompletePath == Path.Combine(fullOutputDir, "ExampleEnumComponentComponent.h")));
            Assert.That(fileWrapperList.Exists((fileWrapper) => fileWrapper.CompletePath == Path.Combine(fullOutputDir, "ExampleEnumComponentComponent.cpp")));
            Assert.That(fileWrapperList.Exists((fileWrapper) => fileWrapper.CompletePath == Path.Combine(fullOutputDir, "ExampleEnumComponentComponentUpdate.h")));
            Assert.That(fileWrapperList.Exists((fileWrapper) => fileWrapper.CompletePath == Path.Combine(fullOutputDir, "ExampleEnumComponentComponentUpdate.cpp")));
            Assert.That(fileWrapperList.Exists((fileWrapper) => fileWrapper.CompletePath == Path.Combine(fullOutputDir, "ExampleEnumComponentAddComponentOp.h")));
        }
Ejemplo n.º 12
0
        public static void is_dirty_returns_true_if_there_are_no_files_in_output_folder()
        {
            var mockFileSystem = GenerateMockFileSystem();

            mockFileSystem.GetFileInfoMock = (path) =>
            {
                var generalMock = new MockFileWrapper(path, Path.GetDirectoryName(path), new DateTime(1, 1, 1));
                generalMock.ExistsMock = () => { return(true); };
                return(generalMock);
            };

            var codegenJob = new StubCodegenJob(OutputDirectory, mockFileSystem, new List <string>()
            {
                "TestSchema.schema"
            }, new List <string>());

            Assert.That(codegenJob.IsDirty(), "Is dirty was not true when output files directory was empty");
        }
Ejemplo n.º 13
0
        public static void run_creates_the_output_directory_if_it_does_not_exist()
        {
            var mockFileSystem = GenerateMockFileSystem();

            mockFileSystem.GetFileInfoMock = (path) =>
            {
                var generalMock = new MockFileWrapper(path, Path.GetDirectoryName(path), new DateTime(1, 1, 1));
                generalMock.ExistsMock = () => { return(true); };
                return(generalMock);
            };
            var directoryCreated = false;
            var createdDirectory = string.Empty;

            mockFileSystem.CreateDirectoryMock = (path) =>
            {
                directoryCreated = true;
                createdDirectory = path;
            };
            mockFileSystem.DirectoryExistsMock = (path) =>
            {
                if (directoryCreated)
                {
                    return(true);
                }

                return(false);
            };

            var codegenJob = new StubCodegenJob(OutputDirectory, mockFileSystem, new List <string>()
            {
                "TestSchema.schema"
            }, new List <string>()
            {
                Path.Combine("CreatedDir", "TestOutput.h"), Path.Combine("CreatedDir", "TestOutput.cpp")
            });

            codegenJob.Run();

            Assert.That(mockFileSystem.DirectoryExistsCallCount == 2);
            Assert.That(mockFileSystem.CreateDirectoryCallCount == 1);
            Assert.That(createdDirectory == Path.Combine(OutputDirectory, "CreatedDir"));
        }
Ejemplo n.º 14
0
        public static void clean_deletes_the_expected_files_on_disk()
        {
            var mockFileSystem   = GenerateMockFileSystem();
            var mockFileWrappers = new List <MockFileWrapper>();

            mockFileSystem.GetFileInfoMock = (path) =>
            {
                var generalMock = new MockFileWrapper(path, Path.GetDirectoryName(path), new DateTime(1, 1, 1));
                generalMock.ExistsMock = () => { return(true); };
                generalMock.DeleteMock = () => { };
                mockFileWrappers.Add(generalMock);
                return(generalMock);
            };
            mockFileSystem.GetFilesInDirectoryMock = (path, searchpattern, recursive) => { return(new List <IFile>()
                {
                    new MockFileWrapper(path, Path.GetDirectoryName(path), new DateTime(1, 1, 1))
                }); };

            var codegenJob = new StubCodegenJob(OutputDirectory, mockFileSystem, new List <string>()
            {
                "TestSchema.schema"
            }, new List <string>()
            {
                "TestOutput.h", "TestOutput.cpp"
            });

            codegenJob.Clean();

            Assert.That(mockFileWrappers.Count == 2);

            Assert.That(mockFileWrappers.Any(file => file.CompletePath == Path.Combine(OutputDirectory, "TestOutput.h")));
            Assert.That(mockFileWrappers.Any(file => file.CompletePath == Path.Combine(OutputDirectory, "TestOutput.cpp")));

            foreach (var fileMock in mockFileWrappers)
            {
                Assert.That(fileMock.ExistsCallCount == 1);
                Assert.That(fileMock.DeleteCallCount == 1);
            }
        }
Ejemplo n.º 15
0
        public void run_does_clean_if_files_are_present_in_output_folder_that_should_not_be_there()
        {
            var mockFileSystem = GenerateMockFileSystem();

            mockFileSystem.GetFilesInDirectoryMock = (path, searchpatter, recursive) =>
            {
                return(new List <IFile>()
                {
                    new MockFileWrapper(Path.Combine(path, "TestType.h"), path, new DateTime(1, 1, 1)),
                    new MockFileWrapper(Path.Combine(path, "TestType.cpp"), path, new DateTime(1, 1, 1)),
                    new MockFileWrapper(Path.Combine(path, "Invalid.cpp"), path, new DateTime(1, 1, 1)),
                });
            };
            mockFileSystem.DeleteDirectoryMock = (path) => { };
            mockFileSystem.GetFileInfoMock     = (path) =>
            {
                var fileMock = new MockFileWrapper(path, Path.GetDirectoryName(path), new DateTime(1, 1, 1));

                bool fileExists = false;
                var  fileName   = Path.GetFileName(path);
                if (fileName == "TestType.h" || fileName == "TestType.cpp" || fileName == "Invalid.cpp")
                {
                    fileExists = true;
                }

                fileMock.ExistsMock = () => { return(fileExists); };
                return(fileMock);
            };

            var unrealPackageDetails = new UnrealPackageDetails("improbable.codegen.TestComponent", TestSchemaPath, "improbable.codegen");

            var cleanUnrealTypeDetails = new UnrealTypeDetails(GenerateTypeDefinition("TestType", "improbable.codegen.TestType"), "TestType", new List <UnrealFieldDetails>(), unrealPackageDetails);
            var cleanTypeJob           = new UnrealTypeJob(cleanUnrealTypeDetails, new HashSet <string>(), new HashSet <string>(), new HashSet <string>(), OutputDirectory, mockFileSystem);

            var dirtyUnrealTypeDetails = new UnrealTypeDetails(GenerateTypeDefinition("DirtyTestType", "improbable.codegen.DirtyTestType"), "DirtyTestType", new List <UnrealFieldDetails>(), unrealPackageDetails);
            var dirtyTypeJob           = new UnrealTypeJob(dirtyUnrealTypeDetails, new HashSet <string>(), new HashSet <string>(), new HashSet <string>(), OutputDirectory, mockFileSystem);

            var jobRunner = new JobRunner(mockFileSystem);

            jobRunner.Run(new List <ICodegenJob>()
            {
                cleanTypeJob, dirtyTypeJob
            }, new List <string>()
            {
                OutputDirectory
            });

            //Validate that the folder check was correct
            Assert.That(mockFileSystem.DeleteDirectoryCallCount == 1);
            Assert.That(mockFileSystem.GetFilesInDirectoryCallCount == 1);

            //Validate that the correct jobs were run and expected files were written
            Assert.That(mockFileSystem.GetFileInfoCallCount == 4);
            Assert.That(mockFileSystem.DirectoryExistsCallCount == 4);
            Assert.That(mockFileSystem.WriteToFileCallCount == 4);
            Assert.That(mockFileSystem.WrittenFiles.Count == 4);
            Assert.That(mockFileSystem.WrittenFiles.Contains(Path.Combine(OutputDirectory, "TestType.h")));
            Assert.That(mockFileSystem.WrittenFiles.Contains(Path.Combine(OutputDirectory, "TestType.cpp")));
            Assert.That(mockFileSystem.WrittenFiles.Contains(Path.Combine(OutputDirectory, "DirtyTestType.h")));
            Assert.That(mockFileSystem.WrittenFiles.Contains(Path.Combine(OutputDirectory, "DirtyTestType.cpp")));

            Assert.That(cleanTypeJob.IsDirty());
            Assert.That(dirtyTypeJob.IsDirty());
        }
Ejemplo n.º 16
0
 public FileLoggerTest()
 {
     _mockWrapper = new MockFileWrapper();
     _mockLogic   = new MockFileLogic();
 }
Ejemplo n.º 17
0
 public FileLogicTests()
 {
     _mockWrapper = new MockFileWrapper();
 }