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