Exemplo n.º 1
0
        public async Task ActionInvokerSerializeEnum_EnumIsSerializedAsString()
        {
            var httpClient    = new FakeManagementHttpClient();
            var actionInvoker = new ActionInvoker(httpClient, new MessageCreator("{api_key}"));

            var assetUpsertModel = new AssetUpsertModel()
            {
                Title        = "Asset",
                Descriptions = new []
                {
                    new AssetDescription()
                    {
                        Description = "Description",
                        Language    = LanguageIdentifier.DEFAULT_LANGUAGE
                    },
                },
                FileReference = new FileReference()
                {
                    Id   = "ab7bdf75-781b-4bf9-aed8-501048860402",
                    Type = FileReferenceTypeEnum.Internal
                }
            };

            await actionInvoker.InvokeMethodAsync <AssetUpsertModel, dynamic>("{endpoint_url}", HttpMethod.Put, assetUpsertModel);

            var expectedRequestBody = "{\"file_reference\":{\"id\":\"ab7bdf75-781b-4bf9-aed8-501048860402\",\"type\":\"internal\"},\"descriptions\":[{\"language\":{\"id\":\"00000000-0000-0000-0000-000000000000\"},\"description\":\"Description\"}],\"title\":\"Asset\"}";

            Assert.Equal(expectedRequestBody, httpClient.requestBody);
        }
Exemplo n.º 2
0
        public void ActionInvokerSerializeElementContainingZero_SerializedJsonContainsZero(decimal d, string s)
        {
            var httpClient    = new FakeManagementHttpClient();
            var actionInvoker = new ActionInvoker(httpClient, new MessageCreator("{api_key}"));

            var contentItemVariantUpsertModel = new ContentItemVariantUpsertModel()
            {
                Elements = new
                {
                    zero    = d,
                    optZero = new decimal?(d),
                },
            };

            var result = actionInvoker.InvokeMethodAsync <ContentItemVariantUpsertModel, dynamic>("{endpoint_url}", HttpMethod.Get, contentItemVariantUpsertModel);

            Assert.Equal($"{{\"elements\":{{\"zero\":{s},\"optZero\":{s}}}}}", httpClient.requestBody);
        }