Exemplo n.º 1
0
        public void Response_Should_Return_View_OfType_ResponseViewModel()
        {
            //arrange
            var mockContext = new Mock <SchedulerDbContext>();

            mockContext.Setup(c => c.Events.Find(1)).Returns(
                new Event
            {
                Id           = 1,
                ListDate     = new DateTime(2020, 02, 10),
                Participants = new List <Participant> {
                    new Participant {
                        Id = 1
                    }
                }
            });
            var controller = new ResponseController(mockContext.Object);

            //act
            var result = controller.Response(1, 1) as ViewResult;

            //Assert
            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result.ViewData.Model, typeof(ResponseViewModel));
        }
Exemplo n.º 2
0
        public void Response_Should_Return_HttpNotfound()
        {
            //arrange
            var mockContext = new Mock <SchedulerDbContext>();

            mockContext.Setup(c => c.Events.Find(1)).Returns(new Event {
                Id = 1, Participants = new List <Participant> {
                    new Participant {
                        Id = 1
                    }
                }
            });
            var controller = new ResponseController(mockContext.Object);

            //act
            var result = controller.Response(1, 22) as HttpNotFoundResult;

            //Assert
            Assert.AreEqual(404, result.StatusCode);
        }
Exemplo n.º 3
0
        public void Response_Should_Return_CantRespond_View()
        {
            var mockContext = new Mock <SchedulerDbContext>();

            mockContext.Setup(c => c.Events.Find(1)).Returns(new Event
            {
                Id           = 1,
                ListDate     = new DateTime(2015, 02, 10),
                Participants = new List <Participant> {
                    new Participant {
                        Id = 1
                    }
                }
            });
            var controller = new ResponseController(mockContext.Object);

            //act
            var result = controller.Response(1, 1) as ViewResult;

            //assert
            Assert.AreEqual("_CantRespond", result.ViewName);
        }