[Fact] // Good Test
        public void GetAllTickets_ReturnsAllTickets_ListOfTicketsOkObjectResult()
        {
            var tList = new List <Ticket>
            {
                new Ticket()
                {
                    TicketId = 123
                }, new Ticket()
                {
                    TicketId = 234
                }
            };

            //Arrange
            repoStub.Setup(repo => repo.GetAllTickets()).Returns(tList);

            //Act
            var controller = new TicketController(repoStub.Object);
            var result     = controller.GetAllTickets();

            //Assert
            repoStub.VerifyAll();
            var returnList = Assert.IsType <OkObjectResult>(result);

            Assert.IsType <OkObjectResult>(result);
            Assert.Equal(tList, returnList.Value);
        }
示例#2
0
        public void Get()
        {
            var res = "[[53.47721822541966,42.53731343283582,'Ticket1']," +
                      "[42.92565947242206,12.313432835820896,'Ticket2']," +
                      "[27.577937649880095,89.55223880597015,'Ticket3']]";

            // Arrange
            TicketController controller = new TicketController();

            // Act
            string result = controller.GetAllTickets("US");

            // Assert
            Assert.IsNotNull(result);
            Assert.AreNotEqual("", result);
            Assert.AreEqual(res, result);
        }