public void GetAllTest() { var bookingService = new Mock <IBookingService>(); var mapperMock = new Mock <IMapper>(); var options = Options.Create(new AppSettings() { Secret = "abcE" }); mapperMock.Setup(m => m.Map <Booking, BookingModel>(It.IsAny <Booking>())).Returns(new BookingModel()); bookingService.Setup(b => b.GetAll()).Returns(new List <Booking>() { new Booking() { } }); BookingController controller = new BookingController(null, bookingService.Object, null, mapperMock.Object, options); var response = controller.GetAll(); bookingService.Verify(m => m.GetAll(), Times.Once()); mapperMock.Verify(m => m.Map <IList <BookingModel> >(It.IsAny <IEnumerable <Booking> >()), Times.Once()); }
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); }
private void BookingForm_Load(object sender, EventArgs e) { bookinListBox.DataSource = _bookingController.GetAll(); bookinListBox.SelectedIndex = -1; GetRoomsAvailable(); }
/// <summary> /// the method to retrieve all the booking there is down in the database /// </summary> /// <returns>a list whit all bookings</returns> public IEnumerable <Booking> GetAll( ) { BookingController bookCon = new BookingController(); return(bookCon.GetAll()); }