예제 #1
0
        public void Issue418()
        {
            using (var connection = GetOpenConnection())
            {
                //update first (will fail) then insert
                //added for bug #418
                var updateObject = new ObjectX
                {
                    ObjectXId = Guid.NewGuid().ToString(),
                    Name      = "Someone"
                };
                var updates = connection.Update(updateObject);
                updates.IsFalse();

                connection.DeleteAll <ObjectX>();

                var objectXId    = Guid.NewGuid().ToString();
                var insertObject = new ObjectX
                {
                    ObjectXId = objectXId,
                    Name      = "Someone else"
                };
                connection.Insert(insertObject);
                var list = connection.GetAll <ObjectX>();
                list.Count().IsEqualTo(1);
            }
        }
예제 #2
0
        public async Task InsertGetUpdateDeleteWithExplicitKeyAsync()
        {
            using (var connection = GetOpenConnection())
            {
                var guid = Guid.NewGuid().ToString();
                var o1   = new ObjectX {
                    ObjectXId = guid, Name = "Foo"
                };
                var originalxCount = (await connection.QueryAsync <int>("Select Count(*) From ObjectX").ConfigureAwait(false)).First();
                await connection.InsertAsync(o1).ConfigureAwait(false);

                var list1 = (await connection.QueryAsync <ObjectX>("select * from ObjectX").ConfigureAwait(false)).ToList();
                list1.Count.IsEqualTo(originalxCount + 1);
                o1 = await connection.GetAsync <ObjectX>(guid).ConfigureAwait(false);

                o1.ObjectXId.IsEqualTo(guid);
                o1.Name = "Bar";
                await connection.UpdateAsync(o1).ConfigureAwait(false);

                o1 = await connection.GetAsync <ObjectX>(guid).ConfigureAwait(false);

                o1.Name.IsEqualTo("Bar");
                await connection.DeleteAsync(o1).ConfigureAwait(false);

                o1 = await connection.GetAsync <ObjectX>(guid).ConfigureAwait(false);

                o1.IsNull();

                const int id = 42;
                var       o2 = new ObjectY {
                    ObjectYId = id, Name = "Foo"
                };
                var originalyCount = connection.Query <int>("Select Count(*) From ObjectY").First();
                await connection.InsertAsync(o2).ConfigureAwait(false);

                var list2 = (await connection.QueryAsync <ObjectY>("select * from ObjectY").ConfigureAwait(false)).ToList();
                list2.Count.IsEqualTo(originalyCount + 1);
                o2 = await connection.GetAsync <ObjectY>(id).ConfigureAwait(false);

                o2.ObjectYId.IsEqualTo(id);
                o2.Name = "Bar";
                await connection.UpdateAsync(o2).ConfigureAwait(false);

                o2 = await connection.GetAsync <ObjectY>(id).ConfigureAwait(false);

                o2.Name.IsEqualTo("Bar");
                await connection.DeleteAsync(o2).ConfigureAwait(false);

                o2 = await connection.GetAsync <ObjectY>(id).ConfigureAwait(false);

                o2.IsNull();
            }
        }
예제 #3
0
        public void GetAllWithExplicitKey()
        {
            using (var connection = GetOpenConnection())
            {
                var guid = Guid.NewGuid().ToString();
                var o1   = new ObjectX {
                    ObjectXId = guid, Name = "Foo"
                };
                connection.Insert(o1);

                var objectXs = connection.GetAll <ObjectX>();
                objectXs.Count().IsEqualTo(1);
            }
        }
예제 #4
0
        public void GetAllWithExplicitKey()
        {
            using (var connection = GetOpenConnection())
            {
                var guid = Guid.NewGuid().ToString();
                var o1   = new ObjectX {
                    ObjectXId = guid, Name = "Foo"
                };
                connection.Insert(o1);

                var objectXs = connection.GetAll <ObjectX>().ToList();
                Assert.True(objectXs.Count > 0);
                Assert.Equal(1, objectXs.Count(x => x.ObjectXId == guid));
            }
        }
예제 #5
0
        public void InsertGetUpdateDeleteWithExplicitKey()
        {
            using (var connection = GetOpenConnection())
            {
                var guid = Guid.NewGuid().ToString();
                var o1   = new ObjectX {
                    ObjectXId = guid, Name = "Foo"
                };
                var originalxCount = connection.Query <int>("Select Count(*) From ObjectX").First();
                connection.Insert(o1);
                var list1 = connection.Query <ObjectX>("select * from ObjectX").ToList();
                list1.Count.IsEqualTo(originalxCount + 1);
                o1 = connection.Get <ObjectX>(guid);
                o1.ObjectXId.IsEqualTo(guid);
                o1.Name = "Bar";
                connection.Update(o1);
                o1 = connection.Get <ObjectX>(guid);
                o1.Name.IsEqualTo("Bar");
                connection.Delete(o1);
                o1 = connection.Get <ObjectX>(guid);
                o1.IsNull();

                const int id = 42;
                var       o2 = new ObjectY {
                    ObjectYId = id, Name = "Foo"
                };
                var originalyCount = connection.Query <int>("Select Count(*) From ObjectY").First();
                connection.Insert(o2);
                var list2 = connection.Query <ObjectY>("select * from ObjectY").ToList();
                list2.Count.IsEqualTo(originalyCount + 1);
                o2 = connection.Get <ObjectY>(id);
                o2.ObjectYId.IsEqualTo(id);
                o2.Name = "Bar";
                connection.Update(o2);
                o2 = connection.Get <ObjectY>(id);
                o2.Name.IsEqualTo("Bar");
                connection.Delete(o2);
                o2 = connection.Get <ObjectY>(id);
                o2.IsNull();
            }
        }
예제 #6
0
        public async Task InsertGetUpdateDeleteWithExplicitKeyAsync()
        {
            using (var connection = GetOpenConnection())
            {
                var guid = Guid.NewGuid().ToString();
                var o1 = new ObjectX { ObjectXId = guid, Name = "Foo" };
                var originalxCount = (await connection.QueryAsync<int>("Select Count(*) From objectx")).First();
                await connection.InsertAsync(o1);
                var list1 = (await connection.QueryAsync<ObjectX>("select * from objectx")).ToList();
                list1.Count.IsEqualTo(originalxCount + 1);
                o1 = await connection.GetAsync<ObjectX>(guid);
                o1.ObjectXId.IsEqualTo(guid);
                o1.Name = "Bar";
                await connection.UpdateAsync(o1);
                o1 = await connection.GetAsync<ObjectX>(guid);
                o1.Name.IsEqualTo("Bar");
                await connection.DeleteAsync(o1);
                o1 = await connection.GetAsync<ObjectX>(guid);
                o1.IsNull();

                const int id = 42;
                var o2 = new ObjectY { ObjectYId = id, Name = "Foo" };
                var originalyCount = connection.Query<int>("Select Count(*) From objecty").First();
                await connection.InsertAsync(o2);
                var list2 = (await connection.QueryAsync<ObjectY>("select * from objecty")).ToList();
                list2.Count.IsEqualTo(originalyCount+1);
                o2 = await connection.GetAsync<ObjectY>(id);
                o2.ObjectYId.IsEqualTo(id);
                o2.Name = "Bar";
                await connection.UpdateAsync(o2);
                o2 = await connection.GetAsync<ObjectY>(id);
                o2.Name.IsEqualTo("Bar");
                await connection.DeleteAsync(o2);
                o2 = await connection.GetAsync<ObjectY>(id);
                o2.IsNull();
            }
        }
예제 #7
0
        public void GetAllWithExplicitKey()
        {
            using (var connection = GetOpenConnection())
            {
                var guid = Guid.NewGuid().ToString();
                var o1 = new ObjectX { ObjectXId = guid, Name = "Foo" };
                connection.Insert(o1);

                var objectXs = connection.GetAll<ObjectX>();
                objectXs.Count().IsEqualTo(1);
            }
        }
예제 #8
0
        public void Issue418()
        {
            using (var connection = GetOpenConnection())
            {
                //update first (will fail) then insert
                //added for bug #418
                var updateObject = new ObjectX
                {
                    ObjectXId = Guid.NewGuid().ToString(),
                    Name = "Someone"
                };
                var updates = connection.Update(updateObject);
                updates.IsFalse();

                connection.DeleteAll<ObjectX>();

                var objectXId = Guid.NewGuid().ToString();
                var insertObject = new ObjectX
                {
                    ObjectXId = objectXId,
                    Name = "Someone else"
                };
                connection.Insert(insertObject);
                var list = connection.GetAll<ObjectX>();
                list.Count().IsEqualTo(1);
            }
        }