public void Value_ShouldPass_UnexpectedException() { // Arrange _origin.When(x => x.Value()).Do(_ => throw new Exception()); var storage = new SafeConfigStorage(_origin); // Act Action action = () => storage.Value(); // Assert action.Should().Throw <Exception>(); }
public void Value_ShouldBeNull_WhenOriginThrows_ExpectedException(Type exceptionType) { // Arrange var exception = (Exception)Activator.CreateInstance(exceptionType); _origin.When(x => x.Value()).Do(_ => throw exception); var storage = new SafeConfigStorage(_origin); // Act var result = storage.Value(); // Assert result.Should().BeNull(); }
public void Value_ShouldBe_OriginValue() { // Arrange var expected = new Config(); _origin.Value().Returns(expected); var storage = new SafeConfigStorage(_origin); // Act var value = storage.Value(); // Assert value.Should().Be(expected); }