예제 #1
0
        public async Task Register(string email, string displayName, string password)
        {
            DeveloperRegistration operation = new DeveloperRegistration(_AuthorityContext, email, displayName, password);
            Developer             developer = await operation.Do();

            await operation.CommitAsync();

            await _emailService.SendDeveloperActivation(developer.Email, new DeveloperActivationModel
            {
                ActivationUrl = string.Format(_configuration.DeveloperActivationUrlTemplate, developer.PendingRegistrationId)
            });
        }
예제 #2
0
        public static async Task <Developer> RegisterDeveloper(AuthorityContext context, string password = "")
        {
            string email    = RandomData.Email();
            string username = RandomData.RandomString();

            password = password == "" ? RandomData.RandomString(12, true) : password;

            DeveloperRegistration operation = new DeveloperRegistration(context, email, username, password);
            Developer             developer = await operation.Do();

            await operation.CommitAsync();

            return(developer);
        }
예제 #3
0
        public async Task RegistrationDuplicateUserShouldFail()
        {
            string email    = RandomData.Email();
            string username = RandomData.RandomString();
            string password = RandomData.RandomString(12, true);

            DeveloperRegistration operation = new DeveloperRegistration(_fixture.Context, email, username, password);
            Developer             developer = await operation.Do();

            await operation.CommitAsync();

            await AssertExtensions.ThrowAsync <RequirementFailedException>(async() =>
            {
                DeveloperRegistration failOperation = new DeveloperRegistration(_fixture.Context, email, username, password);
                Developer failDeveloper             = await failOperation.Do();
            });
        }
예제 #4
0
        public async Task RegistrationShouldSuccess()
        {
            string email    = RandomData.Email();
            string username = RandomData.RandomString();
            string password = RandomData.RandomString(12, true);

            DeveloperRegistration operation = new DeveloperRegistration(_fixture.Context, email, username, password);
            Developer             developer = await operation.Do();

            await operation.CommitAsync();

            Developer developerInDb = await _fixture.Context.Developers
                                      .FirstOrDefaultAsync(d => d.Id == developer.Id);

            Assert.NotNull(developerInDb);
            Assert.Equal(developerInDb.DisplayName, username);
        }