示例#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    = Reference.ById(Guid.Empty)
                },
            },
            FileReference = new FileReference()
            {
                Id   = "ab7bdf75-781b-4bf9-aed8-501048860402",
                Type = FileReferenceTypeEnum.Internal
            }
        };

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

        Assert.Contains("\"type\":\"internal\"", httpClient._requestBody);
    }
示例#2
0
    public async Task ActionInvokerSerializeElementContainingZero_SerializedJsonContainsZero(decimal d, string s)
    {
        var httpClient    = new FakeManagementHttpClient();
        var actionInvoker = new _ActionInvoker(httpClient, new MessageCreator("{api_key}"));

        var languageVariantUpsertModel = new LanguageVariantUpsertModel()
        {
            Elements = new List <dynamic>
            {
                new
                {
                    zero    = d,
                    optZero = new decimal?(d),
                }
            },
        };

        await actionInvoker.InvokeMethodAsync <LanguageVariantUpsertModel, dynamic>("{endpoint_url}", HttpMethod.Get, languageVariantUpsertModel);

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