public async Task UpdateUserFilter()
        {
            var condition = new Condition
            {
                UserFilterCondition = FilterOperation.Contains,
                FilteringField      = "name",
                Value = "test value updates"
            };

            var order = new FilterOrder
            {
                Asc           = false,
                SortingColumn = "name",
            };

            var createUserFilterRequest = new CreateUserFilterRequest
            {
                Name           = Guid.NewGuid().ToString(),
                Description    = "testDscr_1",
                IsShared       = true,
                UserFilterType = UserFilterType.Launch,
                Conditions     = new List <Condition> {
                    condition
                },
                Orders = new List <FilterOrder> {
                    order
                }
            };

            var userFilterCreatedReponse = await Service.UserFilter.CreateAsync(createUserFilterRequest);

            var updateUserFilterRequest = new UpdateUserFilterRequest
            {
                Name           = Guid.NewGuid().ToString(),
                Description    = "testDscr_Updated",
                IsShared       = true,
                UserFilterType = UserFilterType.TestItem,
                Conditions     = new List <Condition> {
                    condition
                },
                Orders = new List <FilterOrder> {
                    order
                }
            };

            await Service.UserFilter.UpdateAsync(userFilterCreatedReponse.Id, updateUserFilterRequest);

            var updatedUserFilter = await Service.UserFilter.GetAsync(userFilterCreatedReponse.Id);

            Assert.Equal(updatedUserFilter.Id, userFilterCreatedReponse.Id);
            Assert.Equal(updateUserFilterRequest.Name, updatedUserFilter.Name);
            Assert.Equal(updateUserFilterRequest.Description, updatedUserFilter.Description);
            Assert.Equal(updateUserFilterRequest.IsShared, updatedUserFilter.IsShared);
            Assert.Equal(updateUserFilterRequest.UserFilterType, updatedUserFilter.UserFilterType);

            var delMessage = await Service.UserFilter.DeleteAsync(userFilterCreatedReponse.Id);

            Assert.Contains("success", delMessage.Info);
        }
Exemple #2
0
        /// <summary>
        /// Creates the specified user filter.
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public virtual async Task <UserFilterCreatedResponse> CreateAsync(CreateUserFilterRequest model)
        {
            var uri = BaseUri.Append($"{ProjectName}/filter");

            var body     = ModelSerializer.Serialize <CreateUserFilterRequest>(model);
            var response = await HttpClient.PostAsync(uri, new StringContent(body, Encoding.UTF8, "application/json")).ConfigureAwait(false);

            response.VerifySuccessStatusCode();
            return(ModelSerializer.Deserialize <UserFilterCreatedResponse>(await response.Content.ReadAsStringAsync().ConfigureAwait(false)));
        }
Exemple #3
0
        public async Task FindUserFilters()
        {
            var condition = new Condition
            {
                UserFilterCondition = FilterOperation.Contains,
                FilteringField      = "name",
                Value = "test value"
            };

            var order = new FilterOrder
            {
                Asc           = true,
                SortingColumn = "name",
            };

            var createUserFilterRequest = new CreateUserFilterRequest
            {
                Name           = Guid.NewGuid().ToString(),
                Description    = "testDscr_1",
                IsShared       = true,
                UserFilterType = UserFilterType.Launch,
                Conditions     = new List <Condition> {
                    condition
                },
                Orders = new List <FilterOrder> {
                    order
                }
            };

            var userFilterCreatedResponse = await Service.UserFilter.CreateAsync(createUserFilterRequest);

            var userFilterContainer = await Service.UserFilter.GetAsync(new FilterOption
            {
                Filters = new List <Filter> {
                    new Filter(FilterOperation.Equals, "name", createUserFilterRequest.Name)
                },
                Paging = new Paging(1, 200)
            });

            Assert.Contains(userFilterContainer.Items, f => f.Id.Equals(userFilterCreatedResponse.Id));

            var deleteMessage = await Service.UserFilter.DeleteAsync(userFilterCreatedResponse.Id);

            Assert.Contains("success", deleteMessage.Info);
        }
Exemple #4
0
        public async Task UpdatePreferences()
        {
            var condition = new Condition
            {
                UserFilterCondition = FilterOperation.Contains,
                FilteringField      = "name",
                Value = "test value"
            };

            var order = new FilterOrder
            {
                Asc           = true,
                SortingColumn = "name",
            };

            var createUserFilterRequest = new CreateUserFilterRequest
            {
                Name           = Guid.NewGuid().ToString(),
                Description    = "testDscr_1",
                IsShared       = true,
                UserFilterType = UserFilterType.Launch,
                Conditions     = new List <Condition> {
                    condition
                },
                Orders = new List <FilterOrder> {
                    order
                }
            };

            var userFilterCreatedReponse = await Service.UserFilter.CreateAsync(createUserFilterRequest);

            var message = await Service.Project.UpdatePreferencesAsync(Service.ProjectName, Username, userFilterCreatedReponse.Id);

            message.Info.Should().Contain("successfully added");

            var allPreferences = await Service.Project.GetAllPreferences(Service.ProjectName, Username);

            allPreferences.Filters.Should().ContainSingle(p => p.Id == userFilterCreatedReponse.Id);

            var delMessage = await Service.UserFilter.DeleteAsync(userFilterCreatedReponse.Id);

            delMessage.Info.Should().Contain("successfully deleted");
        }
Exemple #5
0
        public async Task UpdatePreferences()
        {
            var condition = new Condition
            {
                UserFilterCondition = FilterOperation.Contains,
                FilteringField      = "name",
                Value = "test value"
            };

            var order = new FilterOrder
            {
                Asc           = true,
                SortingColumn = "name",
            };

            var createUserFilterRequest = new CreateUserFilterRequest
            {
                Name           = Guid.NewGuid().ToString(),
                Description    = "testDscr_1",
                IsShared       = true,
                UserFilterType = UserFilterType.Launch,
                Conditions     = new List <Condition> {
                    condition
                },
                Orders = new List <FilterOrder> {
                    order
                }
            };

            var userFilterCreatedReponse = await Service.UserFilter.CreateAsync(createUserFilterRequest);

            var message = await Service.Project.UpdatePreferencesAsync(Service.ProjectName, Username, userFilterCreatedReponse.Id);

            //Assert.Equal(base.Service.ProjectName, message.ProjectRef);

            var allPreferences = await Service.Project.GetAllPreferences(Service.ProjectName, Username);

            //Assert.True(allPreferences.FilterIds.Intersect(userFilters.Select(x => x.Id)).Any());

            await Service.UserFilter.DeleteAsync(userFilterCreatedReponse.Id);
        }
Exemple #6
0
 public async Task <UserFilterCreatedResponse> CreateAsync(CreateUserFilterRequest request)
 {
     return(await PostAsJsonAsync <UserFilterCreatedResponse, CreateUserFilterRequest>($"{ProjectName}/filter", request));
 }