Beispiel #1
0
        public async Task WhenGetPagedList_ThenSuccess()
        {
            var headers = await _defaultRequestHeadersService.GetAsync();

            var category = await _create.ProductCategory.BuildAsync();

            category.Name      = "Test".WithGuid();
            category.IsDeleted = true;

            await _productCategoriesClient.UpdateAsync(category, headers);

            var request = new ProductCategoryChangeGetPagedListRequest
            {
                CategoryId = category.Id,
                SortBy     = "CreateDateTime",
                OrderBy    = "asc"
            };

            var response = await _groupChangesClient.GetPagedListAsync(request, headers);

            Assert.NotEmpty(response.Changes);
            Assert.True(response.Changes.All(x => !x.ChangerUserId.IsEmpty()));
            Assert.True(response.Changes.All(x => x.CategoryId == category.Id));
            Assert.True(response.Changes.All(x => x.CreateDateTime.IsMoreThanMinValue()));
            Assert.True(response.Changes.First().OldValueJson.IsEmpty());
            Assert.True(!response.Changes.First().NewValueJson.IsEmpty());
            Assert.NotNull(response.Changes.First().NewValueJson.FromJsonString <ProductCategory>());
            Assert.True(!response.Changes.Last().OldValueJson.IsEmpty());
            Assert.True(!response.Changes.Last().NewValueJson.IsEmpty());
            Assert.False(response.Changes.Last().OldValueJson.FromJsonString <ProductCategory>().IsDeleted);
            Assert.True(response.Changes.Last().NewValueJson.FromJsonString <ProductCategory>().IsDeleted);
            Assert.Equal(response.Changes.Last().NewValueJson.FromJsonString <ProductCategory>().Name, category.Name);
        }
        public async Task WhenUpdate_ThenSuccess()
        {
            var headers = await _defaultRequestHeadersService.GetAsync();

            var categories = await _create.ProductCategory
                             .WithName("Test".WithGuid())
                             .BuildAsync();

            categories.Name      = "Test".WithGuid();
            categories.IsDeleted = true;

            await _productCategoriesClient.UpdateAsync(categories, headers);

            var updatedCategory = await _productCategoriesClient.GetAsync(categories.Id, headers);

            Assert.Equal(categories.Name, updatedCategory.Name);
            Assert.Equal(categories.IsDeleted, updatedCategory.IsDeleted);
        }