public void CanCreate() { _testDatabase.RunAndRollback(dbContext => { var testScore = new TestScore { Score = 7.5M }; var createdTestScore = new TestScoreRepository(dbContext).Create(testScore); Assert.NotNull(createdTestScore); Assert.True(createdTestScore.Id > 0); Assert.Equal(testScore.Score, createdTestScore.Score); }); }
public void CanGet() { _testDatabase.RunAndRollback(dbContext => { var testScore1 = new TestScore { Score = 7.5M }; var testScore2 = new TestScore { Score = 8.5M }; dbContext.TestScores.Add(testScore1); dbContext.TestScores.Add(testScore2); dbContext.SaveChanges(); var testScore = new TestScoreRepository(dbContext).Get(testScore2.Id); Assert.NotNull(testScore); Assert.Equal(testScore2.Id, testScore.Id); }); }
public void CanUpdate() { _testDatabase.RunAndRollback(dbContext => { var updatedScore = 9.5M; var testScore = new TestScore { Score = 7.5M }; dbContext.TestScores.Add(testScore); dbContext.SaveChanges(); testScore.Score = updatedScore; var updatedTestScore = new TestScoreRepository(dbContext).Update(testScore); Assert.NotNull(updatedTestScore); Assert.Equal(testScore.Id, updatedTestScore.Id); Assert.Equal(updatedScore, updatedTestScore.Score); }); }