public async void should_return_an_identified_pathway()
        {
            //Arrange

            var url = "http://mytest.com/";

            var pathwayNo = "PW755";
            var gender    = "Male";
            var age       = 35;

            var resultString = "identified pathway";

            _configuration.Setup(x => x.GetDomainApiIdentifiedPathwayUrl(pathwayNo, gender, age)).Returns(url);
            _restfulHelper.Setup(x => x.GetAsync(url)).Returns(Task.FromResult(resultString));

            var sut = new PathwayService(_configuration.Object, _restfulHelper.Object);

            //Act
            var result = await sut.GetIdentifiedPathway(pathwayNo, gender, age);

            //Assert
            _configuration.Verify(x => x.GetDomainApiIdentifiedPathwayUrl(pathwayNo, gender, age), Times.Once);
            _restfulHelper.Verify(x => x.GetAsync(url), Times.Once);

            Assert.That(result, Is.EqualTo(resultString));
        }
Esempio n. 2
0
        public async void should_return_an_identified_pathway()
        {
            //Arrange

            var url = "http://mytest.com/";

            var pathwayNo = "PW755";
            var gender    = "Male";
            var age       = 35;
            var pathway   = new Pathway {
                Title = "identified pathway"
            };

            var response = new Mock <IRestResponse <Pathway> >();

            response.Setup(_ => _.Data).Returns(pathway);

            _configuration.Setup(x => x.GetDomainApiIdentifiedPathwayUrl(pathwayNo, gender, age)).Returns(url);
            _restClient.Setup(x => x.ExecuteAsync <Pathway>(It.IsAny <IRestRequest>()))
            .ReturnsAsync(response.Object);

            var sut = new PathwayService(_configuration.Object, _restClient.Object, _cacheStoreMock);

            //Act
            var result = await sut.GetIdentifiedPathway(pathwayNo, gender, age);

            //Assert
            _configuration.Verify(x => x.GetDomainApiIdentifiedPathwayUrl(pathwayNo, gender, age), Times.Once);
            _restClient.Verify(x => x.ExecuteAsync <Pathway>(It.IsAny <IRestRequest>()), Times.Once);
            Assert.AreEqual(result.Title, "identified pathway");
        }