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"); }
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"); }
public static void markasdirty_turns_the_job_into_dirty_state() { var mockFileSystem = GenerateMockFileSystem(); var codegenJob = new StubCodegenJob(OutputDirectory, mockFileSystem, new List <string>() { "TestSchema.schema" }, new List <string>() { "TestOutput.h", "TestOutput.cpp" }); codegenJob.MarkAsDirty(); Assert.That(codegenJob.IsDirty(), "Is dirty was not true after being marked as true"); }
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"); }