Exemplo n.º 1
0
        public async void given_disable_single_user_command_command_dispatcher_should_get_same_command_created_in_controller()
        {
            //Assemble
            var mockAgg = new UserControllerMockAggregate();

            var id     = new Guid();
            var userId = new Guid();

            var input = new DisableUserInputDTO()
            {
                ById   = id,
                UserId = userId
            };

            var command = new DisableSingleUserCommand(input);

            mockAgg.setup_dispatcher_to_verify_disableSingleUserCommands_are_the_same(command);

            var controller = mockAgg.CreateUserController();

            //Apply
            var result = await controller.DisableUser(input);

            //Assert
            Assert.IsType <UserDTO>(result);
            Assert.Equal(result.Id, input.UserId);
        }
Exemplo n.º 2
0
        public async void given_update_user_command_command_dispatcher_should_get_same_command_created_in_controller()
        {
            //Assemble
            var mockAgg = new UserControllerMockAggregate();

            var id = new Guid();

            var input = new UpdateUserInformationDTO()
            {
                ForID     = id,
                FirstName = "testFName",
                LastName  = "testLName"
            };

            var command = new UpdateSingleUserCommand(input.ForID, input);

            mockAgg.setup_dispatcher_to_verify_updateUserInformationCommands_are_the_same(command);

            var controller = mockAgg.CreateUserController();

            //Apply
            var result = await controller.UpdateUser(input);

            //Assert
            Assert.IsType <UpdateUserInformationDTO>(result);
            Assert.Equal(result.FirstName, input.FirstName);
            Assert.Equal(result.LastName, input.LastName);
            Assert.Equal(result.ForID, input.ForID);
        }
Exemplo n.º 3
0
        public async void given_GetLoginUsersQuery_queryprocessor_should_get_same_query_created_in_controller()
        {
            //Assemble
            var mockAgg = new UserControllerMockAggregate();

            mockAgg.setup_processor_to_verify_getLoginUsersQueries_are_the_same();

            var controller = mockAgg.CreateUserController();

            //Apply
            var result = await controller.GetLoginUsers();

            //Assert
            //Assert.Equal(query, mockAgg.PermissionQuery);
            Assert.IsType <List <LoginUserDTO> >(result);
        }
Exemplo n.º 4
0
        public async void given_get_user_collection_query_queryprocessor_should_get_same_query_created_in_controller()
        {
            //Assemble
            var mockAgg = new UserControllerMockAggregate();

            mockAgg.setup_processor_to_verify_getUserCollectionQueries_are_the_same();

            var controller = mockAgg.CreateUserController();

            var filter = new UserFilterCriteria();

            //Apply
            var result = await controller.GetUserCollection(filter);

            //Assert
            Assert.IsType <List <UserDetailProjectionDTO> >(result);
        }
Exemplo n.º 5
0
        public async void given_GetSystemDashboardQuery_queryprocessor_should_get_same_query_created_in_controller()
        {
            //Assemble
            var mockAgg = new UserControllerMockAggregate();

            var input = new DashboardFilterCriteria();

            mockAgg.setup_processor_to_verify_getSystemDashboardQueries_are_the_same();

            var controller = mockAgg.CreateUserController();

            //Apply
            var result = await controller.GetSystemDashboard(input);

            //Assert
            //Assert.Equal(query, mockAgg.PermissionQuery);
            Assert.IsType <List <DashboardProjection> >(result);
        }
Exemplo n.º 6
0
        public async void given_revokeuserpermissionscommand_command_dispatcher_should_get_same_command_created_in_controller()
        {
            //Assemble
            var mockAgg = new UserControllerMockAggregate();

            var id       = new Guid();
            var userId   = new Guid();
            var requests = new Dictionary <Guid, PermissionDetails>
            {
                {
                    new Guid(), new PermissionDetails
                    {
                        EventType    = "testEvent",
                        IsPending    = true,
                        Reason       = "testReason",
                        RequestedBy  = id,
                        RequestedFor = userId,
                        RequestDate  = new DateTime()
                    }
                }
            };

            var input = new RevokeUserPermissionDTO()
            {
                ById  = id,
                ForId = userId,
                PermissionsToRevoke = requests
            };

            var command = new RevokeUserPermissionCommand(input);

            mockAgg.setup_dispatcher_to_verify_revokeUserPermissionRequestCommands_are_the_same(command);

            var controller = mockAgg.CreateUserController();

            //Apply
            var result = await controller.RevokePermission(input);

            //Assert
            Assert.IsType <UserDTO>(result);
            Assert.Equal(result.Id, input.ForId);
            Assert.Equal(result.PermissionList, input.PermissionsToRevoke);
        }
Exemplo n.º 7
0
        public async void given_getoffboarduserpermissionsquery_queryprocessor_should_get_same_query_created_in_controller()
        {
            //Assemble
            var mockAgg = new UserControllerMockAggregate();

            var id    = new Guid();
            var query = new GetOffboardUserPermissionsQuery(id);

            mockAgg.setup_processor_to_verify_getUserOffboardingQueries_are_the_same();

            var controller = mockAgg.CreateUserController();

            //Apply

            var result = await controller.GetOffBoardingPermissionsById(id);

            //Assert
            //Assert.Equal(query, mockAgg.PermissionQuery);
            Assert.IsType <OffBoardUserDTO>(result);
        }
Exemplo n.º 8
0
        public async void given_GetApproverActicityProjectionQuery_queryprocessor_should_get_same_query_created_in_controller()
        {
            //Assemble
            var mockAgg = new UserControllerMockAggregate();

            var input = new ApproverActivityFilterCriteria();
            var query = new GetApproverActicityProjectionQuery
            {
                FilterCriteria = input
            };

            mockAgg.setup_processor_to_verify_getApproverActivityQueries_are_the_same();

            var controller = mockAgg.CreateUserController();

            //Apply

            var result = await controller.GetApproverAtivityProjection(input);

            //Assert
            //Assert.Equal(query, mockAgg.PermissionQuery);
            Assert.IsType <List <ApproverActivityProjection> >(result);
        }
Exemplo n.º 9
0
        public async void given_getuserbyid_query_queryprocessor_should_get_same_query_created_in_controller()
        {
            //Assemble
            var mockAgg = new UserControllerMockAggregate();

            var id    = new Guid();
            var query = new GetPermissionByIdQuery(id);

            mockAgg.setup_processor_to_verify_getUserQueries_are_the_same(id);

            var controller = mockAgg.CreateUserController();

            //Apply

            var result = await controller.Get(id);

            var projection = new UserDetailProjection()
            {
                FirstName      = "Test",
                LastName       = "Name",
                IsActive       = true,
                IsAdmin        = true,
                Department     = "Testeeee",
                Position       = "Deper",
                Email          = "*****@*****.**",
                DateCreated    = new DateTime(),
                UserId         = new Guid(),
                PermissionList = "Permissions Here",
            };

            var newProjection = new UserDetailProjection()
            {
                FirstName      = projection.FirstName,
                LastName       = projection.LastName,
                IsActive       = projection.IsActive,
                IsAdmin        = projection.IsAdmin,
                Department     = projection.Department,
                Position       = projection.Position,
                Email          = projection.Email,
                DateCreated    = projection.DateCreated,
                UserId         = projection.UserId,
                PermissionList = projection.PermissionList
            };

            //await projection.ListenForEvents(new UserCreatedEvent
            //{
            //    FirstName = projection.FirstName,
            //    LastName = projection.LastName,
            //    IsActive = projection.IsActive,
            //    IsAdmin = projection.IsAdmin,
            //    Department = projection.Department,
            //    Position = projection.Position,
            //    Email = projection.Email,
            //    Id = projection.UserId,
            //    PermissionList = new Dictionary<Guid, PermissionDetails>()
            //});

            //await projection.ListenForEvents(new UserUpdatedEvent
            //{
            //    FirstName = projection.FirstName,
            //    LastName = projection.LastName,
            //    IsAdmin = projection.IsAdmin,
            //    Department = projection.Department,
            //    Position = projection.Position,
            //    Email = projection.Email,
            //    Id = projection.UserId,
            //});
            //await projection.ListenForEvents(new UserPermissionGrantedEvent());
            //await projection.ListenForEvents(new UserPermissionRequestDeniedEvent());
            //await projection.ListenForEvents(new UserPermissionRevokedEvent());
            //await projection.ListenForEvents(new UserDisabledEvent());
            //await projection.ListenForEvents(new UserEnabledEvent());

            //Assert
            //Assert.Equal(query, mockAgg.PermissionQuery);
            Assert.IsType <UserDetailProjectionDTO>(result);
            Assert.Equal(result.UserId, id);
        }