Exemplo n.º 1
0
        private async Task DoInsert()
        {
            var obj = new TestObject()
            {
                Name     = "Jim Brown",
                Children = new TestObject[] {
                    new TestObject()
                    {
                        Name = "Scan"
                    }
                },
                ChildrenList = new List <TestObject> {
                    new TestObject()
                    {
                        Name = "Scan"
                    }
                },
                ChildrenIList = new List <TestObject> {
                    new TestObject()
                    {
                        Name = "Scan"
                    }
                },
            };
            var resp = await connection.RunAsync(testTable.Insert(obj));

            Assert.That(resp, Is.Not.Null);
            Assert.That(resp.FirstError, Is.Null);
            Assert.That(resp.Inserted, Is.EqualTo(1));
            Assert.That(resp.GeneratedKeys, Is.Not.Null);
            Assert.That(resp.GeneratedKeys, Has.Length.EqualTo(1));
        }
Exemplo n.º 2
0
        private async Task DoInsert()
        {
            insertedObject = new TestObject()
            {
                Name     = "Jim Brown",
                Children = new TestObject[] {
                    new TestObject()
                    {
                        Name = "Scan"
                    }
                },
                ChildrenList = new List <TestObject> {
                    new TestObject()
                    {
                        Name = "Scan"
                    }
                },
                ChildrenIList = new List <TestObject> {
                    new TestObject()
                    {
                        Name = "Scan"
                    }
                },
                SomeNumber = 1234
            };
            var resp = await connection.RunAsync(testTable.Insert(insertedObject));

            insertedObject.Id = resp.GeneratedKeys[0];
        }
Exemplo n.º 3
0
        private async Task DoInsert()
        {
            insertedObject = new ComplexObject
            {
                Name          = "Brian Chavez",
                ProfileUri    = new Uri("http://www.bitarmory.com"),
                CompanyUri    = null,
                Balance       = 1000001.2m,
                Clicks        = 2000,
                Views         = null,
                SecurityStamp = Guid.Parse("32753EDC-E5EF-46E0-ABCD-CE5413B30797"),
                TrackingId    = null,
                LastLogin     = new DateTime(2013, 1, 14, 4, 44, 25),
                LoginWindow   = new TimeSpan(1, 2, 3, 4, 5),
                Signature     = new byte[] { 0xde, 0xad, 0xbe, 0xef },
                Hours         = new[] { 1, 2, 3, 4 },
                ExtraInfo     = new Dictionary <string, string>()
                {
                    { "key1", "value1" },
                    { "key2", "value2" },
                    { "key3", "value3" },
                },
                Enabled         = true,
                Notify          = null,
                BinaryBools     = new[] { true, false, true },
                NullBinaryBools = new bool?[] { true, null, true },
                SomeNumber      = 1234
            };

            var resp = await connection.RunAsync(testTable.Insert(insertedObject));

            insertedObject.Id = resp.GeneratedKeys[0];
        }
 public virtual void SetUp()
 {
     connection.Run(
         testTable.Insert(
             new[] {
         new TestObjectWithDictionary()
         {
             Name = "Jack Black",
             FreeformProperties = new Dictionary <string, object>()
             {
                 { "awesome level", 100 },
                 { "cool level", 15 },
                 { "best movie", "School of Rock" }
             },
             IntegerProperties = new Dictionary <string, int>()
             {
                 { "awesome level", 100 },
                 { "cool level", 15 },
             },
             StringProperties = new Dictionary <string, string>()
             {
                 { "best movie", "School of Rock" },
                 { "oscar winning movie", null }
             },
         },
         new TestObjectWithDictionary()
         {
             Name = "Gil Grissom",
             FreeformProperties = new Dictionary <string, object>()
             {
                 { "awesome level", 101 },
                 { "cool level", 0 },
                 { "best known for", "CSI: Las Vegas" }
             },
             IntegerProperties = new Dictionary <string, int>()
             {
                 { "awesome level", 101 },
                 { "cool level", 0 },
             },
         },
         new TestObjectWithDictionary()
         {
             Name = "Madame Curie",
             FreeformProperties = new Dictionary <string, object>()
             {
                 { "awesome level", 15 },
                 { "cool level", -1 },
                 { "impressive", true }
             },
             IntegerProperties = new Dictionary <string, int>()
             {
                 { "awesome level", 15 },
                 { "cool level", -1 },
             },
         }
     }
             )
         );
 }
Exemplo n.º 5
0
        public void NumericIdInsert()
        {
            var resp = connection.Run(testTable2.Insert(new TestObject2()
            {
                Id = 1, Name = "Woot"
            }));

            Assert.That(resp.Inserted, Is.EqualTo(1));
            resp = connection.Run(testTable2.Insert(new TestObject2()
            {
                Id = 1, Name = "Woot"
            }));
            Assert.That(resp.Errors, Is.EqualTo(1));
            resp = connection.Run(testTable2.Insert(new TestObject2()
            {
                Id = 1, Name = "Woot"
            }));
            Assert.That(resp.Errors, Is.EqualTo(1));
        }
Exemplo n.º 6
0
 public virtual void SetUp()
 {
     testTable = Query.Db("test").Table <TestObject>("table");
     connection.RunAsync(testTable.Insert(new TestObject[] {
         new TestObject()
         {
             Name = "1", SomeNumber = 1
         },
         new TestObject()
         {
             Name = "1", SomeNumber = 1
         },
         new TestObject()
         {
             Name = "2", SomeNumber = 2
         },
         new TestObject()
         {
             Name = "2", SomeNumber = 200
         },
         new TestObject()
         {
             Name = "2", SomeNumber = 2
         },
         new TestObject()
         {
             Name = "3", SomeNumber = 3
         },
         new TestObject()
         {
             Name = "3", SomeNumber = 3
         },
         new TestObject()
         {
             Name = "4", SomeNumber = 4
         },
         new TestObject()
         {
             Name = "5", SomeNumber = 5
         },
         new TestObject()
         {
             Name = "6", SomeNumber = 6
         },
         new TestObject()
         {
             Name = "6", SomeNumber = 6
         },
         new TestObject()
         {
             Name = "7", SomeNumber = 7
         },
     })).Wait();
 }
Exemplo n.º 7
0
        public virtual void SetUp()
        {
            connection.RunAsync(testTable.Insert(new TestObject[] {
                new TestObject()
                {
                    Id = "1", Name = "1", SomeNumber = 1, Tags = new[] { "1", "5" }, Children = new TestObject[1], ChildrenList = new List <TestObject> {
                        null
                    }, ChildrenIList = new List <TestObject> {
                        null
                    }
                },
                new TestObject()
                {
                    Id = "2", Name = "2", SomeNumber = 2, Tags = new[] { "2", "6" }, Children = new TestObject[2], ChildrenList = new List <TestObject> {
                        null, null
                    }, ChildrenIList = new List <TestObject> {
                        null, null
                    }
                },
                new TestObject()
                {
                    Id = "3", Name = "3", SomeNumber = 3, Tags = new[] { "3", "7" }, Children = new TestObject[3], ChildrenList = new List <TestObject> {
                        null, null, null
                    }, ChildrenIList = new List <TestObject> {
                        null, null, null
                    }
                },
                new TestObject()
                {
                    Id = "4", Name = "4", SomeNumber = 4, Tags = new[] { "4", "8" }, Children = new TestObject[4], ChildrenList = new List <TestObject> {
                        null, null, null, null
                    }, ChildrenIList = new List <TestObject> {
                        null, null, null, null
                    }
                },
            })).Wait();

            connection.RunAsync(anotherTestTable.Insert(new AnotherTestObject[] {
                new AnotherTestObject()
                {
                    Id = "1", FirstName = "1", LastName = "1"
                },
                new AnotherTestObject()
                {
                    Id = "2", FirstName = "2", LastName = "2"
                },
                new AnotherTestObject()
                {
                    Id = "3", FirstName = "3", LastName = "3"
                },
            })).Wait();
        }
Exemplo n.º 8
0
        public override void TestFixtureSetUp()
        {
            base.TestFixtureSetUp();

            connection.RunAsync(Query.DbCreate("test")).Wait();
            connection.RunAsync(Query.Db("test").TableCreate("table")).Wait();
            testTable = Query.Db("test").Table<TestObject>("table");

            // Insert more than 1000 objects to test the enumerable loading additional chunks of the sequence
            var objectList = new List<TestObject>();
            for (int i = 0; i < 1005; i++)
                objectList.Add(new TestObject() { Name = "Object #" + i });
            connection.RunAsync(testTable.Insert(objectList)).Wait();
        }
        /// <summary>
        /// Emit a batch of log events, running to completion asynchronously.
        /// </summary>
        /// <param name="events">The events to emit.</param>
        /// <remarks>Override either <see cref="PeriodicBatchingSink.EmitBatch"/> or <see cref="PeriodicBatchingSink.EmitBatchAsync"/>,
        /// not both.</remarks>
        protected override async Task EmitBatchAsync(IEnumerable <LogEvent> events)
        {
            using (IConnection connection = await _connectionFactory.GetAsync())
            {
                var logs = events.Select(logEvent => new RethinkDBLogEvent
                {
                    Id              = Guid.NewGuid(),
                    Message         = logEvent.RenderMessage(),
                    MessageTemplate = logEvent.MessageTemplate.Text,
                    Level           = logEvent.Level,
                    Timestamp       = logEvent.Timestamp,
                    Exception       = logEvent.Exception != null ? logEvent.Exception.ToString() : null,
                    Props           = Convert(logEvent.Properties),
                });

                await connection.RunAsync(_table.Insert(logs));
            }
        }
Exemplo n.º 10
0
 public virtual void SetUp()
 {
     testTable = Query.Db("test").Table<TestObject>("table");
     connection.RunAsync(testTable.Insert(new TestObject[] {
         new TestObject() { Name = "1", SomeNumber = 1 },
         new TestObject() { Name = "1", SomeNumber = 1 },
         new TestObject() { Name = "2", SomeNumber = 2 },
         new TestObject() { Name = "2", SomeNumber = 200 },
         new TestObject() { Name = "2", SomeNumber = 2 },
         new TestObject() { Name = "3", SomeNumber = 3 },
         new TestObject() { Name = "3", SomeNumber = 3 },
         new TestObject() { Name = "4", SomeNumber = 4 },
         new TestObject() { Name = "5", SomeNumber = 5 },
         new TestObject() { Name = "6", SomeNumber = 6 },
         new TestObject() { Name = "6", SomeNumber = 6 },
         new TestObject() { Name = "7", SomeNumber = 7 },
     })).Wait();
 }
Exemplo n.º 11
0
        public void LongAndIntTests()
        {
            var testObj = new TestObject3()
            {
                Id                  = 3,
                Value_Int           = 1354353535,
                Value_Int_Nullable  = 3,
                Value_Long          = 2222222222,
                Value_Long_Nullable = 2
            };

            var resp = connection.Run(testTable3.Insert(testObj));

            Assert.That(resp.Inserted, Is.EqualTo(1));

            var to = connection.Run(testTable3.Get(3));

            Assert.That(to, Is.Not.Null);
            Assert.That(to.Id, Is.EqualTo(3));
        }
Exemplo n.º 12
0
        public override void TestFixtureSetUp()
        {
            base.TestFixtureSetUp();

            connection.RunAsync(Query.DbCreate("test")).Wait();
            connection.RunAsync(Query.Db("test").TableCreate("table")).Wait();
            testTable = Query.Db("test").Table <TestObject>("table");

            // Insert more than 1000 objects to test the enumerable loading additional chunks of the sequence
            var objectList = new List <TestObject>();

            for (int i = 0; i < 1005; i++)
            {
                objectList.Add(new TestObject()
                {
                    Name = "Object #" + i
                });
            }
            connection.RunAsync(testTable.Insert(objectList)).Wait();
        }
Exemplo n.º 13
0
 public virtual void SetUp()
 {
     connection.RunAsync(testTable.Insert(new TestObject[] {
         new TestObject()
         {
             Id = "1", Name = null, Children = new TestObject[0], ChildrenList = new List <TestObject>(), ChildrenIList = new List <TestObject>()
         },
         new TestObject()
         {
             Id = "2", Name = "2", Children = new TestObject[0], ChildrenList = new List <TestObject>(), ChildrenIList = new List <TestObject>()
         },
         new TestObject()
         {
             Id = "3", Name = null, Children = null
         },
         new TestObject()
         {
             Id = "4", Name = string.Empty, Children = null
         }
     })).Wait();
 }
Exemplo n.º 14
0
 public virtual void SetUp()
 {
     connection.RunAsync(testTable.Insert(new List <TestObject> {
         new TestObject()
         {
             Id = "1", Name = "1", SomeNumber = 1, Tags = new[] { "odd" }, Children = new TestObject[] { new TestObject {
                                                                                                             Name = "C1"
                                                                                                         } }, ChildrenList = new List <TestObject> {
                 new TestObject()
                 {
                     Name = "C1"
                 }
             }, ChildrenIList = new List <TestObject> {
                 new TestObject()
                 {
                     Name = "C1"
                 }
             }
         },
         new TestObject()
         {
             Id = "2", Name = "2", SomeNumber = 2, Tags = new[] { "even" }, Children = new TestObject[0], ChildrenList = new List <TestObject> {
             }, ChildrenIList = new List <TestObject> {
             }
         },
         new TestObject()
         {
             Id = "3", Name = "3", SomeNumber = 3, Tags = new[] { "odd" }, Children = new TestObject[] { new TestObject {
                                                                                                             Name = "C3"
                                                                                                         } }, ChildrenList = new List <TestObject> {
                 new TestObject()
                 {
                     Name = "C3"
                 }
             }, ChildrenIList = new List <TestObject> {
                 new TestObject()
                 {
                     Name = "C3"
                 }
             }
         },
         new TestObject()
         {
             Id = "4", Name = "4", SomeNumber = 4, Tags = new[] { "even" }, Children = new TestObject[0], ChildrenList = new List <TestObject> {
             }, ChildrenIList = new List <TestObject> {
             }
         },
         new TestObject()
         {
             Id = "5", Name = "5", SomeNumber = 5, Tags = new[] { "odd" }, Children = new TestObject[] { new TestObject {
                                                                                                             Name = "C5"
                                                                                                         } }, ChildrenList = new List <TestObject> {
                 new TestObject()
                 {
                     Name = "C5"
                 }
             }, ChildrenIList = new List <TestObject> {
                 new TestObject()
                 {
                     Name = "C5"
                 }
             }
         },
         new TestObject()
         {
             Id = "6", Name = "6", SomeNumber = 6, Tags = new[] { "even" }, Children = new TestObject[0], ChildrenList = new List <TestObject> {
             }, ChildrenIList = new List <TestObject> {
             }
         },
         new TestObject()
         {
             Id = "7", Name = "7", SomeNumber = 7, Tags = new[] { "odd" }, Children = new TestObject[] { new TestObject {
                                                                                                             Name = "C7"
                                                                                                         } }, ChildrenList = new List <TestObject> {
                 new TestObject()
                 {
                     Name = "C7"
                 }
             }, ChildrenIList = new List <TestObject> {
                 new TestObject()
                 {
                     Name = "C7"
                 }
             }
         },
     })).Wait();
 }
Exemplo n.º 15
0
        public override void TestFixtureSetUp()
        {
            base.TestFixtureSetUp();
            connection.Run(Query.DbCreate("test"));
            connection.Run(Query.Db("test").TableCreate("table"));

            testTable = Query.Db("test").Table<TestObject>("table");
            connection.Run(testTable.Insert(new TestObject[]
            {
                new TestObject() { Name = "1", SomeNumber = 1 },
                new TestObject() { Name = "1", SomeNumber = 1 },
                new TestObject() { Name = "2", SomeNumber = 2, Tags = new string[] { "A", "B" } },
                new TestObject() { Name = "2", SomeNumber = 200 },
                new TestObject() { Name = "2", SomeNumber = 2, Tags = new string[] { "A", "C" } },
                new TestObject() { Name = "3", SomeNumber = 3 },
                new TestObject() { Name = "3", SomeNumber = 3 },
                new TestObject() { Name = "4", SomeNumber = 4 },
                new TestObject() { Name = "5", SomeNumber = 5 },
                new TestObject() { Name = "6", SomeNumber = 6 },
                new TestObject() { Name = "6", SomeNumber = 6 },
                new TestObject() { Name = "7", SomeNumber = 7 },
            }));

            nameIndex = testTable.IndexDefine("name", to => to.Name);
            connection.Run(nameIndex.IndexCreate());
            connection.Run(nameIndex.IndexWait()).ToArray(); // ToArray ensures that the IEnumerable is actually evaluated completely and the wait is completed
        }
Exemplo n.º 16
0
        public override void TestFixtureSetUp()
        {
            base.TestFixtureSetUp();
            connection.Run(Query.DbCreate("test"));
            connection.Run(Query.Db("test").TableCreate("table"));

            testTable = Query.Db("test").Table <TestObject>("table");
            connection.Run(testTable.Insert(new TestObject[]
            {
                new TestObject()
                {
                    Name = "1", SomeNumber = 1
                },
                new TestObject()
                {
                    Name = "1", SomeNumber = 1
                },
                new TestObject()
                {
                    Name = "2", SomeNumber = 2, Tags = new string[] { "A", "B" }
                },
                new TestObject()
                {
                    Name = "2", SomeNumber = 200
                },
                new TestObject()
                {
                    Name = "2", SomeNumber = 2, Tags = new string[] { "A", "C" }
                },
                new TestObject()
                {
                    Name = "3", SomeNumber = 3
                },
                new TestObject()
                {
                    Name = "3", SomeNumber = 3
                },
                new TestObject()
                {
                    Name = "4", SomeNumber = 4
                },
                new TestObject()
                {
                    Name = "5", SomeNumber = 5
                },
                new TestObject()
                {
                    Name = "6", SomeNumber = 6
                },
                new TestObject()
                {
                    Name = "6", SomeNumber = 6
                },
                new TestObject()
                {
                    Name = "7", SomeNumber = 7
                },
            }));

            nameIndex = testTable.IndexDefine("name", to => to.Name);
            connection.Run(nameIndex.IndexCreate());
            connection.Run(nameIndex.IndexWait());
        }
Exemplo n.º 17
0
        public override void TestFixtureSetUp()
        {
            base.TestFixtureSetUp();
            connection.Run(Query.DbCreate("test"));
            connection.Run(Query.Db("test").TableCreate("table"));

            testTable = Query.Db("test").Table <TestObject>("table");
            connection.Run(testTable.Insert(new TestObject[]
            {
                new TestObject()
                {
                    Name = "1", SomeNumber = 1
                },
                new TestObject()
                {
                    Name = "1", SomeNumber = 1
                },
                new TestObject()
                {
                    Name = "2", SomeNumber = 2, Tags = new string[] { "A", "B" }
                },
                new TestObject()
                {
                    Name = "2", SomeNumber = 200
                },
                new TestObject()
                {
                    Name = "2", SomeNumber = 2, Tags = new string[] { "A", "C" }
                },
                new TestObject()
                {
                    Name = "3", SomeNumber = 3
                },
                new TestObject()
                {
                    Name = "3", SomeNumber = 3
                },
                new TestObject()
                {
                    Name = "4", SomeNumber = 4
                },
                new TestObject()
                {
                    Name = "5", SomeNumber = 5
                },
                new TestObject()
                {
                    Name = "6", SomeNumber = 6
                },
                new TestObject()
                {
                    Name = "6", SomeNumber = 6
                },
                new TestObject()
                {
                    Name = "7", SomeNumber = 7
                },
            }));

            nameIndex = testTable.IndexDefine("name", to => to.Name);
            connection.Run(nameIndex.IndexCreate());
            connection.Run(nameIndex.IndexWait()).ToArray(); // ToArray ensures that the IEnumerable is actually evaluated completely and the wait is completed
        }
Exemplo n.º 18
0
        public override void TestFixtureSetUp()
        {
            base.TestFixtureSetUp();
            connection.Run(Query.DbCreate("test"));
            connection.Run(Query.Db("test").TableCreate("table"));

            testTable = Query.Db("test").Table<TestObject>("table");
            connection.Run(testTable.Insert(new TestObject[]
            {
                new TestObject() { Name = "1", SomeNumber = 1 },
                new TestObject() { Name = "1", SomeNumber = 1 },
                new TestObject() { Name = "2", SomeNumber = 2, Tags = new string[] { "A", "B" } },
                new TestObject() { Name = "2", SomeNumber = 200 },
                new TestObject() { Name = "2", SomeNumber = 2, Tags = new string[] { "A", "C" } },
                new TestObject() { Name = "3", SomeNumber = 3 },
                new TestObject() { Name = "3", SomeNumber = 3 },
                new TestObject() { Name = "4", SomeNumber = 4 },
                new TestObject() { Name = "5", SomeNumber = 5 },
                new TestObject() { Name = "6", SomeNumber = 6 },
                new TestObject() { Name = "6", SomeNumber = 6 },
                new TestObject() { Name = "7", SomeNumber = 7 },
            }));

            nameIndex = testTable.IndexDefine("name", to => to.Name);
            connection.Run(nameIndex.IndexCreate());
            connection.Run(nameIndex.IndexWait());
        }