// gennemgå metode
        private void btn_createBooking_Click(object sender, EventArgs e)
        {
            List <Service> services     = new List <Service>();
            List <Product> products     = new List <Product>();
            DateTime       selectedDate = dateTimePicker.Value.Date.AddTicks(((TimeSpan)lb_availabletimes.SelectedItem).Ticks);

            foreach (ListViewItem item in lv_services.CheckedItems)
            {
                services.Add((Service)item.Tag);
            }
            foreach (ListViewItem item in lv_products.CheckedItems)
            {
                products.Add((Product)item.Tag);
            }
            Booking booking = new Booking(1, ((Employee)lb_employee.SelectedItem).EmployeeId, selectedDate, getDuration(), GetTotalPrice(), "Dette er en test kommentar fra DesktopClient", services, products);

            bookingsController.Create(booking);
            lb_availabletimes.DataSource = null;
            foreach (ListViewItem service in lv_services.CheckedItems)
            {
                service.Checked = false;
            }
            foreach (ListViewItem product in lv_products.CheckedItems)
            {
                product.Checked = false;
            }
            btn_createBooking.Enabled = false;
        }
        public void Create_ShowsCorrectView()
        {
            var result = Controller.Create();

            Assert.IsType <ViewResult>(result);
            //var viewResult = result as ViewResult;
            //Assert.Null(viewResult.ViewName);
        }
Beispiel #3
0
        public async void TryAddBooking_1()
        {
            Car      car  = _context.Cars.Single(x => x.LicenseNumber == "ABC123");
            Customer dude = _context.Customers.Single(x => x.FirstName == "Georg" && x.LastName == "Fälemark");

            Booking input = new Booking {
                StartDate = new DateTime(2019, 01, 04), CarId = car.CarId, CustomerId = dude.CustomerId
            };
            await _bookingsController.Create(input);



            //Task<IActionResult> expected;

            //hur ska man göra här för att få ett expected?
            //Assert.AreEqual(expected, result);
        }
        public void Create_WithAnyCreate_ReturnTrue()
        {
            // Act
            Booking booking = new Booking();

            booking.CustomerId = 1;
            var result             = controller.Create(booking) as ViewResult;
            var bookingExpected    = result.Model as Booking;
            var ConsumerIdExpected = bookingExpected.CustomerId;

            // Assert
            Assert.Equal(booking.CustomerId, ConsumerIdExpected);
            // fakeBookingRepository.Verify(x => x.Add(It.IsAny<Booking>()), Times.Once);
        }
Beispiel #5
0
        public void CreateTest()
        {
            Room room = new Room()
            {
                Name  = "zeemans suite",
                Price = 200.00m,
                Size  = 2,
                Image = "https://www.google.com/url?sa=i&source=images&cd=&cad=rja&uact=8&ved=2ahUKEwjhxafnnvXgAhUBL1AKHVpqBOIQjRx6BAgBEAU&url=http%3A%2F%2Fwww.bestwesternplusmeridian.com%2Fhotel-rooms&psig=AOvVaw3w593gpqrXk-U5R3J0-aQU&ust=1552227094093805"
            };

            _mockRoomRepo.Setup(x => x.Find(1)).Returns(room);
            var result = _bookingController.Create(1) as ViewResult;
            var vm     = (BookingViewModel)result.Model;

            Assert.AreEqual(room, vm.Room);
        }
        public void Create_WithInvalidHomeId_ShouldReturnNotFoundReult()
        {
            //Arrange
            var homeService = HomeServiceMock.New;

            homeService
            .Setup(hs => hs.Exists(It.IsAny <int>()))
            .Returns(false);

            var controller = new BookingsController(null, homeService.Object, null);

            //Act
            var result = controller.Create(It.IsAny <int>());

            //Assert
            result
            .Should()
            .BeOfType <NotFoundResult>();
        }
        public void Create_WithValidHomeId_ShouldReturnViewResult()
        {
            //Arrange
            var homeService = HomeServiceMock.New;

            homeService
            .Setup(hs => hs.Exists(It.IsAny <int>()))
            .Returns(true);

            var controller = new BookingsController(null, homeService.Object, null);

            var tempDataMock = new Mock <TempDataDictionary>(new Mock <HttpContext>().Object, new Mock <ITempDataProvider>().Object);

            controller.TempData = tempDataMock.Object;

            //Act
            var result = controller.Create(It.IsAny <int>());

            //Assert
            result
            .Should()
            .BeOfType <ViewResult>();
        }
        public async Task Create_WhenCalled_CreateNewBookingAndRedirectToIndex()
        {
            // Arrange
            var model = new BookingCreateViewModel
            {
                FirstName     = "Joseph",
                LastName      = "A",
                Mobile        = "123456789",
                DateBooked    = new DateTime(2020, 12, 21),
                TimeBooked    = "13:30",
                NumberinParty = 3,
                Status        = 1,
                Method        = 2,
                TableNo       = 1,
            };

            // Act
            var result = await controller.Create(model) as RedirectToActionResult;

            // Assert
            Assert.That(result.RouteValues.Count, Is.EqualTo(1));
            Assert.That(result.ActionName, Is.EqualTo("details"));
        }