public async Task Then_If_The_Reservation_Is_For_Levy_The_Event_Is_Created_With_Min_Dates()
        {
            //Arrange
            _command.IsLevyAccount = true;
            _command.StartDate     = null;
            _reservationCreated    = new Reservation(null, _expectedReservationId, ExpectedAccountId, true, DateTime.UtcNow,
                                                     null, null, ReservationStatus.Pending, new Course
            {
                CourseId = "1",
                Level    = 1,
                Title    = "Test Course"
            }, null, 198, "TestName", 0, null);
            _accountReservationsService
            .Setup(x => x.CreateAccountReservation(_command))
            .ReturnsAsync(_reservationCreated);
            _handler = new CreateAccountReservationCommandHandler(_accountReservationsService.Object, _validator.Object, _globalRulesService.Object, _unitOfWork.Object, _accountLegalEntitiesService.Object);

            //Act
            await _handler.Handle(_command, _cancellationToken);

            //Assert
            _unitOfWork.Verify(x => x.AddEvent(It.Is <Func <ReservationCreatedEvent> >(c =>
                                                                                       c.Invoke().Id.Equals(_expectedReservationId) &&
                                                                                       c.Invoke().AccountLegalEntityId.Equals(_reservationCreated.AccountLegalEntityId) &&
                                                                                       c.Invoke().AccountLegalEntityName.Equals(_reservationCreated.AccountLegalEntityName) &&
                                                                                       c.Invoke().StartDate.Equals(DateTime.MinValue) &&
                                                                                       c.Invoke().EndDate.Equals(DateTime.MinValue) &&
                                                                                       c.Invoke().CreatedDate.Equals(_reservationCreated.CreatedDate) &&
                                                                                       c.Invoke().AccountId.Equals(_reservationCreated.AccountId)
                                                                                       )), Times.Once);
        }
        public void Arrange()
        {
            _cancellationToken = new CancellationToken();

            _reservationCreated = new Reservation(null, _expectedReservationId, ExpectedAccountId, false, DateTime.UtcNow,
                                                  DateTime.UtcNow.AddMonths(1), DateTime.UtcNow.AddMonths(3), ReservationStatus.Pending, new Course
            {
                CourseId = "1",
                Level    = 1,
                Title    = "Test Course"
            }, ExpectedProviderId, 198, "TestName", 0, null);

            _validator = new Mock <IValidator <CreateAccountReservationCommand> >();
            _validator.Setup(x => x.ValidateAsync(It.IsAny <CreateAccountReservationCommand>()))
            .ReturnsAsync(new ValidationResult {
                ValidationDictionary = new Dictionary <string, string> {
                    { "", "" }
                }
            });
            _validator.Setup(x => x.ValidateAsync(
                                 It.Is <CreateAccountReservationCommand>(c => c.Id.Equals(_expectedReservationId))))
            .ReturnsAsync(new ValidationResult());

            _globalRulesService = new Mock <IGlobalRulesService>();
            _globalRulesService.Setup(x => x.GetActiveRules(It.IsAny <DateTime>()))
            .ReturnsAsync(new List <GlobalRule>());

            _command = new CreateAccountReservationCommand
            {
                Id                     = _expectedReservationId,
                AccountId              = ExpectedAccountId,
                AccountLegalEntityId   = 198,
                AccountLegalEntityName = "TestName",
                StartDate              = _expectedStartDate,
                CreatedDate            = _expectedExpiryDate,
                ProviderId             = ExpectedProviderId
            };

            _accountReservationsService = new Mock <IAccountReservationService>();
            _accountReservationsService
            .Setup(x => x.CreateAccountReservation(_command))
            .ReturnsAsync(_reservationCreated);

            _accountLegalEntitiesService = new Mock <IAccountLegalEntitiesService>();
            _expectedAccountLegalEntity  = new AccountLegalEntity(Guid.NewGuid(), _command.AccountId, "Test Name 2", 1, _command.AccountLegalEntityId, true, true);
            _accountLegalEntitiesService.Setup(x => x.GetAccountLegalEntity(_command.AccountLegalEntityId))
            .ReturnsAsync(_expectedAccountLegalEntity);

            _unitOfWork = new Mock <IUnitOfWorkContext>();

            _handler = new CreateAccountReservationCommandHandler(_accountReservationsService.Object, _validator.Object, _globalRulesService.Object, _unitOfWork.Object, _accountLegalEntitiesService.Object);
        }