Esempio n. 1
0
        public void GetTestCallScoreAsync_throws_not_found_exception()
        {
            var participantId = Guid.NewGuid();

            _fakeHttpHandler.Register
            (
                $"{_kinlySelfTestScoreEndpointUrl}/{participantId}",
                new HttpResponseMessage(HttpStatusCode.NotFound)
            );

            Assert.ThrowsAsync <NotFoundException>(() => _kinlyPlatformService.GetTestCallScoreAsync(participantId));
        }
Esempio n. 2
0
        public async Task Should_return_result_from_get_test_call_score()
        {
            var participantId          = Guid.NewGuid();
            var expectedTestCallResult = new TestCallResult(true, TestScore.Good);

            _pollyRetryService.Setup(x => x.WaitAndRetryAsync <Exception, TestCallResult>
                                     (
                                         It.IsAny <int>(), It.IsAny <Func <int, TimeSpan> >(), It.IsAny <Action <int> >(), It.IsAny <Func <TestCallResult, bool> >(), It.IsAny <Func <Task <TestCallResult> > >()
                                     ))
            .Callback(async(int retries, Func <int, TimeSpan> sleepDuration, Action <int> retryAction, Func <TestCallResult, bool> handleResultCondition, Func <Task <TestCallResult> > executeFunction) =>
            {
                sleepDuration(1);
                retryAction(1);
                handleResultCondition(expectedTestCallResult);
                await executeFunction();
            })
            .ReturnsAsync(expectedTestCallResult);

            var result = await _kinlyPlatformService.GetTestCallScoreAsync(participantId);

            result.Should().NotBeNull();
            result.Should().BeEquivalentTo(expectedTestCallResult);
        }