public async Task Then_Sets_Owner_Users_On_ViewModel(
            ReservationsRouteModel routeModel,
            GetAccountUsersResponse usersResponse,
            long decodedAccountId,
            [Frozen] Mock <IMediator> mockMediator,
            [Frozen] Mock <IEncodingService> mockEncodingService,
            EmployerReservationsController controller)
        {
            usersResponse.AccountUsers.First().Role = "Owner";
            mockEncodingService
            .Setup(service => service.Decode(
                       routeModel.EmployerAccountId,
                       EncodingType.AccountId))
            .Returns(decodedAccountId);
            mockMediator
            .Setup(mediator => mediator.Send(
                       It.IsAny <GetAccountUsersQuery>(),
                       It.IsAny <CancellationToken>()))
            .ReturnsAsync(usersResponse);

            var result = await controller.TransactorSignAgreement(routeModel) as ViewResult;

            var model = result.Model as SignAgreementViewModel;

            model.OwnersOfThisAccount.Should().BeEquivalentTo(usersResponse.AccountUsers
                                                              .Where(user => user.Role.Equals(EmployerUserRole.Owner.ToString(), StringComparison.InvariantCultureIgnoreCase))
                                                              .OrderBy(user => user.Name)
                                                              .Select(user => (EmployerAccountUserViewModel)user));
        }
예제 #2
0
        public async Task NoUsersReturned()
        {
            var response = new GetAccountUsersResponse();

            _mediator.Setup(m => m.Send(It.IsAny <GetAccountUsersQuery>(), It.IsAny <CancellationToken>())).ReturnsAsync(response);
            var result = (await _sut.GetAccountUsers(12345)).ToArray();

            result.Length.Should().Be(0);
        }
예제 #3
0
        public async Task Then_The_Api_Is_Called_With_The_Request_And_The_AccountUsers_Are_Returned(
            GetAccountUsersQuery query,
            GetAccountUsersResponse apiResponse,
            [Frozen] Mock <IAccountsApiClient <AccountsConfiguration> > apiClient,
            GetAccountUsersQueryHandler handler
            )
        {
            apiClient.Setup(x => x.Get <GetAccountUsersResponse>(It.Is <GetAccountUsersRequest>(x => x.HashedAccountId == query.HashedAccountId))).ReturnsAsync(apiResponse);

            var actual = await handler.Handle(query, CancellationToken.None);

            actual.Should().BeEquivalentTo(apiResponse);
        }
예제 #4
0
        public async Task UserShouldReceiveEmailIfNotSettings()
        {
            var response = new GetAccountUsersResponse();

            response.Add(_fixture.Build <User>().With(m => m.UserRef, "userRef1").Create(), null);
            response.Add(_fixture.Build <User>().With(m => m.UserRef, "userRef2").Create(), _fixture.Build <UserSetting>().With(m => m.ReceiveNotifications, false).Create());

            _mediator.Setup(m => m.Send(It.IsAny <GetAccountUsersQuery>(), It.IsAny <CancellationToken>())).ReturnsAsync(response);
            var result = (await _sut.GetAccountUsers(12345)).ToArray();

            result.Length.Should().Be(2);
            result[0].UserRef.Should().Be("userRef1");
            result[0].ReceiveNotifications.Should().BeTrue();
            result[1].UserRef.Should().Be("userRef2");
            result[1].ReceiveNotifications.Should().BeFalse();
        }
예제 #5
0
        public async Task ShouldReturnUsers()
        {
            var response = new GetAccountUsersResponse();

            response.Add(_superUser, _fixture.Build <UserSetting>().With(m => m.ReceiveNotifications, true).Create());
            response.Add(_normalUser, _fixture.Build <UserSetting>().With(m => m.ReceiveNotifications, false).Create());

            _mediator.Setup(m => m.Send(It.IsAny <GetAccountUsersQuery>(), It.IsAny <CancellationToken>())).ReturnsAsync(response);
            var result = (await _sut.GetAccountUsers(12345)).ToArray();

            result.Length.Should().Be(2);
            result[0].UserRef.Should().Be(_superUser.UserRef);
            result[0].ReceiveNotifications.Should().BeTrue();
            result[0].IsSuperUser.Should().BeTrue();
            result[0].DisplayName.Should().Be(_superUser.DisplayName);
            result[1].UserRef.Should().Be(_normalUser.UserRef);
            result[1].ReceiveNotifications.Should().BeFalse();
            result[1].IsSuperUser.Should().BeFalse();
            result[1].DisplayName.Should().Be(_normalUser.DisplayName);
        }
        public async Task Then_Sets_The_IsUrl_Property_If_Come_From_Select_Reservation(
            ReservationsRouteModel routeModel,
            GetAccountUsersResponse usersResponse,
            [Frozen] Mock <IMediator> mockMediator,
            EmployerReservationsController controller)
        {
            mockMediator
            .Setup(mediator => mediator.Send(
                       It.IsAny <GetAccountUsersQuery>(),
                       It.IsAny <CancellationToken>()))
            .ReturnsAsync(usersResponse);
            routeModel.IsFromSelect = true;

            var result = await controller.TransactorSignAgreement(routeModel) as ViewResult;

            result.ViewName.Should().Be("TransactorSignAgreement");
            var model = result.Model as SignAgreementViewModel;

            model.BackRouteName.Should().Be(routeModel.PreviousPage);
            model.IsUrl.Should().BeTrue();
        }