public async void WithUser_ShoudDeleteUser() { var dbContext = this.GetDbContext(); var userManager = CommonGetMockMethods.GetSetupedUserManager(true).Object; var service = this.GetService(dbContext, userManager); var dbUser = SeedUsersMethods.SeedUserWithRole(dbContext); await service.DeleteAsync(dbUser.Id); Assert.Empty(dbContext.Users); }
private async Task <CarServiceModel> CallGetCarViewModelAsync( ApplicationDbContext dbContext, string carId, bool isUserSignIn, string userId) { var signInManager = CommonGetMockMethods.GetSetupedSignInManager(isUserSignIn).Object; var userManager = CommonGetMockMethods.GetSetupedUserManager(userId); var service = this.GetService(dbContext, signInManager, userManager); var user = new Mock <ClaimsPrincipal>().Object; var model = await service.GetCarTestDriveModelById <CarServiceModel>(carId, user); return(model); }
public async void WithAdmin_ShouldThrowException() { var dbContext = this.GetDbContext(); var userManager = CommonGetMockMethods.GetSetupedUserManager(false).Object; var service = this.GetService(dbContext, userManager); var dbAdmin = SeedUsersMethods.SeedAdminWithRole(dbContext); SeedRolesMethods.SeedUserRole(dbContext); var exception = await Assert.ThrowsAsync <InvalidOperationException>(async() => await service.DeleteAsync(dbAdmin.Id)); Assert.Equal(ErrorConstants.IncorrectUser, exception.Message); }
private async Task <IEnumerable <CarServiceModel> > CallGetCarsInventoryViewModelAsync( ApplicationDbContext dbContext, bool isUserSignIn, string userId, int pageNumber = 1) { var signInManager = CommonGetMockMethods.GetSetupedSignInManager(isUserSignIn).Object; var userManager = CommonGetMockMethods.GetSetupedUserManager(isUserSignIn ? userId : null); var service = this.GetService(dbContext, signInManager, userManager); var user = new Mock <ClaimsPrincipal>().Object; var models = await(await service .GetCarTestDriveModelAsync <CarServiceModel>(dbContext.BaseCars, user, pageNumber)) .ToArrayAsync(); return(models); }