Ejemplo n.º 1
0
        public async Task AddOrderGatewayActionResult()
        {
            String     testId              = "100";
            bool       success             = true;
            var        mockClientFactory   = new Mock <IHttpClientFactory>();
            var        mockServiceClient   = new Mock <IClientService>();
            var        mockServiceOrder    = new Mock <IOrderService>();
            var        mockServiceFlight   = new Mock <IFlightService>();
            var        mockServiceAircraft = new Mock <IAircraftService>();
            OrderModel order = GetTestOrders()[0];

            mockServiceOrder.Setup(c => c.Create(GetTestOrders()[0]));
            //.ReturnsAsync((true, GetTestConcerts()[0]));
            mockServiceFlight.Setup(c => c.Update(testId, GetTestFlights()[0]));
            mockServiceFlight.Setup((c) => c.GetById(testId))
            .Returns(Task.FromResult(GetTestFlights()[0]));
            //mockServiceAircraft.Setup(c => c.GetAll(1, 1));


            var controller = new BookingController(mockClientFactory.Object,
                                                   mockServiceOrder.Object, mockServiceClient.Object, mockServiceFlight.Object, mockServiceAircraft.Object);

            // Act
            var result = await controller.AddOrder(order);

            // Assert
            var requestResult = Assert.IsType <OkResult>(result);
        }
Ejemplo n.º 2
0
        public async Task TestGetAll()
        {
            int testId = 1;

            //var mockLogger = new Mock<ILogger<ConcertsController»();
            var mockClientFactory   = new Mock <IHttpClientFactory>();
            var mockServiceClient   = new Mock <IClientService>();
            var mockServiceOrder    = new Mock <IOrderService>();
            var mockServiceFlight   = new Mock <IFlightService>();
            var mockServiceAircraft = new Mock <IAircraftService>();

            mockServiceClient.Setup(c => c.GetAll(1, 1));
            //.Returns(Task.FromResult(GetTestClients()[0]));
            mockServiceOrder.Setup(c => c.GetAll(1, 1));
            mockServiceFlight.Setup(c => c.GetAll(1, 1));
            mockServiceAircraft.Setup(c => c.GetAll(1, 1));


            var controller = new BookingController(mockClientFactory.Object,
                                                   mockServiceOrder.Object, mockServiceClient.Object, mockServiceFlight.Object, mockServiceAircraft.Object);

            // Act
            var result = await controller.GetAll();

            // Assert
            var requestResult = Assert.IsType <OkObjectResult>(result);
            var model         = Assert.IsType <Res>(requestResult.Value);

            Assert.NotNull(model);
        }
Ejemplo n.º 3
0
        public void PostBookingReturnsValidModel()
        {
            var bookingToReturn = BookingModel.ToEntity();

            bookingToReturn.Lodging = new Lodging()
            {
                Id          = 1,
                Name        = "Name",
                Description = "Description",
                Rating      = 3,
                IsFull      = true,
                Images      = new List <LodgingImage>()
                {
                    new LodgingImage()
                },
                PricePerNight       = 100,
                Address             = "Valid Address 123",
                Phone               = "+598 98 303 040",
                ConfirmationMessage = "Your reservation has been confirmed!",
                TouristSpot         = new TouristSpot()
            };

            BookingLogicMock.Setup(m => m.Create(It.IsAny <Booking>(), It.IsAny <List <Guest> >()))
            .Returns(bookingToReturn);
            var bookingController = new BookingController(BookingLogicMock.Object, BookingStateLogicMock.Object,
                                                          LodgingReviewLogicMock.Object);

            var result  = bookingController.Post(BookingModel) as CreatedResult;
            var content = result.Value as BookingBasicInfoModel;

            BookingLogicMock.VerifyAll();
            Assert.AreEqual(result.StatusCode, 201);
            Assert.IsTrue(content.Equals(new BookingBasicInfoModel(bookingToReturn)));
        }
        public void FetchBooking_RegularValues_OkResult()
        {
            //Arrange
            var booking = new Mock <IBooking>();

            booking.SetupGet(b => b.Id).Returns(2);
            booking.SetupGet(b => b.FacilityId).Returns(3);

            var bookingNew = new Mock <IBooking>();

            bookingNew.SetupGet(b => b.Id).Returns(3);
            bookingNew.SetupGet(b => b.FacilityId).Returns(3);

            var bookingList = new List <IBooking>()
            {
                booking.Object, bookingNew.Object
            };

            facade.Setup(f => f.FetchBookings("3445", 3)).Returns(bookingList);

            var controller = new BookingController(facade.Object)
            {
                ControllerContext = controllerContext
            };

            //Act
            var result = controller.FetchFacilityBookings(3);

            //Assert
            Assert.NotNull(result);

            var okresult = Assert.IsType <OkNegotiatedContentResult <IEnumerable <IBooking> > >(result);

            Assert.Equal(2, okresult.Content.Count());
        }
        public void AddLion_NoFarmAnimalsInList_Test()
        {
            //1. Arrange
            var existingBooking = new Booking {
                ID = 1, Date = DateTime.Now.AddDays(1)
            };
            var list  = new List <Beast>();
            var beast = new Beast {
                Name = "Leeuw"
            };

            //list.Add(beast);

            beast.Booking.Add(existingBooking);
            _boekingsRepository.Setup(b => b.TempBooking).Returns(new BookingVM {
                ID = 2, Date = DateTime.Now
            });
            _beastRepository.Setup(b => b.GetAll()).Returns(GetListLion());
            _bookingscontroller = new BookingController(_boekingsRepository.Object, _beastRepository.Object, _accessoryRepository.Object, _contactpersonRepository.Object);


            //2. Act
            var result = (RedirectToRouteResult)_bookingscontroller.AddCheckedAnimal(new BeastVM(beast));

            //3. Assert
            _beastRepository.VerifySet(m => m.ExcludeFarm = true);
        }
Ejemplo n.º 6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Session["BookingId"] != null)
                {
                    int     id      = Int16.Parse((string)Session["BookingId"]);
                    Booking booking = BookingController.GetInstance().Recover(id);
                    bool    exists  = AccessCodeController.GetInstance().ExistsAccessCode(booking.user_id, booking.booking_id);

                    if (exists)
                    {
                        CheckCode.Visible = true;
                        SendCode.Visible  = false;
                    }
                    else
                    {
                        SendCode.Visible  = true;
                        CheckCode.Visible = false;
                    }
                    HiddenFieldId.Value     = id.ToString();
                    HiddenFieldUserId.Value = booking.user_id.ToString();
                }
            }
        }
Ejemplo n.º 7
0
        /** Method initiates process of saving a booking */
        private void saveBookingButton_Click(object sender, EventArgs e)
        {
            BookingController controller = new BookingController();
            string            startTime  = timeOfBooking.Text.Substring(0, 5);
            string            endTime    = timeOfBooking.Text.Substring(7);
            int userId = ApplicationState.userId;

            if (ApplicationState.userType == "admin")
            {
                if ((int)patientListBox.SelectedValue == 0)
                {
                    FeedbackWindow message = new FeedbackWindow();
                    message.setCustomizedMessage("You are required to choose a patient");
                    message.Show();
                    return;
                }
                else
                {
                    userId = (int)patientListBox.SelectedValue;
                }
            }
            bool result = false;

            result = controller.bookAppointment(commentTextField.Text, startTime, endTime, userId, staffScheduleId);
            this.reloadScheduleOrShowFeedbackWindowBasedOnResult(result);
            if (result && (printCheckBox.Checked || emailCheckBox.Checked))
            {
                PrintingPrompt printingPrompt = new PrintingPrompt(this.date, startTime, endTime, this.doctorsName, staffScheduleId);
                printingPrompt.Show();
            }
        }
Ejemplo n.º 8
0
        public async Task BookingsByCustomerID_Returns_A_BookingViewModel()
        {
            // Arrange
            var returnedValues = new List <Booking>()
            {
                new Booking()
                {
                    BookingID = 1
                },
                new Booking()
                {
                    BookingID = 1
                }
            };

            int testId = 1;
            var mock   = new Mock <IDelpinHttpClientHandler <Booking> >();

            mock.Setup(m => m.CallHttpGet(It.IsAny <string>(), It.IsAny <string>()))
            .ReturnsAsync(returnedValues);

            var sut = new BookingController(Configuration(), mock.Object);

            // Act
            var result = await sut.BookingsByCustomerID(testId) as ViewResult;

            // Assert
            var model = Assert.IsType <BookingViewModel>(result.Model);

            int bookingId = model.bookings.Select(c => c.BookingID).FirstOrDefault();

            Assert.Equal(returnedValues, model.bookings);
            Assert.Equal(returnedValues.Count, model.bookings.Count);
            Assert.Equal(1, bookingId);
        }
Ejemplo n.º 9
0
        public void Index_ReturnsRedirectToRegisterPage_WhenUserIsNotSignedIn()
        {
            var controller = new BookingController(new Mock <ILogger <BookingController> >().Object, new Mock <MockSignInManager>().Object, null);

            var mockUrlHelper = new Mock <IUrlHelper>(MockBehavior.Strict);

            mockUrlHelper
            .Setup(
                x => x.Action(It.IsAny <UrlActionContext>())
                )
            .Returns("callbackUrl");

            controller.Url = mockUrlHelper.Object;

            var model = new BookingViewModel();

            model.ResourceId = Guid.NewGuid();
            model.ServicesId.Add(Guid.NewGuid());
            model.Time = DateTime.Now;

            var result = controller.Index(model);

            Assert.True(controller.ModelState.IsValid);

            var viewResult = Assert.IsType <RedirectToPageResult>(result);

            Assert.Equal("/Account/Register", viewResult.PageName);
            Assert.Equal("callbackUrl", viewResult.RouteValues["returnUrl"]);
        }
Ejemplo n.º 10
0
        public void Add_InvalidObjectPassed_ReturnsBadRequest()
        {
            //Arrange
            var booking = new Booking()
            {
                BookingId   = 11,
                ShowId      = 1,
                BookingTime = System.DateTime.Now,
                seats       = 5
            };

            var mockRepo = new Mock <IBookingService>();

            mockRepo.Setup(repo => repo.PostBooking(booking))
            .Returns(_bookingservice.PostBooking(booking));
            _bookingcontroller = new BookingController(mockRepo.Object);


            _bookingcontroller.ModelState.AddModelError("UserName", "Required");
            // Act
            var badResponse = _bookingcontroller.PostBooking(booking);

            // Assert
            Assert.IsType <BadRequestObjectResult>(badResponse.Result.Result);
        }
Ejemplo n.º 11
0
        public void PostReturnsCorrectModel(BookingController sut,
                                            BookingViewModel expected)
        {
            var actual = sut.Post(expected);

            Assert.Equal(expected, actual.Model);
        }
Ejemplo n.º 12
0
 public UnitTest1()
 {
     context           = new ApparelStoreContext();
     controller        = new AdminController(this.context);
     searchcontroller  = new SearchServiceController(this.context);
     bookingController = new BookingController(this.context);
 }
Ejemplo n.º 13
0
        public void GetReturnsCorrectModelType(BookingController sut,
                                               DateViewModel id)
        {
            ViewResult actual = sut.Get(id);

            Assert.IsAssignableFrom <BookingViewModel>(actual.Model);
        }
Ejemplo n.º 14
0
        public void PostReturnsCorrectViewName(BookingController sut,
                                               BookingViewModel model)
        {
            ViewResult actual = sut.Post(model);

            Assert.Equal("Receipt", actual.ViewName);
        }
 public void CreateMocks()
 {
     _mockFilmContext    = new MockFilmContext();
     _mockShowingContext = new MockShowingContext();
     _mockBookingContext = new MockBookingContext();
     _bookingController  = new BookingController(new BookingService(new ShowingService(_mockShowingContext, _mockFilmContext), _mockBookingContext));
 }
Ejemplo n.º 16
0
        public BookingControllerTest()
        {
            var loggerMock     = new Mock <ILogger <BookingController> >();
            var repositoryMock = new Mock <IRepository <BookingModel> >();
            var unitOfWorkMock = new Mock <IUnitOfWork>();

            IEnumerable <BookingModel> bookings = new List <BookingModel> {
                new BookingModel()
            };
            var booking  = new BookingModel();
            var checkIn  = It.IsAny <DateTime>();
            var checkOut = It.IsAny <DateTime>();

            repositoryMock.Setup(m => m.DeleteAsync(0)).Returns(Task.CompletedTask);
            repositoryMock.Setup(m => m.DeleteAsync(1)).Returns(Task.CompletedTask);
            repositoryMock.Setup(m => m.InsertAsync(It.IsAny <BookingModel>())).Returns(Task.CompletedTask);
            repositoryMock.Setup(m => m.SelectAsync()).ReturnsAsync((IEnumerable <BookingModel>)null);
            repositoryMock.Setup(m => m.SelectAsync(e => e.EntityId == 0)).ReturnsAsync((IEnumerable <BookingModel>)null);
            repositoryMock.Setup(m => m.SelectAsync(e => e.EntityId == 1)).ReturnsAsync(new [] { booking });
            repositoryMock.Setup(m => m.Update(It.IsAny <BookingModel>()));
            repositoryMock.Setup(m => m.SelectAsync(e =>
                                                    (checkIn <= e.CheckIn && checkOut >= e.CheckIn) ||
                                                    (checkIn <= e.CheckOut && checkOut >= e.CheckOut) ||
                                                    (checkIn <= e.CheckIn && checkOut >= e.CheckOut) ||
                                                    (checkIn >= e.CheckIn && checkOut <= e.CheckOut))).ReturnsAsync(bookings);
            repositoryMock.Setup(m => m.SelectAsync(e => e.EntityId == 0)).ReturnsAsync(Enumerable.Empty <BookingModel>());
            repositoryMock.Setup(m => m.SelectAsync(e => e.EntityId == 1)).ReturnsAsync(bookings);

            unitOfWorkMock.Setup(m => m.Booking).Returns(repositoryMock.Object);

            _logger     = loggerMock.Object;
            _unitOfWork = unitOfWorkMock.Object;
            _controller = new BookingController(_logger, _unitOfWork);
        }
Ejemplo n.º 17
0
        public BookingControllerTests()
        {
            var element = new ElementBuilder()
                          .WithType(EElementType.Booking)
                          .WithQuestionId("valid")
                          .Build();

            var page = new PageBuilder()
                       .WithElement(element)
                       .WithValidatedModel(true)
                       .WithPageSlug("valid")
                       .Build();

            var schema = new FormSchemaBuilder()
                         .WithPage(page)
                         .Build();

            _schemaFactory.Setup(_ => _.Build("valid"))
            .ReturnsAsync(schema);

            _bookingController = new BookingController(_bookingService.Object, _schemaFactory.Object, _pageHelper.Object, _sessionHelper.Object);
            _bookingController.ControllerContext             = new ControllerContext();
            _bookingController.ControllerContext.HttpContext = new DefaultHttpContext();
            _bookingController.ControllerContext.HttpContext.Request.Query = new QueryCollection();
        }
Ejemplo n.º 18
0
        public void TestPostBookTableAsync()
        {
            //Arrange
            //var client = new RestClient("https://localhost:44349/api/Booking/Create");
            // var client = new RestClient(constring);


            //string json = JsonConvert.SerializeObject(reservation);
            ////ACT
            //var request = new RestRequest("/post", Method.POST);
            //// var request = new RestRequest("/Booking/Create", Method.POST);
            //// request.AddJsonBody(reservation);
            //request.AddJsonBody(json);
            //var response = client.Execute(request);



            //Arrange
            BookingController _bc = new BookingController();
            var reservation       = new ReservationDTO(
                DateTime.Now,
                new CustomerDTO(),
                DateTime.Now,
                4,
                false,
                "TEST",
                new List <RestaurantTablesDTO>());

            //Act
            var response = _bc.PostBookingAsync(reservation, constring).Result;

            //Assert
            Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
        }
Ejemplo n.º 19
0
        public void Item9_ListRoomsByStudent()
        {
            var context = new Mock <ControllerContext>();
            var session = new MockHttpSession();

            context.Setup(m => m.HttpContext.Session).Returns(session);

            BookingController bc = new BookingController();

            bc.ControllerContext = context.Object;

            bc.Session["UserName"] = "******"; // this is the login account to obs.

            BookingViewModel bvmd = new BookingViewModel()
            {
                BookingDate = DateTime.Today
            };

            var result = bc.GetAllRooms(bvmd) as PartialViewResult;

            IEnumerable <BookingViewModel> mds = result.Model as IEnumerable <BookingViewModel>;

            //the count value may be diferent.  At the time for testing this function, there are total 6 Rooms

            /* Use below query to know the exact booking number in database:
             *
             *  select	count(*)
             *  from	Rooms
             *  where	IsActive = 1
             *
             */

            Assert.AreNotEqual(6, mds.Count());
        }
Ejemplo n.º 20
0
        /** Method initiaties the process of updating the attendance process */
        private void saveButton_Click(object sender, System.EventArgs e)
        {
            FeedbackWindow message = new FeedbackWindow();

            if (attendanceOptions.SelectedIndex != 0)
            {
                BookingController        controller     = new BookingController();
                string                   selectedOption = (attendanceOptions.SelectedItem as ListItem).text;
                Dictionary <string, int> options        = controller.getAttendanceOptions()[selectedOption];
                booking.setAttendance(options["attendance"]);
                booking.setConfirmation(options["confirmation"]);
                booking.setLackOfCancellation(options["lackOfCancellation"]);
                if (controller.updateAttendanceStatus(booking))
                {
                    message.setMessageForSuccessfullOperation();
                }
                else
                {
                    message.setMessageForSavingError();
                }
                parent.getAppointmentBoxes();
                this.Hide();
            }
            else
            {
                message.setCustomizedMessage(ATTENDANCE_OPTION_NOT_SELECTED);
            }
            message.Show();
        }
Ejemplo n.º 21
0
        public void Item2_SendBookingRequest()
        {
            var context = new Mock <ControllerContext>();
            var session = new MockHttpSession();

            context.Setup(m => m.HttpContext.Session).Returns(session);

            BookingController bc = new BookingController();

            bc.ControllerContext = context.Object;

            bc.Session["LogedUserID"] = 3;

            BookingViewModel bvmd = new BookingViewModel()
            {
                RoomId          = 16,
                BookingHourID   = 1,
                BookingDate     = DateTime.Today.AddDays(4),
                NumberOfMembers = "5"
            };

            var result = bc.Index(bvmd) as JsonResult;

            string test = Convert.ToString(result.Data);

            Assert.AreEqual("{ message = Booking Successfully Created., success = True }", Convert.ToString(result.Data));
        }
Ejemplo n.º 22
0
        public void BookingController_CreateBooking()
        {
            IHotelTamagotchiContext c  = new FakeHotelTamagotchiContext();
            IHotelRoomRepository    hr = new HotelRoomRepository(c);
            ITamagotchiRepository   tr = new TamagotchiRepository(c);
            BookingController       bc = new BookingController(hr, tr);
            var ccMock = new Mock <ControllerContext>();

            ccMock.SetupGet(x => x.HttpContext.Session["User"]).Returns("testUser");
            ccMock.SetupGet(x => x.HttpContext.Session["Role"]).Returns(UserRole.Customer);
            bc.ControllerContext = ccMock.Object;
            FormCollection fc = new FormCollection();


            TamagotchiViewModel t = new TamagotchiViewModel()
            {
                Name  = "Test",
                Alive = true
            };

            tr.Add(t);
            HotelRoomViewModel h = new HotelRoomViewModel()
            {
                Size = 5,
                Type = HotelRoomType.Fightroom
            };

            hr.Add(h);
            fc.Add("1", "true,false");
            bc.Create(fc, h);
            Assert.AreEqual(t.ToModel().HotelRoomId, tr.Find(t.Id).HotelRoomId);
            tr.Remove(t);
            hr.Remove(h);
        }
Ejemplo n.º 23
0
        public void Item4_LoadRoomAndTimeSlotByDate()
        {
            var context = new Mock <ControllerContext>();
            var session = new MockHttpSession();

            context.Setup(m => m.HttpContext.Session).Returns(session);

            BookingController bc = new BookingController();

            bc.ControllerContext = context.Object;

            bc.Session["UserName"] = "******";

            BookingViewModel bvmd = new BookingViewModel()
            {
                BookingDate = DateTime.Today
            };

            var result = bc.GetAllRooms(bvmd) as PartialViewResult;

            IEnumerable <BookingViewModel> mds = result.Model as IEnumerable <BookingViewModel>;

            //the count value may be diferent.  At the time for testing this function, there are total 6 Rooms
            Assert.AreEqual(6, mds.Count());
        }
Ejemplo n.º 24
0
        public void Index_ReturnsToCreateBookingPage_WhenUserIsSignedIn()
        {
            var signInManager = new Mock <MockSignInManager>();

            signInManager.Setup(
                s => s.IsSignedIn(null)
                ).Returns(true);

            var controller = new BookingController(new Mock <ILogger <BookingController> >().Object, signInManager.Object, null);

            var model = new BookingViewModel();

            model.ResourceId = Guid.NewGuid();
            model.ServicesId.Add(Guid.NewGuid());
            model.Time = DateTime.Now;

            var result = controller.Index(model);

            Assert.True(controller.ModelState.IsValid);

            var viewResult = Assert.IsType <RedirectToActionResult>(result);

            Assert.Equal("Create", viewResult.ActionName);
            Assert.Equal(model.ResourceId, viewResult.RouteValues["resourceId"]);
            Assert.Equal(model.ServicesId, viewResult.RouteValues["servicesId"]);
            Assert.Equal(model.Time, viewResult.RouteValues["time"]);
        }
Ejemplo n.º 25
0
        public void PostLodgingReviewReturnsValidLodgingReviewBasicInfoModel()
        {
            const int BOOKING_ID         = 2;
            var       lodgingReviewModel = new LodgingReviewModel
            {
                BookingId  = BOOKING_ID,
                Rating     = 2,
                Commentary = "aComment"
            };

            var lodgingReview = lodgingReviewModel.ToEntity();

            lodgingReview.Booking = new Booking
            {
                Tourist = new Tourist
                {
                    Name     = "aName",
                    LastName = "aLastName"
                },
            };
            LodgingReviewLogicMock.Setup(m => m.Create(It.IsAny <LodgingReview>())).Returns(lodgingReview);

            var bookingController = new BookingController(BookingLogicMock.Object, BookingStateLogicMock.Object,
                                                          LodgingReviewLogicMock.Object);
            var result  = bookingController.PostReview(BOOKING_ID, lodgingReviewModel) as CreatedResult;
            var content = result.Value as LodgingReviewBasicInfoModel;

            LodgingReviewLogicMock.VerifyAll();
            Assert.AreEqual(content, new LodgingReviewBasicInfoModel(lodgingReview));
        }
Ejemplo n.º 26
0
        public void Add_MoreTicketsBooked_ReturnsBadResponse()
        {
            //Arrange
            var booking = new Booking()
            {
                BookingId   = 11,
                UserName    = "******",
                ShowId      = 123,
                BookingTime = System.DateTime.Now,
                seats       = 6
            };

            var mockRepo = new Mock <IBookingService>();

            mockRepo.Setup(repo => repo.PostBooking(booking))
            .Returns(_bookingservice.PostBooking(booking));
            var mockRepo_show = new Mock <IMovieService>();

            mockRepo_show.Setup(repo => repo.Getshows())
            .Returns(_movieservice.Getshows());


            _bookingcontroller = new BookingController(mockRepo.Object, mockRepo_show.Object);

            // Act
            var badResponse = _bookingcontroller.PostBooking(booking);

            // Assert
            Assert.IsType <BadRequestObjectResult>(badResponse.Result.Result);
        }
Ejemplo n.º 27
0
        public async Task BookingController_Retrieve_WhenTripDoesNotExist_ShouldReturnNotFound()
        {
            // Arrange
            var tripReference    = StringHelper.RandomString(8);
            var bookingReference = StringHelper.RandomString(6);
            var bookingStatus    = BookingStatus.Initiated;

            _mockBookingRepository
            .Setup(m => m.GetByBookingReferenceAsync(It.IsAny <string>()))
            .ReturnsAsync(TestDataHelper.GetBookingCollection(bookingReference, tripReference, bookingStatus).FirstOrDefault())
            .Verifiable();
            _mockTripRepository
            .Setup(m => m.GetByTripReferenceAsync(It.IsAny <string>()))
            .ReturnsAsync(default(Trip))
            .Verifiable();

            // Act
            var bookingController = new BookingController(_mockTripRepository.Object, _mockBookingRepository.Object, _mockLogger.Object);
            var result            = await bookingController.Retrieve(bookingReference);

            // Assert
            Assert.IsNotNull(result as NotFoundObjectResult);
            _mockBookingRepository.Verify(m => m.GetByBookingReferenceAsync(It.IsAny <string>()), Times.Once);
            _mockTripRepository.Verify(m => m.GetByTripReferenceAsync(It.IsAny <string>()), Times.Once);
        }
Ejemplo n.º 28
0
        public async Task BookingDetailsByID_Returns_A_BookingDetailsViewModel()
        {
            // Arrange
            Booking booking = new Booking();

            booking.BookingID = 1;

            int testId = 1;

            var mock = new Mock <IDelpinHttpClientHandler <Booking> >();

            mock.Setup(m => m.CallHttpGetByID(It.IsAny <string>(), It.IsAny <string>()))
            .ReturnsAsync(booking);

            var sut = new BookingController(Configuration(), mock.Object);

            // Act
            var result = await sut.BookingDetailsByID(testId) as ViewResult;

            // Assert
            var model = Assert.IsType <BookingDetailsViewModel>(result.Model);

            Assert.Equal(booking, model.BookingDetails);
            Assert.Equal(booking.BookingID, model.BookingDetails.BookingID);
        }
        public void AddCow_ExcludePolarLionIsCalled_Test()
        {
            //1. Arrange
            var existingBooking = new Booking {
                ID = 1, Date = DateTime.Now.AddDays(1)
            };
            var list  = new List <Beast>();
            var beast = new Beast {
                Name = "Koe", Type = "Boerderij"
            };

            //list.Add(beast);

            beast.Booking.Add(existingBooking);
            _boekingsRepository.Setup(b => b.TempBooking).Returns(new BookingVM {
                ID = 2, Date = DateTime.Now
            });
            _beastRepository.Setup(b => b.GetAll()).Returns(GetListLion());
            _bookingscontroller = new BookingController(_boekingsRepository.Object, _beastRepository.Object, _accessoryRepository.Object, _contactpersonRepository.Object);


            //2. Act
            _bookingscontroller.AddCheckedAnimal(new BeastVM(beast));

            //3. Assert
            _beastRepository.VerifySet(m => m.ExcludePolarLion = true);
        }
        private void Delete_Click(object sender, System.EventArgs args)
        {
            string id = ((Button)sender).CommandArgument;

            BookingController.GetInstance().DeleteBooking(Int16.Parse(id));
            Response.Redirect("~/Pages/Bookings/SearchBooking.aspx");
        }
Ejemplo n.º 31
0
 public ModelFacade()
 {
     dataAccessFacade = new DataAccessFacade();
     customerController = new CustomerController(dataAccessFacade.GetCustomers());
     saleController = new SaleController(dataAccessFacade.GetSales());
     paymentRuleCatalogController = new PaymentRuleCatalogController(dataAccessFacade.GetPaymentRuleCatalogs());
     paymentContractController = new PaymentContractController(dataAccessFacade.GetPaymentContracts());
     paymentRuleController = new PaymentRuleController(dataAccessFacade.GetPaymentRules());
     bookingController = new BookingController(dataAccessFacade.GetBookings());
     supplierController = new SupplierController(dataAccessFacade.GetSuppliers());
 }
 public DataAccessFacade()
 {
     customerController = new CustomerController();
     saleController = new SaleController();
     paymentRuleCatalogController = new PaymentRuleCatalogController();
     paymentContractController = new PaymentContractController();
     paymentRuleController = new PaymentRuleController();
     bookingController = new BookingController();
     paymentController = new PaymentController();
     supplierController = new SupplierController();
 }
        private void button1_Click(object sender, EventArgs e)
        {
            KundeETO k = new KundeETO(textBox1.Text, textBox2.Text);

            int antalGæster = 0;

            foreach (VærelseETO v in listeVærelser)
            {
                antalGæster += v.Kapacitet;
            }

            BookingController c = new BookingController();
            Boolean status = c.Reserver(new ReservationETO(listeVærelser, antalGæster, k));

            ReservationStatusForm form = new ReservationStatusForm(status);
            form.Show();
        }