public void Get_ShouldPass_UnexpectedException() { // Arrange _origin.When(x => x.Get()).Do(_ => throw new Exception()); ((IThrowsExpectedExceptions)_origin).IsExpectedException(Arg.Any <Exception>()).Returns(false); var storage = new SafeStorage <string>(_origin); // Act Action action = () => storage.Get(); // Assert action.Should().Throw <Exception>(); }
public void Get_ShouldBe_OriginGet() { // Arrange const string expected = "John Doe"; _origin.Get().Returns(expected); var storage = new SafeStorage <string>(_origin); // Act var result = storage.Get(); // Assert result.Should().Be(expected); }
public void Get_ShouldBeNull_WhenOriginThrows_ExpectedException() { // Arrange var exception = new Exception(); _origin.When(x => x.Get()).Do(_ => throw exception); ((IThrowsExpectedExceptions)_origin).IsExpectedException(exception).Returns(true); var storage = new SafeStorage <string>(_origin); // Act var result = storage.Get(); // Assert result.Should().BeNull(); }