public void Compare_File1CreatedBeforeFile2_ReturnsLessThanZero( ) { // Create the first file string path1 = Path.GetTempFileName( ); // Testing the comparer here, not the file system. File.SetCreationTime(path1, DateTime.Now.AddMinutes(-1)); // Create the second file string path2 = Path.GetTempFileName( ); // Initialize the file data var file1 = new FileInfo(path1); var file2 = new FileInfo(path2); // Compare the file var comparer = new FileCreationComparer( ); int result = comparer.Compare(file1, file2); // Assert that the file1 was created before file2 Assert.IsTrue(result < 0); File.Delete(path1); File.Delete(path2); }
public void Compare_File1File2CreatedSameTime_ReturnsZero( ) { // Create the file string path = Path.GetTempFileName( ); // Initialize the file data var file1 = new FileInfo(path); var file2 = new FileInfo(path); // Compare the file var comparer = new FileCreationComparer( ); int result = comparer.Compare(file1, file2); // Assert that the file1 was created at the same time as file2 Assert.IsTrue(result == 0); File.Delete(path); }