Beispiel #1
0
        public async Task GetRoles_ThrowException_Failed()
        {
            _mockRoleManager.Setup(x => x.Roles)
            .Throws <Exception>();
            var rolesController = new RolesController(_mockRoleManager.Object, _context);

            await Assert.ThrowsAnyAsync <Exception>(async() =>
                                                    await rolesController.GetAll());
        }
Beispiel #2
0
        public async Task GetRoles_HasData_ReturnSuccess()
        {
            _mockRoleManager.Setup(x => x.Roles)
            .Returns(_roleSources.AsQueryable().BuildMock().Object);
            var rolesController = new RolesController(_mockRoleManager.Object, _context);
            var result          = await rolesController.GetAll();

            var okResult = result as OkObjectResult;
            var roleVms  = okResult.Value as IEnumerable <RoleVm>;

            Assert.True(roleVms.Count() > 0);
        }