Ejemplo n.º 1
0
        public void CheckTest()
        {
            var bookingServiceMock        = new Mock <IBookingService>();
            var parkingSettingServiceMock = new Mock <IParkingSettingService>();
            var mapperMock = new Mock <IMapper>();

            var options = Options.Create(new AppSettings()
            {
                Secret = "abcE"
            });

            bookingServiceMock.Setup(b => b.GetAll()).Returns(new List <Booking>()
            {
                new Booking()
                {
                }
            });
            parkingSettingServiceMock.Setup(b => b.GetAll()).Returns(new List <ParkingSetting>()
            {
                new ParkingSetting()
                {
                    Spaces = 10
                }
            });

            BookingController controller = new BookingController(parkingSettingServiceMock.Object, bookingServiceMock.Object, null, mapperMock.Object, options);

            var response = controller.Check(new CreateBookingModel());

            bookingServiceMock.Verify(m => m.GetAll(), Times.Once());
            mapperMock.Verify(m => m.Map <IList <BookingModel> >(It.IsAny <IEnumerable <Booking> >()), Times.Once());
            bookingServiceMock.Verify(m => m.Create(It.IsAny <Booking>()), Times.Once());
            parkingSettingServiceMock.Verify(m => m.GetAll(), Times.Once());
        }