示例#1
0
        public void Exams_Controller_Test_On_Delete_With_Existent_Id()
        {
            //Arrange
            Guid     id           = new Guid("f616cc8c-2223-4145-b7d0-232a1f6f0795");
            string   title        = "TestT";
            string   observations = "TestF";
            DateTime dateStart    = DateTime.Now;
            DateTime dateEnd      = DateTime.Now.AddDays(1);

            Exam expectedExams = new Exam(title, observations, dateStart, dateEnd);

            expectedExams.Id = id;

            var repo = Substitute.For <IRepository>();
            var sut  = new ExamsController(repo);

            repo.GetById <Exam>(id).Returns(expectedExams);
            //Act
            var actual = sut.Delete(id).Result as ViewResult;

            //Assert
            Assert.IsInstanceOfType(actual, typeof(ViewResult));
            var viewResult = actual;

            Assert.AreEqual(expectedExams, viewResult.Model);
        }
示例#2
0
        public void Exams_Controller_Test_On_Delete_With_Null_Id()
        {
            //Arrange
            var id   = Guid.Empty;
            var repo = Substitute.For <IRepository>();
            var sut  = new ExamsController(repo);

            repo.GetById <Exam>(id);

            //Act
            var actual = sut.Delete(id).Result;

            //Assert
            Assert.IsInstanceOfType(actual, typeof(NotFoundResult));
        }
示例#3
0
        public void Exams_Controller_Test_On_Delete_With_NonExistent_Id()
        {
            //Arrange
            Guid id   = new Guid("f616cc8c-2223-4145-b7d0-232a1f6f0795");
            var  repo = Substitute.For <IRepository>();
            var  sut  = new ExamsController(repo);

            repo.GetById <Exam>(id);

            //Act
            var actual = sut.Delete(id).Result;

            //Assert
            Assert.IsInstanceOfType(actual, typeof(NotFoundResult));
        }
        public async Task Return_Delete_View_With_Exams_List()
        {
            // Arrange
            var fixture         = new Fixture();
            var context         = GetFakeContext();
            var ExamsController = new ExamsController(context, GetMockedUserManager());
            var exam            = fixture.Create <Exam>();

            exam.ExamId = context.Exams.FirstOrDefault().ExamId;

            // Act
            var result = await ExamsController.Delete(exam.ExamId);

            // Assert
            Assert.NotNull(result);
            var viewResult = Assert.IsAssignableFrom <ViewResult>(result);
        }