public async Task ReservationService_CreateAsync_Valid() { // Arrange var reservation = new InputModels.Reservation { AccountId = Guid.NewGuid(), FirstName = "Test", LastName = "User", Notes = "Test Note", ReservationTimeUtc = DateTime.UtcNow, RestaurantName = "Test Restaurant", TotalPatrons = 8 }; this._reservationProvider .Setup(x => x.GetWithinRange(reservation.AccountId, reservation.ReservationTimeUtc)) .ReturnsAsync(new Collection <Reservation>()); var reservationService = new ReservationService(this._reservationProvider.Object); // Act var result = await reservationService.CreateAsync(reservation); Assert.IsNotNull(result); Assert.AreEqual(reservation.AccountId, result.AccountId); Assert.AreEqual(reservation.FirstName, result.FirstName); Assert.AreEqual(reservation.LastName, result.LastName); Assert.AreEqual(reservation.Notes, result.Notes); Assert.AreEqual(reservation.ReservationTimeUtc, result.ReservationTimeUtc); Assert.AreEqual(reservation.RestaurantName, result.RestaurantName); Assert.AreEqual(reservation.TotalPatrons, result.TotalPatrons); }
public async Task ReservationService_CreateAsync_Conflicting_Reservation() { // Arrange var reservation = new InputModels.Reservation { AccountId = Guid.NewGuid(), FirstName = "Test", LastName = "User", Notes = "Test Note", ReservationTimeUtc = DateTime.UtcNow, RestaurantName = "Test Restaurant", TotalPatrons = 8 }; this._reservationProvider .Setup(x => x.GetWithinRange(reservation.AccountId, reservation.ReservationTimeUtc)) .ReturnsAsync(new Collection <Reservation>() { new Reservation(Guid.NewGuid()) }); var reservationService = new ReservationService(this._reservationProvider.Object); // Act var result = await reservationService.CreateAsync(reservation); // Assert Assert.Fail("Expected exception was not thrown"); }
public async Task ReservationService_CreateAsync_Model_Null() { // Arrange var reservationService = new ReservationService(this._reservationProvider.Object); // Act await reservationService.CreateAsync(null); // Assert Assert.Fail("Expected exception was not thrown"); }
public void ReservationService_Create_Reservation_Verify() { //arrange var reservation = new Reservation { Id = Guid.NewGuid().ToString(), Name = "Special Meeting", RoomId = "101", FromDate = DateTime.Today.ToString(), ToDate = DateTime.Today.AddDays(1).ToString(), Price = 1 }; _mockRepo.Setup(x => x.InsertAsync(It.IsAny <Reservation>())).Verifiable(); var reservationSvc = new ReservationService(_mockRepo.Object); //act var result = reservationSvc.CreateAsync(reservation); //assert _mockRepo.Verify(); }
public async Task <ActionResult <Reservation> > Create(Reservation reservation) { await _reservationService.CreateAsync(reservation); return(CreatedAtRoute("GetReservation", new { id = reservation.Id.ToString() }, reservation)); }