public void GetById_ShouldReturnNull_WhenWrongId() { // Arrange var context = GetContext(TestData.employees); var repo = new SqlEmployeeRepo(context); // Act var employee = repo.GetById(999); // Assert Assert.Null(employee); context.Database.EnsureDeleted(); context.Dispose(); }
public void GetById_ShouldReturnEmployee() { // Arrange var context = GetContext(TestData.employees); var repo = new SqlEmployeeRepo(context); int id = _rnd.Next(1, TestData.employees.Count()); // Act var employee = repo.GetById(id); // Assert Assert.Equal(TestData.employees.SingleOrDefault(v => v.Id == id), employee); context.Database.EnsureDeleted(); context.Dispose(); }