Esempio n. 1
0
        public void Cat_CanTurnIntoJsonText()
        {
            // arrange
            var io = MockDB.SharedRuntimeClient["classToJsonText"];
            var savedCat = new Cat
            {
                Name = "Tom",
                Tale = @"Deserializer can mistake as text object instead of vanilla string."
            };
            var jsonCat = "{\r\n   \"Name\" : \"Tom\",\r\n   \"Age\" : 0,\r\n"
                +"   \"Tale\" : \"Deserializer can mistake as text object instead of vanilla string.\",\r\n"
                +"   \"FurDensity\" : 0,\r\n   \"HasMeme\" : false\r\n}";

            var idCat = io.Insert(savedCat);

            // act
            string objectAsString = io.Get<string>(idCat);

            // assert}
            Assert.AreEqual(jsonCat, objectAsString);
        }
Esempio n. 2
0
        static void MixedTypeDemo()
        {
            // arrange some guinea pigs
            var pet = new Sheep { Name = "Fluffy", FavouriteIceCream = IceCream.Vanilla };
            var mittens = new Cat { Name = "Mittens", FurDensity = 0.1 };

            // save data locally
            var db = Embark.Client.GetLocalDB(@"C:\AnimalsDB\"); /* Client.GetLocalDB() defaults to: C:\MyTemp\Embark\Local\ */

            // or over a network (via REST API)
            //var db = Embark.Client.GetNetworkDB("127.0.0.1", 8030);// Not implemented, yet..

            // collections created on-the-fly if needed
            var io = db["sheep"];

            // insert
            long id = io.Insert(pet);
            long d2 = io.Insert((object)500);
            long d3 = io.Insert("a string!");
            long d4 = io.Insert<Cat>(mittens);

            // get
            Sheep fluffy = io.Get<Sheep>(id);

            var xs = (int)io.Get<object>(d2);
            var ss = io.Get<string>(d3);
            //Cat indy = io.Get<Cat>(d2);
            //var x = io.Get<Object>(d3);
            //string empty = io.Get<string>(d4);

            DocumentWrapper<Sheep> fluffbox = io.GetWrapper<Sheep>(id);

            // update
            fluffy.FavouriteIceCream = IceCream.Strawberry;
            bool fluffyNowLikesStrawberry = io.Update(id, fluffy);

            // delete
            bool hasSheepVanished = io.Delete(id);
        }