Example #1
0
        public void ShouldForgotPasswordSuccessfully()
        {
            var client         = new Services.MeshyClient(Generator.RandomString(5), Generator.RandomString(36));
            var authService    = new Mock <IAuthenticationService>();
            var expected       = new UserVerificationHash();
            var passedUsername = string.Empty;

            authService.Setup(x => x.ForgotPasswordAsync(It.IsAny <string>(), It.IsAny <int>()))
            .Callback <string, int>((sentUsername, sentAttempt) =>
            {
                passedUsername = sentUsername;
            })
            .Returns(() =>
            {
                return(Task.FromResult(expected));
            });

            client.AuthenticationService = authService.Object;

            var username = Generator.RandomString(5);
            var actual   = client.ForgotPassword(username);

            Assert.Equal(expected, actual);
            Assert.Equal(username, passedUsername);
        }
Example #2
0
        public void ShouldRegisterUserSuccessfully()
        {
            var client      = new Services.MeshyClient(Generator.RandomString(5), Generator.RandomString(36));
            var authService = new Mock <IAuthenticationService>();
            var expected    = new UserVerificationHash();

            authService.Setup(x => x.RegisterAsync(It.IsAny <RegisterUser>())).Returns(() =>
            {
                return(Task.FromResult(expected));
            });

            client.AuthenticationService = authService.Object;

            var actual = client.RegisterUser(new RegisterUser(Generator.RandomString(5), Generator.RandomString(5)));

            Assert.Equal(expected, actual);
        }