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