Beispiel #1
0
        public IActionResult Login(string username, string password)
        {
            var user = _userQueryables.GetByUsername(username);

            if (user.Password == password)
            {
                return(Ok());
            }
            else
            {
                return(BadRequest());
            }
        }
Beispiel #2
0
        public void UserController_Create_IUnitOfWork(
            [Frozen] IUnitOfWork unitOfWork,
            [Frozen] IUserQueryables userQueryables,
            User user,
            UserController userController)
        {
            //Information
            A.CallTo(() => userQueryables.GetByUsername(A <string> .Ignored)).Returns(null);
            A.CallTo(() => userQueryables.GetByMail(A <string> .Ignored)).Returns(null);

            //Act
            userController.Create(user);

            //Test
            A.CallTo(() => unitOfWork.Complete())
            .MustHaveHappenedOnceExactly();
        }
Beispiel #3
0
        public void UserController_Create_createUserCommandHandler(
            [Frozen] ICommandHandler <CreateUserCommand> createUserCommandHandler,
            [Frozen] IUserQueryables userQueryables,
            User user,
            UserController userController)
        {
            //Information
            A.CallTo(() => userQueryables.GetByUsername(A <string> .Ignored)).Returns(null);
            A.CallTo(() => userQueryables.GetByMail(A <string> .Ignored)).Returns(null);
            //Act
            userController.Create(user);

            //Test
            A.CallTo(() => createUserCommandHandler
                     .ExecuteAsync(A <CreateUserCommand> .Ignored))
            .MustHaveHappened();
        }
Beispiel #4
0
        public void UserController_Create_WithAlreadyExistingEmail(
            [Frozen] IUnitOfWork unitOfWork,
            [Frozen] IUserQueryables userQueryables,
            UserDto userDto,
            User user,
            UserController userController)
        {
            //Information
            A.CallTo(() => userQueryables.GetByUsername(A <string> .Ignored)).Returns(userDto);
            A.CallTo(() => userQueryables.GetByMail(A <string> .Ignored)).Returns(null);

            //Act
            userController.Create(user);

            //Test
            A.CallTo(() => unitOfWork.Complete())
            .MustNotHaveHappened();
        }