Exemplo n.º 1
0
        public void Can_Send_Pagination_View_Model()
        {
            //arrange
            Mock <IRepository> mock = new Mock <IRepository>();

            mock.Setup(m => m.GetAllResponses()).Returns(new List <GuestResponse> {
                new GuestResponse {
                    Name       = "Matthijs",
                    Email      = "*****@*****.**",
                    Phone      = "0612345678",
                    WillAttend = true
                },
                new GuestResponse {
                    Name       = "Piet",
                    Email      = "*****@*****.**",
                    Phone      = "0612345678",
                    WillAttend = false
                },
                new GuestResponse {
                    Name       = "Truus",
                    Email      = "*****@*****.**",
                    Phone      = "0612345678",
                    WillAttend = true
                },
                new GuestResponse {
                    Name       = "Anja",
                    Email      = "*****@*****.**",
                    Phone      = "0612345678",
                    WillAttend = false
                }
            });

            ResponseController target = new ResponseController(mock.Object);

            target.PageSize = 3;

            //act
            ResponseListViewModel result = (ResponseListViewModel)target.Responses(null, 2).Model;

            //assert
            PagingInfo pageInfo = result.PagingInfo;

            Assert.AreEqual(pageInfo.CurrentPage, 2);
            Assert.AreEqual(pageInfo.ResponsesPerPage, 3);
            Assert.AreEqual(pageInfo.TotalResponses, 4);
            Assert.AreEqual(pageInfo.TotalPages, 2);
        }
Exemplo n.º 2
0
        public void Can_Filter_Responses_Attending()
        {
            //arrange
            Mock <IRepository> mock = new Mock <IRepository>();

            mock.Setup(m => m.GetAllResponses()).Returns(new List <GuestResponse> {
                new GuestResponse {
                    Name       = "Matthijs",
                    Email      = "*****@*****.**",
                    Phone      = "0612345678",
                    WillAttend = true
                },
                new GuestResponse {
                    Name       = "Piet",
                    Email      = "*****@*****.**",
                    Phone      = "0612345678",
                    WillAttend = false
                },
                new GuestResponse {
                    Name       = "Truus",
                    Email      = "*****@*****.**",
                    Phone      = "0612345678",
                    WillAttend = true
                },
                new GuestResponse {
                    Name       = "Anja",
                    Email      = "*****@*****.**",
                    Phone      = "0612345678",
                    WillAttend = false
                }
            });

            ResponseController target = new ResponseController(mock.Object);

            target.PageSize = 3;

            //act
            GuestResponse[] result = ((ResponseListViewModel)target.Responses("Will Attend").Model).GuestResponses.ToArray();


            //assert
            Assert.AreEqual(result.Count(), 2);
            Assert.IsTrue(result[0].Name == "Matthijs" && result[0].WillAttend == true);
            Assert.IsTrue(result[1].Name == "Truus" && result[1].WillAttend == true);
        }
Exemplo n.º 3
0
        public void Can_Paginate()
        {
            //arrange
            Mock <IRepository> mock = new Mock <IRepository>();

            mock.Setup(m => m.GetAllResponses()).Returns(new List <GuestResponse> {
                new GuestResponse {
                    Name       = "Matthijs",
                    Email      = "*****@*****.**",
                    Phone      = "0612345678",
                    WillAttend = true
                },
                new GuestResponse {
                    Name       = "Piet",
                    Email      = "*****@*****.**",
                    Phone      = "0612345678",
                    WillAttend = false
                },
                new GuestResponse {
                    Name       = "Truus",
                    Email      = "*****@*****.**",
                    Phone      = "0612345678",
                    WillAttend = true
                },
                new GuestResponse {
                    Name       = "Anja",
                    Email      = "*****@*****.**",
                    Phone      = "0612345678",
                    WillAttend = false
                }
            });

            ResponseController target = new ResponseController(mock.Object);

            target.PageSize = 3;

            //act
            ResponseListViewModel result = (ResponseListViewModel)target.Responses(null, 2).Model;

            //assert
            GuestResponse[] responseArray = result.GuestResponses.ToArray();
            Assert.IsTrue(responseArray.Length == 1);
            Assert.AreEqual(responseArray[0].Name, "Anja");
        }