Esempio n. 1
0
        public void Test_GetCount_WhenHasDeletedRecords_CountOnlyActive()
        {
            // Arrange
            var handler = new Mock <HttpMessageHandler>();

            handler.Protected()
            .Setup <Task <HttpResponseMessage> >("SendAsync",
                                                 ItExpr.Is <HttpRequestMessage>(request =>
                                                                                request.RequestUri.ToString() == "http://baseurl.com/explore/tags/tag/?__a=1"),
                                                 ItExpr.IsAny <CancellationToken>())
            .ReturnsAsync(new HttpResponseMessage
            {
                Content = new StringContent("{posts:[{}, {IsDeleted: true}]}")
            });
            var httpClient = new HttpClient(handler.Object);

            var config = new Mock <IApiConfig>();

            config.Setup(x => x.BaseUrl).Returns("http://baseurl.com");

            var service = new PostService7(httpClient, config.Object, MapperContext.Map, new Mock <IFeatureConfig>().Object);

            // Act
            var postCount = service.GetPostsCount("tag");

            // Assert
            Assert.AreEqual(1, postCount);
        }
Esempio n. 2
0
        public void Test_GetCount_WhenHasDeletedRecords_CountOnlyActive()
        {
            var service = new PostService7(_httpClient, _config, MapperContext.Map, new Mock <IFeatureConfig>().Object);

            var postCount = service.GetPostsCount("Test_GetCount_WhenHasDeletedRecords_CountOnlyActive");

            Assert.AreEqual(1, postCount);
        }