Ejemplo n.º 1
0
        public async void testGetAllDocuments()
        {
            Dictionary <string, string> request = new Dictionary <string, string>()
            {
                { "collection", "entities" }
            };

            Nilsson.Mongo.MongoClient  client       = new Nilsson.Mongo.MongoClient();
            Nilsson.Mongo.MongoRequest mongoRequest = new Nilsson.Mongo.MongoRequest(request);

            JsonDocument result = await client.getDocuments(mongoRequest);

            Assert.True(result.RootElement.GetArrayLength() > 0);
        }
Ejemplo n.º 2
0
        public async void testUpdateDocuments()
        {
            Dictionary <string, string> request = new Dictionary <string, string>()
            {
                { "collection", "entities" },
                { "query", "{'geometry': 'text'}" },
                { "documents", "{$set: {'scale': '50 50 50'}}" }
            };

            Nilsson.Mongo.MongoClient  client       = new Nilsson.Mongo.MongoClient();
            Nilsson.Mongo.MongoRequest mongoRequest = new Nilsson.Mongo.MongoRequest(request);
            bool result = await client.updateDocuments(mongoRequest);

            Assert.True(result);
        }
Ejemplo n.º 3
0
        public async void testCreateMultipleDocuments()
        {
            Dictionary <string, string> request = new Dictionary <string, string>()
            {
                { "collection", "entities" },
                { "documents", "[{ 'geometry': 'text', 'value': 'test1', 'scale': '30 30 30', 'position': { 'lat': '59.2929', 'lon': '18.1' }},{ 'geometry': 'text', 'value': 'test2', 'scale': '30 30 30', 'position': { 'lat': '59.31', 'lon': '18.1' }}]" }
                //{ "query", "{ 'type': 'account', 'id':20001, 'balance': 10000 }"}
            };

            Nilsson.Mongo.MongoClient  client       = new Nilsson.Mongo.MongoClient();
            Nilsson.Mongo.MongoRequest mongoRequest = new Nilsson.Mongo.MongoRequest(request);
            bool result = await client.createDocuments(mongoRequest);

            Assert.True(result);

            // TODO: Mock database
        }
Ejemplo n.º 4
0
        public async void testCreateOneDocument()
        {
            Dictionary <string, string> request = new Dictionary <string, string>()
            {
                { "collection", "entities" },
                { "documents", "{ 'geometry': 'text', 'value': 'test', 'scale': '30 30 30', 'position': { 'lat': '59.30', 'lon': '18.1' }}" }
            };


            Nilsson.Mongo.MongoClient  client       = new Nilsson.Mongo.MongoClient();
            Nilsson.Mongo.MongoRequest mongoRequest = new Nilsson.Mongo.MongoRequest(request);
            bool result = await client.createDocument(mongoRequest);

            Assert.True(result);

            // TODO: Mock database
        }