public void Test_GetEuroToRuble() { var url = _fixture.Create <string>(); var expected = _fixture.Create <decimal>(); _courseSource.Setup(x => x.GetEuroToRuble(url)).Returns(expected); var policy = new CourseSourceRetryPolicy(_courseSource.Object, 2, _log.Object, TimeSpan.FromMilliseconds(1)); var actual = policy.GetEuroToRuble(url); actual.ShouldBeEquivalentTo(expected); _courseSource.Verify(x => x.GetEuroToRuble(url), Times.Once); }
public void Test_OneAttempt() { var url = _fixture.Create <string>(); _courseSource.Setup(x => x.GetEuroToRuble(url)).Throws(new TestException()); var policy = new CourseSourceRetryPolicy(_courseSource.Object, 1, _log.Object, TimeSpan.FromMilliseconds(1)); try { policy.GetEuroToRuble(url); } catch (TestException) { _courseSource.Verify(x => x.GetEuroToRuble(url), Times.Once); throw; } }