Exemplo n.º 1
0
        public async Task AllActionShouldReturnCorrectActionResult()
        {
            var fakeResponseHandler = new FakeResponseHandler();

            fakeResponseHandler.AddFakeResponse(new Uri("https://localhost:44365/api/customers?pageSize=10&page=1"), await GetTestHttpClientResponseMessage());

            var httpClient = new HttpClient(fakeResponseHandler);
            var controller = new CustomersController(httpClient);

            var result = await controller.Index();

            Assert.IsType <ViewResult>(result);
        }
Exemplo n.º 2
0
        public async Task AllApiActionShouldReturnCorrectCustomersCount()
        {
            var fakeResponseHandler = new FakeResponseHandler();

            fakeResponseHandler.AddFakeResponse(new Uri("https://localhost:44365/api/customers?pageSize=10&page=1"), await GetTestHttpClientResponseMessage());

            var httpClient = new HttpClient(fakeResponseHandler);
            var controller = new CustomersController(httpClient);

            var result = await controller.Index();

            var viewResult = Assert.IsType <ViewResult>(result);

            var model = Assert.IsAssignableFrom <CustomersViewModel>(viewResult.Model);

            Assert.Equal(2, model.Customers.Count());
        }