public void Should_Convert_To_CamelCase_Json_With_Default_Client_Configuration_Serialization_Settings()
        {
            var data = new Pascal
            {
                SomeProperty = "SOME",
                SomeIntProperty = 12345,
                HasPascalCase = true
            };
            const string expectedJson = "{\"someProperty\":\"SOME\",\"someIntProperty\":12345,\"hasPascalCase\":true}";
            var actualJson = JsonConvert.SerializeObject(data, new ClientConfiguration().SerializationSettings);

            Assert.AreEqual(expectedJson, actualJson);
        }
        public void Should_Convert_To_PascalCase_Json_With_Altered_Serialization_Settings()
        {
            var data = new Pascal
            {
                SomeProperty = "SOME",
                SomeIntProperty = 12345,
                HasPascalCase = true
            };
            const string expectedJson = "{\"SomeProperty\":\"SOME\",\"SomeIntProperty\":12345,\"HasPascalCase\":true}";
            var serializationSetting = new ClientConfiguration().SerializationSettings;
            serializationSetting.ContractResolver = new DefaultContractResolver();
            var actualJson = JsonConvert.SerializeObject(data, serializationSetting);

            Assert.AreEqual(expectedJson, actualJson);
        }
        public void Should_Convert_To_PascalCase_Json_With_Altered_Serialization_Settings()
        {
            var transcoder = new DefaultTranscoder(
                new DefaultConverter(),
                new DefaultSerializer(
                    new JsonSerializerSettings(),
                    new JsonSerializerSettings
            {
                ContractResolver = new DefaultContractResolver()
            }));

            var data = new Pascal
            {
                SomeProperty = "SOME",
                SomeIntProperty = 12345,
                HasPascalCase = true
            };
            var expectedJsonBytes = Encoding.UTF8.GetBytes("{\"SomeProperty\":\"SOME\",\"SomeIntProperty\":12345,\"HasPascalCase\":true}");
            var actualJsonBytes = transcoder.SerializeAsJson(data);
            var actualJsonEncoded = transcoder.Encode(data, OperationCode.Get);

            Assert.AreEqual(expectedJsonBytes, actualJsonBytes);
            Assert.AreEqual(expectedJsonBytes, actualJsonEncoded);
        }
 public void When_Custom_Transcoder_Upsert_uses_it()
 {
     const string key = "when_custom_Transcoder_Upsert_uses_it";
     var clientConfiguration = new ClientConfiguration((CouchbaseClientSection)ConfigurationManager.GetSection("couchbaseClients/couchbase"))
     {
         SerializationSettings = new JsonSerializerSettings
         {
             TypeNameHandling = TypeNameHandling.Objects
         }
     };
     using (var cluster = new Cluster(clientConfiguration))
     {
         using (var bucket = cluster.OpenBucket())
         {
             var doc = new Pascal
             {
                 HasPascalCase = true,
                 SomeIntProperty = 9999,
                 SomeProperty = "when_custom_Transcoder_Upsert_uses_it"
             };
             var result = bucket.Upsert(key, doc);
             Assert.IsTrue(result.Success);
             var readBack = bucket.Get<string>(key);
             Assert.IsTrue(readBack.Success);
             Assert.IsTrue(readBack.Value.Contains("when_custom_Transcoder_Upsert_uses_it"));
         }
     }
 }
 public void Should_Convert_To_CamelCase_Json_With_Default_Serialization_Settings()
 {
     var transcoder = new DefaultTranscoder(new DefaultConverter());
     var data = new Pascal
     {
         SomeProperty = "SOME",
         SomeIntProperty = 12345,
         HasPascalCase = true
     };
     var expectedJsonBytes = Encoding.UTF8.GetBytes("{\"someProperty\":\"SOME\",\"someIntProperty\":12345,\"hasPascalCase\":true}");
     var actualJsonBytes = transcoder.SerializeAsJson(data);
     var actualJsonEncoded = transcoder.Encode(data, new Flags{DataFormat = DataFormat.Json}, OperationCode.Get);
     Assert.AreEqual(expectedJsonBytes, actualJsonBytes);
     Assert.AreEqual(expectedJsonBytes, actualJsonEncoded);
 }