コード例 #1
0
        public void GetUsersUnitTest_NullResponse()
        {
            List <DataAccess.Models.User> mockedData = CommonHelper.GetMockedUsersOfDB();

            webApiRepo.Setup(repo => repo.GetUsers()).Returns((List <DataAccess.Models.User>)null);

            WebApiBusiness webApiBusiness = new WebApiBusiness(webApiRepo.Object, mapper);
            var            result         = webApiBusiness.GetUsers();

            Assert.True(result.Count == 0);
        }
コード例 #2
0
        public void GetUsersUnitTest_OkResponse()
        {
            List <DataAccess.Models.User> mockedData = CommonHelper.GetMockedUsersOfDB();

            webApiRepo.Setup(repo => repo.GetUsers()).Returns(mockedData);

            WebApiBusiness webApiBusiness = new WebApiBusiness(webApiRepo.Object, mapper);
            var            result         = webApiBusiness.GetUsers();

            Assert.NotNull(result);
            Assert.Equal(result[0].Id, mockedData[0].Id);
        }