コード例 #1
0
        public void Index_ShowCorrectView()
        {
            var result = Controller.Index(null, "Date");

            //implement
            Assert.Null(1);
        }
コード例 #2
0
 public void Index_ReturnsViewResultWithCorrectListOfBookings()
 {
     // Act
     var result       = controller.Index(null) as ViewResult;
     var yearExpected = DateTime.Today.Year;
     var year         = result.ViewData;
     // Assert
 }
コード例 #3
0
        public void Index_ReturnsView()
        {
            // Act
            var result = _bookingsController.Index("testTenant");

            // Assert
            var viewResult = Assert.IsType <ViewResult>(result.Result);
            //var model = Assert.IsAssignableFrom<IEnumerable<BookingModel>>(viewResult.ViewData.Model);
            //Assert.Equal(2, model.Count());
        }
コード例 #4
0
        public void Index_ReturnsViewResultWithCorrectListOfBookings()
        {
            // Act
            //var result = controller.Index(null) as ViewResult;

            // Assert
            // Assert.NotNull(result);

            // Act
            var result           = controller.Index(null) as ViewResult;
            var bookingviewmodel = result.Model as BookingViewModel;
            var listofbookings   = bookingviewmodel.Bookings as IList <Booking>;
            var count            = listofbookings.Count;

            // Assert
            Assert.Equal(2, count);
        }
コード例 #5
0
        public void IndexTest()
        {
            var bookingList = new List <Booking>()
            {
                new Booking()
                {
                    Guests = new List <Guest>(),
                    Room   = new Room(),
                    Date   = new DateTime(2019, 6, 12),
                    Price  = 200,
                },
            };

            var userMock = new Mock <IPrincipal>();

            userMock.Setup(p => p.IsInRole("Employee")).Returns(true);

            var contextMock = new Mock <HttpContextBase>();

            contextMock.SetupGet(ctx => ctx.User)
            .Returns(userMock.Object);

            var controllerContextMock = new Mock <ControllerContext>();

            controllerContextMock.SetupGet(con => con.HttpContext)
            .Returns(contextMock.Object);

            _bookingController.ControllerContext = controllerContextMock.Object;

            _mockBookingRepo.Setup(x => x.GetAllBookingInfo()).Returns(bookingList);

            var result = _bookingController.Index() as ViewResult;

            userMock.Verify(p => p.IsInRole("Employee"));

            Assert.AreEqual(bookingList, result.Model);
        }
コード例 #6
0
        public async Task Index_WhenCalled_ReturnAllBookings()
        {
            // Arrange
            repository.Setup(r => r.GetBookingsAsync(It.IsAny <DateTime>(), It.IsAny <DateTime>())).ReturnsAsync(new List <Booking>
            {
                new Booking
                {
                    Id            = 1,
                    FirstName     = "Andy",
                    LastName      = "J",
                    Mobile        = "123456789",
                    DateBooked    = new DateTime(2020, 12, 22),
                    TimeBooked    = "12:30",
                    Status        = 1,
                    NumberinParty = 5,
                    Method        = 1,
                    TableNo       = 1,
                    EmployeeId    = 1,
                    DateCreated   = new DateTime(2020, 12, 20)
                },
                new Booking
                {
                    Id            = 2,
                    FirstName     = "Joseph",
                    LastName      = "K",
                    Mobile        = "123456789",
                    DateBooked    = new DateTime(2021, 02, 22),
                    TimeBooked    = "12:30",
                    Status        = 1,
                    NumberinParty = 5,
                    Method        = 1,
                    TableNo       = 1,
                    EmployeeId    = 1,
                    DateCreated   = new DateTime(2020, 12, 20)
                },
                new Booking
                {
                    Id            = 3,
                    FirstName     = "Jimmy",
                    LastName      = "Kim",
                    Mobile        = "123456789",
                    DateBooked    = new DateTime(2020, 12, 22),
                    TimeBooked    = "12:30",
                    Status        = 1,
                    NumberinParty = 5,
                    Method        = 1,
                    TableNo       = 1,
                    EmployeeId    = 1,
                    DateCreated   = new DateTime(2020, 12, 20)
                }
            });


            // Act
            var result = await controller.Index(It.IsAny <string>(), It.IsAny <string>()) as ViewResult;

            var model = result.Model as List <Booking>;

            // Assert
            Assert.That(result, Is.Not.Null);
            Assert.That(model.Count, Is.EqualTo(3));
        }