示例#1
0
        public async void LoginUser(
            EStatusCode expectedStatus,
            LoginUser mutation,
            bool?withUser      = false,
            bool?equalPassword = false
            )
        {
            var user = null as User;

            if (withUser.Value)
            {
                user = EntitiesFactory.NewUser(
                    login: mutation.Login,
                    password: equalPassword.Value ? mutation.Password : null
                    ).Save();
            }
            var(status, result) = await Request.Post <MutationResultTest <LoginResult> >(Uri, mutation);

            Assert.Equal(expectedStatus, status);
            if (expectedStatus == EStatusCode.Success)
            {
                var loginResult = result.Data;
                Assert.NotNull(loginResult);
                Assert.NotNull(loginResult.Token);
                Assert.False(string.IsNullOrWhiteSpace(loginResult.Token));
                Assert.Equal(user.Id, loginResult.Id);
                Assert.Equal(user.Name, loginResult.Name);
            }
        }
示例#2
0
        private string GenerateTokenStr()
        {
            var defaultUser = EntitiesFactory.NewUser().Save();

            return(new TokenData(defaultUser.Id).Generate());
        }