public void InsertStudentTest()
        {
            //Arrange
            var studentEntity = testContext.RepositorySUT.InitializeNew();

            studentEntity.Name = "Job Markos";

            //Act
            testContext.RepositorySUT.Insert(studentEntity);
            testContext.UnitOfWork.Commit();

            //Assert
            using (var schoolDbContext = testContext.CreateSchoolDbContext())
            {
                var retrievedStudent = schoolDbContext.Students.First(entity => entity.Id == studentEntity.Id);
                Assert.Equal(studentEntity, retrievedStudent, new StudentEqualityComparer());
            }
        }
Exemple #2
0
        public void InsertGradeTest()
        {
            //Arrange
            var gradeEntity = testContext.RepositorySUT.InitializeNew();

            gradeEntity.Name    = "Freshman";
            gradeEntity.Section = "High school";

            //Act
            testContext.RepositorySUT.Insert(gradeEntity);
            testContext.UnitOfWork.Commit();

            //Assert
            using (var schoolDbContext = testContext.CreateSchoolDbContext())
            {
                var retrievedGrade = schoolDbContext.Grades.First(entity => entity.Id == gradeEntity.Id);
                Assert.Equal(gradeEntity, retrievedGrade, new GradeEqualityComparer());
            }
        }