public async void GetSymptomDisciminator_should_return_a_symptomDiscrimnator_by_id_before_adding_to_cache() { //Arrange var id = 1; var symptomDiscriminator = new SymptomDiscriminator() { Id = id, Description = "A description", ReasoningText = "Some reasoning" }; var response = new Mock <IRestResponse <SymptomDiscriminator> >(); response.Setup(x => x.IsSuccessful).Returns(true); response.Setup(x => x.Data).Returns(symptomDiscriminator); var expectedCacheKey = new SymptomDiscriminatorCacheKey(id.ToString()); _cacheManagerMock.Setup(x => x.Read(It.IsAny <string>())).ReturnsAsync(string.Empty); _restClient.Setup(x => x.ExecuteAsync <SymptomDiscriminator>(It.IsAny <IRestRequest>())) .ReturnsAsync(response.Object); var sut = new SymptomDisciminatorService(_configuration.Object, _restClient.Object, _cacheStoreMock); //Act var result = await sut.GetSymptomDisciminator(id.ToString()); //Assert _cacheManagerMock.Verify(x => x.Set(expectedCacheKey.CacheKey, It.IsAny <string>()), Times.Once); _configuration.Verify(x => x.GetDomainApiSymptomDisciminatorUrl(id.ToString()), Times.Once); _restClient.Verify(x => x.ExecuteAsync <SymptomDiscriminator>(It.IsAny <IRestRequest>()), Times.Once); Assert.AreEqual(result.Id, id); }
public async void GetSymptomDisciminator_should_return_a_symptomDiscrimnator_by_id() { //Arrange var url = "http://mytest.com/"; var id = 1; var symptomDiscriminator = new SymptomDiscriminator() { Id = id, Description = "A description", ReasoningText = "Some reasoning" }; var response = new Mock <IRestResponse <SymptomDiscriminator> >(); response.Setup(x => x.IsSuccessful).Returns(true); response.Setup(x => x.Data).Returns(symptomDiscriminator); _configuration.Setup(x => x.GetDomainApiSymptomDisciminatorUrl(id.ToString())).Returns(url); _restClient.Setup(x => x.ExecuteAsync <SymptomDiscriminator>(It.IsAny <IRestRequest>())) .ReturnsAsync(response.Object); var sut = new SymptomDisciminatorService(_configuration.Object, _restClient.Object, _cacheStoreMock); //Act var result = await sut.GetSymptomDisciminator(id.ToString()); //Assert _configuration.Verify(x => x.GetDomainApiSymptomDisciminatorUrl(id.ToString()), Times.Once); _restClient.Verify(x => x.ExecuteAsync <SymptomDiscriminator>(It.IsAny <IRestRequest>()), Times.Once); Assert.AreEqual(result.Id, id); }