コード例 #1
0
        public async Task <GetUserByCredentialsResult> Handle(GetUserByCredentials data, CancellationToken cancellationToken)
        {
            var result = await repository.GetUserByCredentials(new Model.DAL.Access.Users.GetUserByCredentialsModel
            {
                Email    = data.Email,
                Password = data.Password
            });

            if (!result.IsSuccessful)
            {
                return(new GetUserByCredentialsResult(result.Error));
            }

            return(new GetUserByCredentialsResult
            {
                User = new UserModel
                {
                    Code = result.Model.Code,
                    DisplayName = result.Model.DisplayName,
                    UserName = result.Model.UserName,
                    Email = result.Model.Email,
                    ImageUrl = result.Model.ImageUrl,
                    UserId = result.Model.UserId
                }
            });
        }
コード例 #2
0
        public async Task NotGetUserForInvalidCredentials()
        {
            await CreateUser("*****@*****.**", "pass12");

            var handler = Fixture.GetService <IGetUserByCredentialsHandler>();

            var request = new GetUserByCredentials
            {
                Email    = "*****@*****.**",
                Password = "******"
            };

            var result = await handler.Handle(request, new System.Threading.CancellationToken());

            Assert.False(result.IsSuccessful);
            Assert.Equal(AccessErrors.InvalidUserCredentials, result.Error);
            Assert.Null(result.User);
        }
コード例 #3
0
        public async Task GetExistingUserData()
        {
            await CreateUser("*****@*****.**", "pass12");

            var handler = Fixture.GetService <IGetUserByCredentialsHandler>();

            var request = new GetUserByCredentials
            {
                Email    = "*****@*****.**",
                Password = "******"
            };

            var result = await handler.Handle(request, new System.Threading.CancellationToken());

            Assert.True(result.IsSuccessful);
            Assert.Null(result.Error);
            Assert.NotNull(result.User);
            Assert.Equal("*****@*****.**", result.User.Email);
        }