Ejemplo n.º 1
0
        public void InsertCompoundOf2()
        {
            var indexables =
                _collectionFile.Collection <Indexable, int, IndexableIndexDefinition2>("indexables2", i => i.ID);

            indexables.Persist(Indexable.CreateIndexable(1));
            indexables.Persist(Indexable.CreateIndexable(2));
            indexables.Persist(Indexable.CreateIndexable(3));

            var item2 = indexables.Indexes.Compound1And2.Equals(2, 2).First();

            Assert.AreEqual(2, item2.ID);
        }
Ejemplo n.º 2
0
        public void Allow_Updating_Object_In_Unique_Index()
        {
            var indexables =
                _collectionFile.Collection <Indexable, int, IndexableIndexDefinitionUnique2>("indexables_unique_compound", i => i.ID);
            var indexable = Indexable.CreateIndexable(1);

            indexables.Persist(indexable);
            indexable.Prop8 = "Updated";
            indexables.Persist(indexable);
            var foundIndexable = indexables.Indexes.UniqueCompound1And2.Find(indexable.Prop1, indexable.Prop2);

            Assert.AreEqual(indexable.ID, foundIndexable.ID);
        }
Ejemplo n.º 3
0
        public void Between3Compound_2Params()
        {
            var indexables =
                _collectionFile.Collection <Indexable, int, IndexableIndexDefinition3>("indexables3", i => i.ID);

            indexables.Persist(Indexable.CreateIndexable(1));
            indexables.Persist(Indexable.CreateIndexable(2));
            indexables.Persist(Indexable.CreateIndexable(3));

            var items = indexables.Indexes.Compound1And2And3.Between(1, 1).And(3, 3).ToList();

            Assert.AreEqual(1, items.Count);
            Assert.AreEqual(2, items[0].ID);
        }
Ejemplo n.º 4
0
        public void GreaterThan_Keys()
        {
            var indexables =
                _collectionFile.Collection <Indexable, int, IndexableIndexDefinition3>("indexables3", i => i.ID);

            indexables.Persist(Indexable.CreateIndexable(1));
            indexables.Persist(Indexable.CreateIndexable(2));
            indexables.Persist(Indexable.CreateIndexable(3));

            var keys = indexables.Indexes.Compound1And2And3.GreaterThanOrEqual(2).Keys.ToList();

            Assert.AreEqual(2, keys.Count);
            Assert.AreEqual(2, keys[0].P1);
            Assert.AreEqual(3, keys[1].P1);
        }
Ejemplo n.º 5
0
        public void GreaterThan_Descending()
        {
            var indexables =
                _collectionFile.Collection <Indexable, int, IndexableIndexDefinition3>("indexables3", i => i.ID);

            indexables.Persist(Indexable.CreateIndexable(1));
            indexables.Persist(Indexable.CreateIndexable(2));
            indexables.Persist(Indexable.CreateIndexable(3));

            var items = indexables.Indexes.Compound1And2And3.GreaterThan(1).Descending.ToList();

            Assert.AreEqual(2, items.Count);
            Assert.AreEqual(3, items[0].ID);
            Assert.AreEqual(2, items[1].ID);
        }
Ejemplo n.º 6
0
        public void SmallerOrEqualThan3Compound_3Params()
        {
            var indexables =
                _collectionFile.Collection <Indexable, int, IndexableIndexDefinition3>("indexables3", i => i.ID);

            indexables.Persist(Indexable.CreateIndexable(1));
            indexables.Persist(Indexable.CreateIndexable(2));
            indexables.Persist(Indexable.CreateIndexable(3));

            var items = indexables.Indexes.Compound1And2And3.SmallerThanOrEqual(2, 2, 2).ToList();

            Assert.AreEqual(2, items.Count);
            Assert.AreEqual(1, items[0].ID);
            Assert.AreEqual(2, items[1].ID);
        }
Ejemplo n.º 7
0
        public void Throws_DuplicateIndexEntryException_When_Inserting_Duplicate_Keys_In_Unique_Index()
        {
            var indexables =
                _collectionFile.Collection <Indexable, int, IndexableIndexDefinitionUnique2>("indexables_unique_compound", i => i.ID);
            var indexable = Indexable.CreateIndexable(1);

            indexables.Persist(indexable);

            var conflictingIndexable = Indexable.CreateIndexable(2);

            conflictingIndexable.Prop1 = indexable.Prop1;
            conflictingIndexable.Prop2 = indexable.Prop2;
            Assert.Throws <ArgumentException>(
                () => indexables.Persist(conflictingIndexable)
                );
        }
Ejemplo n.º 8
0
        public void All()
        {
            var indexables =
                _collectionFile.Collection <Indexable, int, IndexableIndexDefinition4>("indexables4", i => i.ID);

            indexables.Persist(Indexable.CreateIndexable(3));
            indexables.Persist(Indexable.CreateIndexable(2));
            indexables.Persist(Indexable.CreateIndexable(1));
            var items = indexables.Indexes.Compound1And2And3And4.All.ToList();

            Assert.AreEqual(3, items.Count);

            Assert.AreEqual(1, items[0].ID);
            Assert.AreEqual(2, items[1].ID);
            Assert.AreEqual(3, items[2].ID);
        }
Ejemplo n.º 9
0
        public void Insert_Optional_Compound_Of2()
        {
            var indexables =
                _collectionFile.Collection <Indexable, int, IndexDefinitionWithPredicateCompound2>("indexables_unique_compound", i => i.ID);

            for (int i = 1; i <= 3; i++)
            {
                var indexable = Indexable.CreateIndexable(i);
                indexables.Persist(indexable);
            }

            var indexableNotToIndex = new Indexable {
                ID = 123
            };

            indexables.Persist(indexableNotToIndex);

            var foundIndexables = indexables.Indexes.Compound.All;

            CollectionAssert.AreEquivalent(new int[] { 1, 2, 3 }, foundIndexables.Select(i => i.ID).ToArray());
        }