public void Execute_OnNonExpectedExceptionThrown_ShouldThrowThatException() { // ARRANGE // Arranging: When FooStatic.ExecuteStatic() is called, it should throw NotImplementedException. Mock.Arrange(() => FooStatic.ExecuteStatic()).Throws <NotImplementedException>(); // ACT var foo = new Foo(); foo.Execute(); }
public void Execute() { try { FooStatic.ExecuteStatic(); } catch (UnauthorizedAccessException) { logger.Append("Unauthorized Access !!!"); } catch (StackOverflowException ex) { logger.AppendLine("Stack Overflow Detected !!!").AppendLine(ex.Message); } }
public void Execute_OnUnauthorizedAccessExceptionThrown_ShouldGiveProperMessage() { var expected = "Unauthorized Access !!!"; // ARRANGE // Arranging: When FooStatic.ExecuteStatic() is called, it should throw UnauthorizedAccessException. Mock.Arrange(() => FooStatic.ExecuteStatic()).Throws <UnauthorizedAccessException>(); // ACT var foo = new Foo(); foo.Execute(); var actual = foo.logger.ToString(); // ASSERT Assert.AreEqual(expected, actual); }
public void Execute_OnStackOverflowExceptionThrown_ShouldGiveProperMessage() { // We compare culture-dependant strings var expected = "Stack Overflow Detected !!!\r\n" + new StackOverflowException().Message + "\r\n"; // ARRANGE // Arranging: When FooStatic.ExecuteStatic() is called, it should throw StackOverflowException. Mock.Arrange(() => FooStatic.ExecuteStatic()).Throws <StackOverflowException>(); // ACT var foo = new Foo(); foo.Execute(); var actual = foo.logger.ToString(); // ASSERT Assert.AreEqual(expected, actual); }