private void AssertItem(IObjectSet objectSet, QueryByExampleTestCase.Item item) { Assert.AreEqual(1, objectSet.Count); QueryByExampleTestCase.Item retrievedItem = (QueryByExampleTestCase.Item)objectSet .Next(); Assert.AreSame(item, retrievedItem); }
public virtual void TestQueryByExampleNoneFound() { QueryByExampleTestCase.Item itemOne = new QueryByExampleTestCase.Item("one"); QueryByExampleTestCase.Item itemTwo = new QueryByExampleTestCase.Item("two"); Store(itemOne); Store(itemTwo); // Change the name of the "sample" itemOne._name = "three"; IObjectSet objectSet = Db().QueryByExample(itemOne); Assert.AreEqual(0, objectSet.Count); }
public virtual void TestQueryByExample() { QueryByExampleTestCase.Item itemOne = new QueryByExampleTestCase.Item("one"); QueryByExampleTestCase.Item itemTwo = new QueryByExampleTestCase.Item("two"); Store(itemOne); Store(itemTwo); // Change the name of the "sample" itemOne._name = "two"; // Query by Example IObjectSet objectSet = Db().QueryByExample(itemOne); AssertItem(objectSet, itemTwo); }
public virtual void TestDefaultQueryModeIsIdentity() { QueryByExampleTestCase.Item itemOne = new QueryByExampleTestCase.Item("one"); QueryByExampleTestCase.Item itemTwo = new QueryByExampleTestCase.Item("two"); Store(itemOne); Store(itemTwo); // Change the name of the "sample" itemOne._name = "two"; // Query by Identity IQuery q = Db().Query(); q.Constrain(itemOne); IObjectSet objectSet = q.Execute(); AssertItem(objectSet, itemOne); }
public virtual void TestConstrainByExample() { QueryByExampleTestCase.Item itemOne = new QueryByExampleTestCase.Item("one"); QueryByExampleTestCase.Item itemTwo = new QueryByExampleTestCase.Item("two"); Store(itemOne); Store(itemTwo); // Change the name of the "sample" itemOne._name = "two"; // Query by Example IQuery q = Db().Query(); q.Constrain(itemOne).ByExample(); IObjectSet objectSet = q.Execute(); // Expect to get the other AssertItem(objectSet, itemTwo); }