Exemple #1
0
        public void MixesAliasAndNormalNameWhenSerializing()
        {
            BsonConfiguration.ForType <Skinny>(t => t.UseAlias(p => p.Nint, "id"));

            var result = Serializer.Serialize(new Skinny {
                Nint = 43, String = "abc"
            });

            Assert.AreEqual((byte)'i', result[5]);
            Assert.AreEqual((byte)'d', result[6]);
            Assert.AreEqual((byte)0, result[7]);

            Assert.AreEqual((byte)'S', result[13]);
            Assert.AreEqual((byte)'t', result[14]);
            Assert.AreEqual((byte)'r', result[15]);
            Assert.AreEqual((byte)'i', result[16]);
            Assert.AreEqual((byte)'n', result[17]);
            Assert.AreEqual((byte)'g', result[18]);
            Assert.AreEqual((byte)0, result[19]);
        }
Exemple #2
0
        public void UsesAliasWhenSerializing()
        {
            BsonConfiguration.ForType <Skinny>(t =>
            {
                t.UseAlias(p => p.Nint, "id");
                t.UseAlias(p => p.String, "str");
            });

            var result = Serializer.Serialize(new Skinny {
                Nint = 43, String = "abc"
            });

            Assert.AreEqual((byte)'i', result[5]);
            Assert.AreEqual((byte)'d', result[6]);
            Assert.AreEqual((byte)0, result[7]);

            Assert.AreEqual((byte)'s', result[13]);
            Assert.AreEqual((byte)'t', result[14]);
            Assert.AreEqual((byte)'r', result[15]);
            Assert.AreEqual((byte)0, result[16]);
        }
 internal TypeConfiguration(BsonConfiguration configuration)
 {
     _configuration = configuration;
 }
Exemple #4
0
 private void StaticConfiguration()
 {
     BsonConfiguration.Add();
 }