public async Task Read_InvalidInput_ReturnsNull(int id) { #region Arrange var dbContext = new ApplicationDbContext(_dbContextOptions); await dbContext.Database.EnsureDeletedAsync(); var appPerson = new Person(dbContext); #endregion #region Act var actualPerson = await appPerson.Read(id); #endregion #region Assert Assert.Null(actualPerson); #endregion }
public async Task Read_ValidInput_ReturnsCorrectData(int id) { #region Arrange var dbContext = new ApplicationDbContext(_dbContextOptions); await dbContext.Database.EnsureDeletedAsync(); var person = new Domain.Person { BirthDate = "04-10-2010", BirthPlace = "Birth Place", Description = "Description", FirstName = "First Name", LastName = "Last Name" }; dbContext.Persons.Add(person); await dbContext.SaveChangesAsync(); var expectedPerson = new PersonModel { ID = id, BirthDate = DateTime.Parse(person.BirthDate), BirthPlace = person.BirthPlace, Description = person.Description, FirstName = person.FirstName, LastName = person.LastName }; var appPerson = new Person(dbContext); #endregion #region Act var actualPerson = await appPerson.Read(id); #endregion #region Assert Assert.Equal(expectedPerson.ID, actualPerson.ID); Assert.Equal(expectedPerson.BirthDate, actualPerson.BirthDate); Assert.Equal(expectedPerson.BirthPlace, actualPerson.BirthPlace); Assert.Equal(expectedPerson.Description, actualPerson.Description); Assert.Equal(expectedPerson.FirstName, actualPerson.FirstName); Assert.Equal(expectedPerson.LastName, actualPerson.LastName); #endregion }