public void then_expected_message_written() { SutMock.Verify(f => f.AppendFallbackFile( It.Is <string>(msg => msg.EndsWith("| ERROR | message")), It.IsAny <string>()), Times.Once()); }
public void then_exceptions_are_written_to_file() { SutMock.Verify(logger => logger.AppendFallbackFile( It.Is <string>(msg => msg.Contains("exception1") && msg.Contains("exception2")), It.IsAny <string>()), Times.Once()); }
public void then_expected_message_written() { string expectedMessage = $@"| ERROR | message{Environment.NewLine}exception"; SutMock.Verify(logger => logger.AppendFallbackFile(It.Is <string>(msg => msg.EndsWith(expectedMessage)), It.IsAny <string>()), Times.Once()); }
public void and_input_directory_is_valid_then(string inputDirectory, string expectedResultDirectory) { InitSut(inputDirectory); SutMock.Object.Write("message"); SutMock.Verify(l => l.AppendFallbackFile(It.IsAny <string>(), It.Is <string>(path => Path.GetDirectoryName(path) == expectedResultDirectory)), Times.Once); }
public void then_delete_call_happens_as_expected(int shiftBackFromToday, bool deleteCalled) { _shiftBackFromToday = shiftBackFromToday; Act(); var times = deleteCalled ? Times.Exactly(FileCount) : Times.Never(); SutMock.Verify(d => d.DeleteFile(It.IsAny <FileInfo>()), times); }
public void then_with_constant_failure_only_three_attempts_made() { for (int i = 0; i < 300; i++) { SutMock.Object.Write("failing_message"); } SutMock.Verify(l => l.AppendFallbackFile(It.IsAny <string>(), It.IsAny <string>()), Times.Exactly(100)); }
public void then_proper_error_logged(string message) { Write(message); SutMock.Verify(f => f.AppendFallbackFile( It.Is <string>(msg => msg.EndsWith("| ERROR | " + message)), It.IsAny <string>()), Times.Once()); }
public void then_environment_variable_is_resolved() { Environment.SetEnvironmentVariable("fallback_root", @"C:\GIT"); InitSut(@"%fallback_root%\dir"); SutMock.Object.Write("message"); SutMock.Verify(l => l.AppendFallbackFile(It.IsAny <string>(), It.Is <string>(path => Path.GetDirectoryName(path) == @"C:\GIT\dir")), Times.Once); }
public void then_with_every_third_successful_message_all_attempts_are_made() { for (int i = 0; i < 100; i++) { SutMock.Setup(l => l.AppendFallbackFile(It.IsAny <string>(), It.IsAny <string>())).Throws <FileNotFoundException>(); SutMock.Object.Write("failing_message"); SutMock.Object.Write("failing_message"); SutMock.Setup(l => l.AppendFallbackFile(It.IsAny <string>(), It.IsAny <string>())); SutMock.Object.Write("success_message"); } SutMock.Verify(l => l.AppendFallbackFile(It.IsAny <string>(), It.IsAny <string>()), Times.Exactly(300)); }
public void then_no_files_deleted() { SutMock.Verify(d => d.DeleteFile(It.IsAny <FileInfo>()), Times.Never); }
public void then_delete_is_called_2_times_not_4() { SutMock.Verify(del => del.DeleteFile(It.IsAny <FileInfo>()), Times.Exactly(2)); }
public override void Arrange() { base.Arrange(); SutMock.Setup(l => l.AppendFallbackFile(It.IsAny <string>(), It.IsAny <string>())).Throws <FileNotFoundException>(); }
public void and_input_directory_is_invalid_then(string inputDirectory) { InitSut(inputDirectory); SutMock.Object.Write("message"); SutMock.Verify(l => l.AppendFallbackFile(It.IsAny <string>(), It.IsAny <string>()), Times.Never); }
public void then_second_old_file_deleted() { SutMock.Verify(del => del.DeleteFile(OldFile2), Times.Once); }
public void then_first_old_file_deleted() { SutMock.Verify(del => del.DeleteFile(OldFile1), Times.Once); }
public void then_2_files_deleted() { SutMock.Verify(del => del.DeleteFile(It.IsAny <FileInfo>()), Times.Exactly(2)); }
public void then_directory_is_ensured_to_exist() { SutMock.Verify(f => f.EnsureDirectoryExists(), Times.Once); }