public async Task IncorrectBanUser_Test() { var username = "******"; var options = TestUtilities.GetOptions(nameof(IncorrectBanUser_Test)); using (var actContext = new LibrarySystemContext(options)) { await actContext.Users.AddAsync(new User { UserName = "******" }); await actContext.SaveChangesAsync(); } var accountDto = new AccountDto { Username = username }; using (var assertContext = new LibrarySystemContext(options)) { var sut = new AccountWebService(assertContext); var userBan = await sut.BanAccountAsync(accountDto); } }
public async Task ThrowExeptionWhenUserIsAdminBanUser_Test() { var username = "******"; var options = TestUtilities.GetOptions(nameof(ThrowExeptionWhenUserIsAdminBanUser_Test)); using (var actContext = new LibrarySystemContext(options)) { var identityRole = new RoleUser { Id = "77aedcd5-c539-40cd-b88e-e30ff108e6b8", Name = "Admin", NormalizedName = "ADMIN" }; await actContext.Roles.AddAsync(identityRole); var adminTest = await actContext.Users.AddAsync(new User { UserName = username }); var accountDto = new AccountDto { Username = username }; var user = new IdentityUserRole <string> { UserId = adminTest.Entity.Id, RoleId = "77aedcd5-c539-40cd-b88e-e30ff108e6b8" }; await actContext.SaveChangesAsync(); var sut = new AccountWebService(actContext); var userBan = await sut.BanAccountAsync(accountDto); // Assert.IsTrue(userBan.IsBanned); } using (var assertContext = new LibrarySystemContext(options)) { } }
private async Task <bool> RegisterOnlineAccountAsync() { bool result = false; try { if (await AccountWebService.RegisterAccountAsync(_userName, _email, _password)) { result = true; } } catch (WebApiException except) { await _userDialog.AlertAsync(except.Message, Translation.Get(TRS.ERROR), Translation.Get(TRS.OK)); } catch (Exception except) { await _userDialog.AlertAsync(except.Message, Translation.Get(TRS.ERROR), Translation.Get(TRS.OK)); } return(await Task.FromResult(result)); }
private void InitializeCustom() { _accountWebService = new AccountWebService(); _buildingWebService = new BuildingWebService(); }
public AccountController() { _accountService = new AccountWebService(); }