Beispiel #1
0
        public async Task GetAllAsyncTest()
        {
            //Arrange
            var service = new Mock <IUserService>();
            var users   = UserGenerator.GetTestUsers();

            service.Setup(e => e.ListAsync()).ReturnsAsync(users);

            var controller = new UsersController(service.Object, _mapper);

            //Act
            var result = await controller.GetAllAsync();

            //Assert
            var actionResult  = Assert.IsType <List <UserResource> >(result);
            var userResources = Assert.IsAssignableFrom <List <UserResource> >(actionResult);

            AssertHelperBase.AssertEqualLists(users, actionResult, UserAssertHelper.AssertEquals);
            Assert.Equal(3, userResources.Count());
        }
Beispiel #2
0
        public async Task GetAllAsyncTest()
        {
            //Arrange
            var service  = new Mock <IProductService>();
            var products = ProductGenerator.GetTestProducts();

            service.Setup(e => e.ListAsync()).ReturnsAsync(products);

            var controller = new ProductsController(service.Object, _mapper);

            //Act
            var result = await controller.GetAllAsync();

            //Assert
            var actionResult     = Assert.IsType <List <ProductResource> >(result);
            var productResources = Assert.IsAssignableFrom <List <ProductResource> >(actionResult);

            AssertHelperBase.AssertEqualLists(products, actionResult, ProductAssertHelper.AssertEquals);
            Assert.Equal(3, productResources.Count());
        }