Пример #1
0
        public async void GetPathwayMetaData_should_return_a_single_pathway_metadata_by_id_before_adding_to_cache()
        {
            //Arrange
            var id      = "PW123";
            var pathway = new PathwayMetaData()
            {
                DigitalTitle = "pathway1"
            };
            var expectedCacheKey = new PathwayMetaDataCacheKey(id);


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

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

            _cacheManagerMock.Setup(x => x.Read(It.IsAny <string>())).ReturnsAsync(string.Empty);
            _restClient.Setup(x => x.ExecuteAsync <PathwayMetaData>(It.IsAny <IRestRequest>()))
            .ReturnsAsync(response.Object);

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

            //Act
            var result = await sut.GetPathwayMetaData(id);

            //Assert
            _cacheManagerMock.Verify(x => x.Set(expectedCacheKey.CacheKey, It.IsAny <string>()), Times.Once);
            _configuration.Verify(x => x.GetDomainApiPathwayMetadataUrl(id), Times.Once);
            _restClient.Verify(x => x.ExecuteAsync <PathwayMetaData>(It.IsAny <IRestRequest>()), Times.Once);
            Assert.AreEqual(result.DigitalTitle, "pathway1");
        }
Пример #2
0
        public async void GetPathwayMetaData_should_return_a_single_pathway_metadata_by_id()
        {
            //Arrange

            var url     = "http://mytest.com/";
            var id      = "PW123";
            var pathway = new PathwayMetaData()
            {
                DigitalTitle = "pathway1"
            };

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

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

            _configuration.Setup(x => x.GetDomainApiPathwayMetadataUrl(id)).Returns(url);
            _restClient.Setup(x => x.ExecuteAsync <PathwayMetaData>(It.IsAny <IRestRequest>()))
            .ReturnsAsync(response.Object);

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

            //Act
            var result = await sut.GetPathwayMetaData(id);

            //Assert
            _configuration.Verify(x => x.GetDomainApiPathwayMetadataUrl(id), Times.Once);
            _restClient.Verify(x => x.ExecuteAsync <PathwayMetaData>(It.IsAny <IRestRequest>()), Times.Once);
            Assert.AreEqual(result.DigitalTitle, "pathway1");
        }