示例#1
0
        public void Delete_ExistingTeacher_OkResult()
        {
            var controller = new TeacherController(_logger, _teacherService);
            var teacher    = new Entities.Models.Teacher
            {
                Id             = new Guid("f7afefa9-2cc6-4ea9-901d-d99e227a12de"),
                FirstName      = "Bart",
                LastName       = "Simpson",
                DocumentType   = Entities.Models.EDocumentType.CC,
                DocumentNumber = "97654315",
                Address        = "Springfield 123",
                Email          = "*****@*****.**",
                City           = "Springfield",
                PhoneNumber    = "7654321",
                Birth          = new DateTime(1950, 11, 1)
            };

            var data = controller.CreateTeacher(teacher);

            Assert.IsType <CreatedAtRouteResult>(data as CreatedAtRouteResult);

            var deleteResult = controller.DeleteTeacher(teacher.Id);

            Assert.IsType <NoContentResult>(deleteResult);
        }
示例#2
0
        public void Delete_NonExistingTeacher_NotFoundResult()
        {
            var controller = new TeacherController(_logger, _teacherService);
            var teacherId  = new Guid("1c575a69-27f3-4379-b7be-5798a0001449");
            var data       = controller.DeleteTeacher(teacherId);

            Assert.IsType <NotFoundResult>(data);
        }
示例#3
0
        //TODO tests for delete and update
        public void DeleteTeacher()
        {
            //Arrange
            var teacherDal        = Substitute.For <ITeacherDal>();
            var teacherController = new TeacherController(teacherDal);

            //Act
            teacherController.DeleteTeacher(1);

            //Assert
            // ????????
        }
示例#4
0
        public async Task Delete_Teacher()
        {
            //Given
            int teacherId             = 1;
            var teacherRepositoryMock = new Mock <ITeacherRepository>();

            teacherRepositoryMock.Setup(x => x.Delete(teacherId)).ReturnsAsync(true);

            //When
            TeacherController controller = new TeacherController(teacherRepositoryMock.Object);
            var result = await controller.DeleteTeacher(teacherId) as ObjectResult;

            //Then
            Assert.AreEqual((int)HttpStatusCode.OK, result.StatusCode);
        }