Ejemplo n.º 1
0
        public async Task TestFinishRegistration()
        {
            // Setup
            var crowdaction = new Crowdaction($"test-{Guid.NewGuid()}", CrowdactionStatus.Running, await context.Users.Select(u => u.Id).FirstAsync(), 10, DateTime.UtcNow.AddDays(-1), DateTime.UtcNow.AddDays(1), "t", "t", "t", null, null);

            context.Crowdactions.Add(crowdaction);
            await context.SaveChangesAsync();

            // Test
            string testEmail = GetTestEmail();
            AddParticipantResult commitResult = await crowdactionService.CommitToCrowdactionAnonymous(testEmail, crowdaction.Id, CancellationToken.None);

            Assert.Equal(AddParticipantScenario.AnonymousCreatedAndAdded, commitResult.Scenario);

            var finishRegistrationResult = await userService.FinishRegistration(
                new NewUser()
            {
                Email     = testEmail,
                FirstName = GetRandomString(),
                LastName  = GetRandomString(),
                IsSubscribedNewsletter = false,
                Password = "******"
            },
                commitResult.PasswordResetToken);

            Assert.True(finishRegistrationResult.Result.Succeeded);
            Assert.NotNull(finishRegistrationResult.User);
        }
Ejemplo n.º 2
0
        public async Task TestCrowdactionCommitAnonymous()
        {
            // Setup
            var user = await context.Users.FirstAsync();

            Crowdaction crowdaction = new Crowdaction($"test-{Guid.NewGuid()}", CrowdactionStatus.Running, user.Id, 10, DateTime.UtcNow.AddDays(-1), DateTime.UtcNow.AddDays(1), "t", "t", "t", null, null);

            context.Crowdactions.Add(crowdaction);
            await context.SaveChangesAsync();

            // Test
            string testEmail = GetTestEmail();
            var    result    = await crowdactionService.CommitToCrowdactionAnonymous(testEmail, crowdaction.Id, CancellationToken.None);

            Assert.Equal(AddParticipantScenario.AnonymousCreatedAndAdded, result.Scenario);
            result = await crowdactionService.CommitToCrowdactionAnonymous(testEmail, crowdaction.Id, CancellationToken.None);

            Assert.Equal(AddParticipantScenario.AnonymousNotRegisteredPresentAndAlreadyParticipating, result.Scenario);
        }