コード例 #1
0
        public void CadastrarUsuarioValido()
        {
            // Arrange
            var controller  = new AutenticacaoController();
            var novoUsuario = new UserCreateDTO
            {
                Username = "******",
                Password = "******"
            };

            // Act
            var response = controller.CreateUser(novoUsuario) as OkResult;
            var expected = (int)HttpStatusCode.OK;

            // Assert
            Assert.NotNull(response);
            Assert.Equal(expected, response.StatusCode);
        }
コード例 #2
0
        public void CadastrarUsuarioInvalido()
        {
            // Arrange
            var controller = new AutenticacaoController();

            Startup.createdUsers.Add(new User {
                Username = "******", Password = "******"
            });
            var novoUsuario = new UserCreateDTO
            {
                Username = "******",
                Password = ""
            };

            // Act
            var response = controller.CreateUser(novoUsuario) as BadRequestResult;
            var expected = (int)HttpStatusCode.BadRequest;

            // Assert
            Assert.NotNull(response);
            Assert.Equal(expected, response.StatusCode);
        }