public RegisterNewUserCommandShould()
 {
     registerModel = new RegisterModel
     {
         Email           = EMAIL,
         Password        = PASSWORD,
         ConfirmPassword = PASSWORD
     };
     userServiceMock = new Mock <IUserService>();
     userServiceMock
     .Setup(u => u.CreateUser(It.IsAny <PlannerAppUser>(), It.IsAny <string>()))
     .Callback <PlannerAppUser, string>((PlannerAppUser user, string password) =>
     {
         this.user = user;
     })
     .Returns(Task.FromResult(IdentityResult.Success));
     sut = new RegisterNewUserCommand(userServiceMock.Object);
 }
        public void ReturnIsSuccessfulEqualsFalseWithErrors()
        {
            // Arrange
            var failResult = IdentityResult.Failed(new IdentityError()
            {
                Code = "code", Description = "desc"
            });

            userServiceMock
            .Setup(u => u.CreateUser(It.IsAny <PlannerAppUser>(), It.IsAny <string>()))
            .Returns(Task.FromResult(failResult));
            sut = new RegisterNewUserCommand(userServiceMock.Object);
            // Act
            var result = sut.Execute(registerModel).Result;

            // Assert
            Assert.False(result.IsSuccessful);
            Assert.Single(result.Errors);
            Assert.Equal("desc", result.Errors.First().Value);
        }