Пример #1
0
        private async Task DoFilterExpectedObjects(Expression <Func <TestObject, bool> > expr, params string[] expectedIds)
        {
            var enumerable = connection.RunAsync(testTable.Filter(expr));

            Assert.That(enumerable, Is.Not.Null);
            List <TestObject> objects = new List <TestObject>();
            var count = 0;

            while (true)
            {
                if (!await enumerable.MoveNext())
                {
                    break;
                }
                objects.Add(enumerable.Current);
                ++count;
            }
            Assert.That(count, Is.EqualTo(expectedIds.Length));
            Assert.That(objects, Has.Count.EqualTo(expectedIds.Length));
            foreach (var id in expectedIds)
            {
                Assert.That(objects, Has.Exactly(1).EqualTo(new TestObject()
                {
                    Id = id
                }));
            }
        }
Пример #2
0
        public void DeleteAndReturnValuesSequenceNoChanges()
        {
            var resp = connection.Run(testTable.Filter(o => o.Name == "foo").DeleteAndReturnChanges());

            Assert.That(resp, Is.Not.Null);
            Assert.That(resp.FirstError, Is.Null);
            Assert.That(resp.Deleted, Is.EqualTo(0));
            Assert.That(resp.GeneratedKeys, Is.Null);
            Assert.That(resp.Changes, Is.Not.Null);
            Assert.That(resp.Changes, Has.Length.EqualTo(0));
        }
Пример #3
0
        public void NullableNullFilter()
        {
            connection.Run(testTable3.Insert(new TestObject3()
            {
                Id = 1, Value_Int_Nullable = 100
            }));
            connection.Run(testTable3.Insert(new TestObject3()
            {
                Id = 2, Value_Int_Nullable = null
            }));

            int count = 0;

            foreach (var row in connection.Run(testTable3.Filter(o => o.Value_Int_Nullable == null)))
            {
                row.Id.Should().Be(2);
                count += 1;
            }
            count.Should().Be(1);
        }
        public void Keys()
        {
            var keys = connection.Run(testTable.Filter(o => o.Name == "Madame Curie").Map(o => o.FreeformProperties.Keys)).Single();

            keys.Should().Contain("awesome level");
            keys.Should().Contain("cool level");
            keys.Should().Contain("impressive");
            keys.Should().HaveCount(3);
        }