Пример #1
0
        public async Task Should_add_prod_judge_groups()
        {
            const string EMAIL_STEM = EmailData.FAKE_EMAIL_STEM;

            var prodJudge = new UserBuilder(EMAIL_STEM, 1)
                            .WithUserType(UserType.Judge)
                            .ForApplication(Application.TestApi)
                            .IsProdUser(true)
                            .BuildUserDto();

            var nonProdJudge = new UserBuilder(EMAIL_STEM, 2)
                               .WithUserType(UserType.Judge)
                               .ForApplication(Application.TestApi)
                               .IsProdUser(false)
                               .BuildUserDto();

            UserApiClient.Setup(x => x.AddUserToGroupAsync(It.IsAny <AddUserToGroupRequest>()))
            .Returns(Task.CompletedTask);

            var groupsForProdCount = await UserApiService.AddGroupsToUser(prodJudge, "1");

            var groupsForNonProdCount = await UserApiService.AddGroupsToUser(nonProdJudge, "2");

            groupsForProdCount.Should().BeGreaterThan(groupsForNonProdCount);
        }
Пример #2
0
        public async Task Should_add_user_to_groups_by_user_type(UserType userType)
        {
            const string EMAIL_STEM = EmailData.FAKE_EMAIL_STEM;

            var user = new UserBuilder(EMAIL_STEM, 1)
                       .ForTestType(TestType.Automated)
                       .WithUserType(userType)
                       .BuildUserDto();

            UserApiClient.Setup(x => x.AddUserToGroupAsync(It.IsAny <AddUserToGroupRequest>()))
            .Returns(Task.CompletedTask);

            var groupsCount = await UserApiService.AddGroupsToUser(user, "1");

            groupsCount.Should().BeGreaterThan(0);
        }
Пример #3
0
        public async Task Should_throw_error_if_failed_to_add_user_to_group()
        {
            const string EMAIL_STEM = EmailData.FAKE_EMAIL_STEM;

            var user = new UserBuilder(EMAIL_STEM, 1)
                       .ForTestType(TestType.Automated)
                       .WithUserType(UserType.Individual)
                       .BuildUserDto();

            UserApiClient
            .Setup(x => x.AddUserToGroupAsync(It.IsAny <AddUserToGroupRequest>()))
            .ThrowsAsync(InternalServerError);
            try
            {
                await UserApiService.AddGroupsToUser(user, "1");
            }
            catch (UserApiException ex)
            {
                ex.StatusCode.Should().Be(InternalServerError.StatusCode);
            }
        }
Пример #4
0
        public async Task Should_add_performance_test_groups()
        {
            const string EMAIL_STEM = EmailData.FAKE_EMAIL_STEM;

            var performanceTestUser = new UserBuilder(EMAIL_STEM, 1)
                                      .ForTestType(TestType.Performance)
                                      .WithUserType(UserType.Individual)
                                      .BuildUserDto();

            var nonPerformanceTestUser = new UserBuilder(EMAIL_STEM, 2)
                                         .ForTestType(TestType.Automated)
                                         .WithUserType(UserType.Individual)
                                         .BuildUserDto();

            UserApiClient.Setup(x => x.AddUserToGroupAsync(It.IsAny <AddUserToGroupRequest>()))
            .Returns(Task.CompletedTask);

            var groupsForPerformanceTestUserCount = await UserApiService.AddGroupsToUser(performanceTestUser, "1");

            var groupsForNonPerformanceTestUserCount = await UserApiService.AddGroupsToUser(nonPerformanceTestUser, "2");

            groupsForPerformanceTestUserCount.Should().BeGreaterThan(groupsForNonPerformanceTestUserCount);
        }