コード例 #1
0
        public async Task WhenGetPagedList_ThenSuccess()
        {
            var headers = await _defaultRequestHeadersService.GetAsync();

            var attribute = await _create.SupplierAttribute.BuildAsync();

            attribute.Type      = AttributeType.Link;
            attribute.Key       = "Test".WithGuid();
            attribute.IsDeleted = true;

            await _supplierAttributesClient.UpdateAsync(attribute, headers);

            var request = new SupplierAttributeChangeGetPagedListRequest
            {
                AttributeId = attribute.Id,
                SortBy      = "CreateDateTime",
                OrderBy     = "asc"
            };

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

            Assert.NotEmpty(response.Changes);
            Assert.True(response.Changes.All(x => !x.ChangerUserId.IsEmpty()));
            Assert.True(response.Changes.All(x => x.AttributeId == attribute.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 <SupplierAttribute>());
            Assert.True(!response.Changes.Last().OldValueJson.IsEmpty());
            Assert.True(!response.Changes.Last().NewValueJson.IsEmpty());
            Assert.False(response.Changes.Last().OldValueJson.FromJsonString <SupplierAttribute>().IsDeleted);
            Assert.True(response.Changes.Last().NewValueJson.FromJsonString <SupplierAttribute>().IsDeleted);
            Assert.Equal(response.Changes.Last().NewValueJson.FromJsonString <SupplierAttribute>().Key, attribute.Key);
            Assert.Equal(response.Changes.Last().NewValueJson.FromJsonString <SupplierAttribute>().Type, attribute.Type);
        }
コード例 #2
0
        public async Task WhenUpdate_ThenSuccess()
        {
            var headers = await _defaultRequestHeadersService.GetAsync();

            var attribute = await _create.SupplierAttribute
                            .WithType(AttributeType.Text)
                            .WithKey("Test".WithGuid())
                            .BuildAsync();

            attribute.Type      = AttributeType.Link;
            attribute.Key       = "Test".WithGuid();
            attribute.IsDeleted = true;

            await _supplierAttributesClient.UpdateAsync(attribute, headers);

            var updatedAttribute = await _supplierAttributesClient.GetAsync(attribute.Id, headers);

            Assert.Equal(attribute.Type, updatedAttribute.Type);
            Assert.Equal(attribute.Key, updatedAttribute.Key);
            Assert.Equal(attribute.IsDeleted, updatedAttribute.IsDeleted);
        }