public void CanCreateNewAccount() { // Act var account = new Account("*****@*****.**"); // Assert var events = account.GetUncommittedChanges(); Assert.That(events.Length, Is.EqualTo(1)); Assert.That(events[0], Is.InstanceOf<AccountCreated>()); }
public void InvalidatesFalsePassword() { // Arrange var account = new Account("*****@*****.**"); // Act account.Activate("some password"); // Assert Assert.That(account.ValidatePassword("invalid password"), Is.False); }
public void ActivatedAccountCanValidatePasswords() { // Arrange var account = new Account("*****@*****.**"); // Act account.Activate("some password"); // Assert account.ValidatePassword(""); }
public void CanActivateAccount() { // Arrange var account = new Account("*****@*****.**"); // Act account.Activate("some password"); // Assert var events = account.GetUncommittedChanges(); Assert.That(events.Length, Is.EqualTo(2)); Assert.That(events[1], Is.InstanceOf<AccountActivated>()); }
public async Task <IActionResult> Update([FromBody] Models.Account account) { var existing = this.context.Accounts.Where(p => p.Id == account.Id).FirstOrDefault(); if (existing == null) { return(NotFound()); } this.context.Accounts.Update(account); await this.context.SaveChangesAsync(); return(NoContent()); }
public void InactiveAccountDoesNotValidatePasswords() { // Arrange var account = new Account("*****@*****.**"); // Act try { account.ValidatePassword("some password"); // Assert Assert.Fail("Should throw"); } catch (InvalidOperationException) { } }
public async Task <IActionResult> Create([FromBody] Models.Account account) { this.context.Add(account); this.context.SaveChanges(); return(await Task.FromResult(Ok(account))); }