public async Task ThenNullIsReturnedIfCanNotFindByIndex( AccountsRepository sut, AccountEntity newEntity) { // Act var entity = await sut.Find(newEntity.Id); // Assert entity.Should().BeNull(); }
public void CreateFindUpdateDeleteTest() { Person createdPerson = new Person(); createdPerson.Name = "gandamu strike freedom"; createdPerson.Document = "ZGMFX20A"; createdPerson.Email = "*****@*****.**"; PeopleRepository peopleRepository = new PeopleRepository(); peopleRepository.Save(createdPerson); Account createdAccount = new Account(); createdAccount.Agency = 435; createdAccount.Number = 123123123; createdAccount.OwnerId = createdPerson.Id; AccountsRepository repository = new AccountsRepository(); repository.Save(createdAccount); Assert.AreNotEqual(0, createdAccount.Id); Account retrievedAccount = repository.FindSingle(a => a.Id == createdAccount.Id); Assert.AreEqual(createdAccount, retrievedAccount); retrievedAccount.Agency = 666; repository.Save(retrievedAccount); retrievedAccount = repository.FindSingle(a => a.Id == createdAccount.Id); IList<Account> accounts = repository.Find(a => a.Id == createdAccount.Id); Assert.AreEqual(666, retrievedAccount.Agency); Assert.AreEqual(1, accounts.Count); repository.Delete(retrievedAccount); accounts = repository.Find(a => a.Id == createdAccount.Id); Assert.AreEqual(0, accounts.Count); }
public async Task ThenAccountCanBeFoundByIndex( AccountsRepository sut, AccountEntity newEntity) { // Arrange await sut.AddOrUpdate(newEntity); // Act var entity = await sut.Find(newEntity.Id); // Assert entity.Should().NotBe(newEntity); entity.Id.Should().Be(newEntity.Id); entity.Name.Should().Be(newEntity.Name); }
public IEnumerable<Account> FindByName(string firstName, string lastName = "") { try { IAccountRepository accountRepo = new AccountsRepository(); return accountRepo.Find(firstName, lastName, null); } catch (InvalidParamsException invPExp) { throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.BadRequest, invPExp.Message)); } catch { throw new HttpResponseException(HttpStatusCode.InternalServerError); } }
public IEnumerable<Account> FindByEmailAddress(string emailAddress) { try { IAccountRepository accountRepo = new AccountsRepository(); return accountRepo.Find(null, null, emailAddress); } catch (InvalidParamsException invPExp) { throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.BadRequest, invPExp.Message)); } catch { throw new HttpResponseException(HttpStatusCode.InternalServerError); } }
public void SaveTest() { var account1 = new Account(); account1.Number = 2345235; account1.Agency = 166; var owner = new Person(); owner.Name = "Ryu Ken"; owner.Document = "3451345"; owner.Email = "*****@*****.**"; account1.Owner = owner; account1.Save(); var account2 = new Account(); account2.Number = 464567; account2.Agency = 345; owner.Accounts.Add(account2); owner.Save(); var accountsRepository = new AccountsRepository(); var accounts = accountsRepository.Find(a => a.PERSON.Id == owner.Id); Assert.IsNotNull(accounts); Assert.AreEqual(2, accounts.Count); Assert.IsTrue(accounts.Contains(account1)); Assert.IsTrue(accounts.Contains(account2)); }