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

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

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

            await _customerAttributesClient.UpdateAsync(attribute, headers);

            var request = new CustomerAttributeChangeGetPagedListRequest
            {
                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 <CustomerAttribute>());
            Assert.True(!response.Changes.Last().OldValueJson.IsEmpty());
            Assert.True(!response.Changes.Last().NewValueJson.IsEmpty());
            Assert.False(response.Changes.Last().OldValueJson.FromJsonString <CustomerAttribute>().IsDeleted);
            Assert.True(response.Changes.Last().NewValueJson.FromJsonString <CustomerAttribute>().IsDeleted);
            Assert.Equal(response.Changes.Last().NewValueJson.FromJsonString <CustomerAttribute>().Key, attribute.Key);
            Assert.Equal(response.Changes.Last().NewValueJson.FromJsonString <CustomerAttribute>().Type, attribute.Type);
        }
        public async Task WhenUpdate_ThenSuccess()
        {
            var headers = await _defaultRequestHeadersService.GetAsync();

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

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

            await _customerAttributesClient.UpdateAsync(attribute, headers);

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

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