Beispiel #1
0
        public void TestingSomeLinq()
        {
            var client = new RequestClient("http://localhost:5984/");
            var api = new CouchApi(client, "trivial");

            //var cars = query.Where(p => (((p.Make == "Saab" || (p.Model == "1337" && p.HorsePowers == 200)) || p.Make != "Volvo") && p.Model != "2013")).ToList();
            //var cars = query.Where(p => (p.Make == "Saab" && (p.Model == "1337" || p.HorsePowers == 1337))).ToList();
            Console.WriteLine("Starting to process queries...");
            var stopwatch = new Stopwatch();
            stopwatch.Start();
            var cars = new List<object>();
            for (var i = 0; i < 1000; i++)
            {
                var car = new Car {Id = Guid.NewGuid().ToString(), HorsePowers = 10 + i, Make = "Audi", Model = i.ToString()};
                dynamic obj = new CouchObjectProxy<Car>(car);
                obj.Test = "Test123";
                cars.Add(obj);
            }
            var request = new BulkDocsRequest(cars);
            var responseData = api.Root().Db("trivial").BulkDocs().Post<BulkDocsRequest, BulkDocsResponse>(request);

            stopwatch.Stop();
            Console.WriteLine("Finished!");
            Console.WriteLine("Elapsed: {0}", stopwatch.ElapsedMilliseconds);
        }
Beispiel #2
0
        public void When_getting_data_from_then_server__Then_it_should_be_deserialized()
        {
            var client = new RequestClient("http://localhost:5984/");
            var api = new CouchApi(client);

            var responseData = api.Root().Stats().Get<dynamic>();

            var rootData = api.Root().Get<HttpGetRoot>();
            Assert.IsNotNull(rootData);

            var configData = api.Root().Config().Get<dynamic>();
            Assert.IsNotNull(configData);

            var configSectionData = api.Root().Config().Section("daemons").Get<dynamic>();
            var indexServer = configSectionData.DataDeserialized.index_server.ToString();
            Assert.IsNotNull(configSectionData);

            var dbData = api.Root().Db("Test").Get<dynamic>();
            if (dbData.StatusCode != HttpStatusCode.OK)
            {
                var newDbData = api.Root().Db("Test").Put<dynamic, object>();
            }
            var person = new Person();
            person.FirstName = "André";
            person.LastName = "Biseth";
            person.BirthDate = new DateTime(1974, 3, 12);
            person.Weight = 78;
            person.Height = 178;

            var post = api.Root().Db("test").Doc().Post<Person, dynamic>(person);
            Assert.IsNotNull(post);

            var getDoc = api.Root().Db("test").Doc("Test").Get<Person>();
            Assert.IsNotNull(getDoc);

            getDoc.DataDeserialized.Weight = 77;

            var postDoc = api.Root().Db("test").Doc("Test").Put<Person, dynamic>(getDoc.DataDeserialized, (string)getDoc.DynamicData._rev);
            Assert.IsNotNull(postDoc);
        }