Exemple #1
0
        public void SavedObjectsShouldBeIdentical()
        {
            // create a proto-contract class (https://code.google.com/p/protobuf-net/wiki/GettingStarted)
            //var testPerson = new ProtoBufPerson()
            //{
            //    Id = 42,
            //    Name = "alex",
            //    Address = new Address()
            //    {
            //        Line1 = "16 dusty road",
            //        Line2 = "santa fe, nm 87508"
            //    }
            //};
            const string bucketName = "test";
            var          ojPerson   = new Person()
            {
                Name = "oj", CurrentlyDrinking = "tea"
            };

            var oj = new RiakObject(bucketName, OJ)
            {
                ContentType = RiakConstants.ContentTypes.ProtocolBuffers
            };

            oj.SetObject(ojPerson);

            var putResult = Client.Put(oj);

            var getResult = Client.Get(bucketName, OJ);
            var newPerson = getResult.GetObject <Person>();

            ojPerson.Name.ShouldEqual(newPerson.Name);


            var testPerson = new ProtoBufPerson()
            {
                Id      = 42,
                Name    = "alex",
                Address = new Address()
                {
                    Line1 = "16 dusty road",
                    Line2 = "santa fe, nm 87508"
                }
            };

            var ro = new RiakObject(bucketName, testPerson.Id.ToString());

            ro.ContentType = RiakConstants.ContentTypes.ProtocolBuffers;
            ro.SetObject(testPerson);

            var putResult2 = Client.Put(ro);

            var getResult2  = Client.Get(bucketName, testPerson.Id.ToString());
            var testPerson2 = getResult2.GetObject <ProtoBufPerson>();

            testPerson.Id.ShouldEqual(testPerson2.Id);
            testPerson.Name.ShouldEqual(testPerson2.Name);
            testPerson.Address.Line1.ShouldEqual(testPerson2.Address.Line1);
            testPerson.Address.Line2.ShouldEqual(testPerson2.Address.Line2);
        }
        public void SavedObjectsShouldBeIdentical()
        {
            // create a proto-contract class (https://code.google.com/p/protobuf-net/wiki/GettingStarted)
            //var testPerson = new ProtoBufPerson()
            //{
            //    Id = 42,
            //    Name = "alex",
            //    Address = new Address()
            //    {
            //        Line1 = "16 dusty road",
            //        Line2 = "santa fe, nm 87508"
            //    }
            //};
            const string bucketName = "test";
            var ojPerson = new Person() { Name = "oj", CurrentlyDrinking = "tea" };

            var oj = new RiakObject(bucketName, OJ) { ContentType = RiakConstants.ContentTypes.ProtocolBuffers };
            oj.SetObject(ojPerson);

            // Don't capture result to avoid compiler warning
            Client.Put(oj);

            var getResult = Client.Get(bucketName, OJ);
            var newPerson = getResult.Value.GetObject<Person>();

            ojPerson.Name.ShouldEqual(newPerson.Name);


            var testPerson = new ProtoBufPerson()
            {
                Id = 42,
                Name = "alex",
                Address = new Address()
                {
                    Line1 = "16 dusty road",
                    Line2 = "santa fe, nm 87508"
                }
            };

            var ro = new RiakObject(bucketName, testPerson.Id.ToString());
            ro.ContentType = RiakConstants.ContentTypes.ProtocolBuffers;
            ro.SetObject(testPerson);

            // Don't capture result to avoid compiler warning
            Client.Put(ro);

            var getResult2 = Client.Get(bucketName, testPerson.Id.ToString());
            var testPerson2 = getResult2.Value.GetObject<ProtoBufPerson>();

            testPerson.Id.ShouldEqual(testPerson2.Id);
            testPerson.Name.ShouldEqual(testPerson2.Name);
            testPerson.Address.Line1.ShouldEqual(testPerson2.Address.Line1);
            testPerson.Address.Line2.ShouldEqual(testPerson2.Address.Line2);
        }