Ejemplo n.º 1
0
        private static async Task <UserDTO> CreateReader(HttpClient client)
        {
            var command = new CreateReaderCommand()
            {
                FirstName = "FirstName",
                LastName  = "LastName",
                Email     = "*****@*****.**",
                Password  = "******"
            };
            var response = await client.PostAsJsonAsync("api/readers/", command);

            return(await response.Content.ReadFromJsonAsync <UserDTO>());
        }
Ejemplo n.º 2
0
        public async Task Handle_ValidCommand_ReaderCreated()
        {
            var command = new CreateReaderCommand()
            {
                FirstName = "FirstName",
                LastName  = "LastName",
                Email     = "*****@*****.**",
                Password  = "******"
            };

            await _sut.Handle(command, CancellationToken.None);

            _userServiceMock.Verify(x => x.Register(It.IsAny <RegisterUserModel>()), Times.Once);
        }
        public void Validate_EmptyName_ContainError()
        {
            var command = new CreateReaderCommand()
            {
                FirstName = "",
                LastName  = "LastName",
                Password  = "******",
                Email     = "*****@*****.**"
            };

            var result = _sut.Validate(command);

            result.IsValid.Should().BeFalse();
        }
        public void Validate_ValidCommand_NoErrors()
        {
            var command = new CreateReaderCommand()
            {
                FirstName = "FirstName",
                LastName  = "LastName",
                Password  = "******",
                Email     = "*****@*****.**"
            };

            var result = _sut.Validate(command);

            result.IsValid.Should().BeTrue();
            result.Errors.Should().BeEmpty();
        }
Ejemplo n.º 5
0
        public async Task CreateReader_ReaderUser_Forbidden()
        {
            // Arrange
            var claimsProvider = TestClaimsProvider.WithReaderClaims();
            var client         = Factory.CreateClientWithTestAuth(claimsProvider);

            // Act
            var content = new CreateReaderCommand()
            {
                FirstName = "FirstName",
                LastName  = "LastName",
                Email     = "*****@*****.**",
                Password  = "******"
            };
            var response = await client.PostAsJsonAsync("api/readers/", content);

            // Assert
            response.StatusCode.Should().Be(HttpStatusCode.Forbidden);
        }
Ejemplo n.º 6
0
        public async Task <ActionResult <UserDTO> > CreateReader(CreateReaderCommand command)
        {
            var user = await _mediator.Send(command);

            return(Ok(user));
        }