public void ConfirmReservation_ExpireConfirmDate_FalseResult() { var confirmReservation = new ConfirmReservation { Id = 1, Guid = Guid.Parse("11111111-1111-1111-1111-111111111111"), ExpireDate = new DateTime(2008, 11, 11, 8, 0, 0, DateTimeKind.Unspecified), IsConfirm = false }; // arrange var confirmReservationManagerMock = new Mock <IConfirmReservation>(); confirmReservationManagerMock.Setup(m => m.Get(It.IsAny <Guid>())).Returns(confirmReservation); var unitOfWorkMock = new Mock <IUnitOfWork>(); unitOfWorkMock.Setup(m => m.ConfirmReservationManager).Returns(confirmReservationManagerMock.Object); var clockMock = new Mock <IClock>(); clockMock.Setup(m => m.CurentUtcDateTime()).Returns(new DateTime(2008, 11, 11, 8, 0, 0, DateTimeKind.Utc).AddMinutes(1)); var reservationService = new ReservationService(unitOfWorkMock.Object, clockMock.Object); // act var actual = reservationService.Confirm(Guid.Parse("11111111-1111-1111-1111-111111111111")); // assert actual.Should().NotBeNull(); actual.Succedeed.Should().BeFalse(); actual.Message.Should().Be("Error guid or time extire"); }
public void ConfirmReservation_TrueGuid_ConfirmReservation() { var confirmReservation = new ConfirmReservation { Id = 1, Guid = Guid.Parse("11111111-1111-1111-1111-111111111111"), ExpireDate = new DateTime(2008, 11, 11, 8, 0, 0, DateTimeKind.Unspecified), IsConfirm = false }; // arrange var confirmReservationManagerMock = new Mock <IConfirmReservation>(); confirmReservationManagerMock.Setup(m => m.Get(It.IsAny <Guid>())).Returns(confirmReservation); confirmReservationManagerMock.Setup(m => m.Update(It.IsAny <ConfirmReservation>())).Verifiable(); var unitOfWorkMock = new Mock <IUnitOfWork>(); unitOfWorkMock.Setup(m => m.ConfirmReservationManager).Returns(confirmReservationManagerMock.Object); var clockMock = new Mock <IClock>(); clockMock.Setup(m => m.CurentUtcDateTime()).Returns(new DateTime(2008, 11, 11, 8, 0, 0, DateTimeKind.Utc)); var reservationService = new ReservationService(unitOfWorkMock.Object, clockMock.Object); // act var actual = reservationService.Confirm(Guid.Parse("11111111-1111-1111-1111-111111111111")); // assert actual.Should().NotBeNull(); confirmReservationManagerMock.VerifyAll(); actual.Succedeed.Should().BeTrue(); }
public IActionResult Confirm(ConfirmReservationsRequest request) { try { List <Reservation> confirmedReservations = ReservationService.Confirm(request.ConfirmationID); List <object> slots = new List <object>(); foreach (Reservation reservation in confirmedReservations) { slots.Add(new { year = reservation.Year, monthIndex = reservation.MonthIndex, dayIndex = reservation.DayIndex, slotIndex = reservation.SlotIndex }); } return(this.MakeSuccess(new { slots = slots })); } catch (KeyNotFoundException) { return(this.MakeFailure("No such confirmation found.", StatusCodes.Status404NotFound)); } }
public void ConfirmReservation_NonexistentGUIDParameter_FalseResult() { // arrange var confirmReservationManagerMock = new Mock <IConfirmReservation>(); confirmReservationManagerMock.Setup(m => m.Get(It.IsAny <Guid>())).Returns((ConfirmReservation)null); var unitOfWorkMock = new Mock <IUnitOfWork>(); unitOfWorkMock.Setup(m => m.ConfirmReservationManager).Returns(confirmReservationManagerMock.Object); var clockMock = new Mock <IClock>(); var reservationService = new ReservationService(unitOfWorkMock.Object, clockMock.Object); // act var actual = reservationService.Confirm(Guid.Parse("11111111-1111-1111-1111-111111111111")); // assert actual.Should().NotBeNull(); actual.Succedeed.Should().BeFalse(); actual.Message.Should().Be("Error guid or time extire"); }