public void AssertJsonSerializer()
        {
            string connectionString = "AccountEndpoint=https://localtestcosmos.documents.azure.com:443/;AccountKey=425Mcv8CXQqzRNCgFNjIhT424GK99CKJvASowTnq15Vt8LeahXTcN5wt3342vQ==;";
            CosmosClientBuilder cosmosClientBuilder = new CosmosClientBuilder(connectionString);
            CosmosClient        cosmosClient        = cosmosClientBuilder.Build(new MockDocumentClient());

            Assert.IsInstanceOfType(cosmosClient.ClientOptions.GetCosmosSerializerWithWrapperOrDefault(), typeof(CosmosJsonSerializerWrapper));
            Assert.AreEqual(cosmosClient.ClientOptions.GetCosmosSerializerWithWrapperOrDefault(), cosmosClient.ClientOptions.PropertiesSerializer);

            CosmosSerializer defaultSerializer  = cosmosClient.ClientOptions.PropertiesSerializer;
            CosmosSerializer mockJsonSerializer = new Mock <CosmosSerializer>().Object;

            cosmosClientBuilder.WithCustomSerializer(mockJsonSerializer);
            CosmosClient cosmosClientCustom = cosmosClientBuilder.Build(new MockDocumentClient());

            Assert.AreEqual(defaultSerializer, cosmosClientCustom.ClientOptions.PropertiesSerializer);
            Assert.AreEqual(mockJsonSerializer, cosmosClientCustom.ClientOptions.Serializer);
            Assert.IsInstanceOfType(cosmosClientCustom.ClientOptions.GetCosmosSerializerWithWrapperOrDefault(), typeof(CosmosJsonSerializerWrapper));
            Assert.AreEqual(mockJsonSerializer, ((CosmosJsonSerializerWrapper)cosmosClientCustom.ClientOptions.GetCosmosSerializerWithWrapperOrDefault()).InternalJsonSerializer);
        }
        private static CosmosClient CreateCosmosClient(string connectionString, CosmosOptions cosmosOptions)
        {
            GuardEmptyString(connectionString, "cosmosDbConnectionString");
            cosmosOptions.Guard();

            var builder = new CosmosClientBuilder(connectionString);

            // ConnectionPolicy のDefault値は、SDKのConnectionPolicy.csで設定されています。

            // ## Connection Mode について
            // Default で ConnectionMode.Direct/Protocol.Tcp で接続されます。
            // もしGateway(ConnectionMode.Gateway/Protocol.Https) を使いたければ、以下メソッドを呼ぶ
            // builder.UseConnectionModeGateway(maxConnectionLimit: ??);

            // Default: CamelCase Serialize/Deserialize and ignore Readonly property
            // TODO: 設定変更用のconfigは未実装
            //var settings = JsonSerializerSettingsFactory.CreateForReadonlyIgnoreAndCamelCase();
            var settings = JsonSerializerSettingsFactory.CreateForCamelCase();

            builder.WithCustomSerializer(new CustomizableCaseJsonSerializer(settings));

            if (cosmosOptions.ThrottlingRetryOptions != null)
            {
                builder.WithThrottlingRetryOptions(
                    cosmosOptions.ThrottlingRetryOptions.MaxRetryWaitTimeOnThrottledRequests,
                    cosmosOptions.ThrottlingRetryOptions.MaxRetryAttemptsOnThrottledRequests);
            }

            // multi-master support
            if (!string.IsNullOrEmpty(cosmosOptions.CurrentRegion))
            {
                builder.WithApplicationRegion(cosmosOptions.CurrentRegion);
            }

            return(builder.Build());
        }