Ejemplo n.º 1
0
        public void CanCreate()
        {
            _testDatabase.RunAndRollback(dbContext =>
            {
                var student = new Student
                {
                    LastName = "Rambo"
                };

                var createdStudent = new StudentRepository(dbContext).Create(student);

                Assert.NotNull(createdStudent);
                Assert.True(createdStudent.Id > 0);
                Assert.Equal(student.LastName, createdStudent.LastName);
            });
        }
Ejemplo n.º 2
0
        public void CanGet()
        {
            _testDatabase.RunAndRollback(dbContext =>
            {
                var student1 = new Student
                {
                    LastName = "Rambo"
                };

                var student2 = new Student
                {
                    LastName = "Cobretti"
                };

                dbContext.Students.Add(student1);
                dbContext.Students.Add(student2);
                dbContext.SaveChanges();

                var student = new StudentRepository(dbContext).Get(student2.Id);

                Assert.NotNull(student);
                Assert.Equal(student2.Id, student.Id);
            });
        }
Ejemplo n.º 3
0
        public void CanUpdate()
        {
            _testDatabase.RunAndRollback(dbContext =>
            {
                var updatedLastName = "Balboa";

                var student = new Student
                {
                    LastName = "Rambo"
                };

                dbContext.Students.Add(student);
                dbContext.SaveChanges();

                student.LastName = updatedLastName;
                var updatedStudent = new StudentRepository(dbContext).Update(student);

                Assert.NotNull(updatedStudent);
                Assert.Equal(student.Id, updatedStudent.Id);
                Assert.Equal(updatedLastName, updatedStudent.LastName);
            });
        }