public async Task Update_ValidEntity_ShouldCreateBeUpdated() { // Arrange FakeEntity entity = new FakeEntity(_fixture.Create <string>(), _fixture.Create <string>()); IBaseRepository <FakeEntity> repository = new BaseRepository <FakeDbContext, FakeEntity>(_context); _context.FakeEntities.Add(entity); await _context.SaveChangesAsync(); entity.Update(_fixture.Create <string>(), _fixture.Create <string>()); // Act repository.Update(entity); await _context.SaveChangesAsync(); // Assert FakeEntity actualResult = await _context.FakeEntities.FindAsync(entity.Id); Assert.NotNull(actualResult); entity .WithDeepEqual(actualResult) .Assert(); }
public async Task Create_ValidEntity_ShouldCreateBeCreated() { // Arrange string name = _fixture.Create <string>(); string description = _fixture.Create <string>(); FakeEntity entity = new FakeEntity(name, description); IBaseRepository <FakeEntity> repository = new BaseRepository <FakeDbContext, FakeEntity>(_context); // Act repository.Create(entity); await _context.SaveChangesAsync(); // Assert FakeEntity actualResult = await _context.FakeEntities.FindAsync(entity.Id); Assert.NotNull(actualResult); entity .WithDeepEqual(actualResult) .Assert(); }