Exemple #1
0
        public void CanStoreAndFindTypeWithString()
        {
            var item = new TypeWithAString()
            {
                String = null
            };
            var item2 = new TypeWithAString()
            {
                String = "asdf"
            };

            var index = new Linqdex <TypeWithAString>();

            index.Add(item);
            index.Add(item2);
            Assert.AreEqual(item, index.ToIndexedQuery().Where(t => t.String == null).ToArray().Single());

            Assert.AreEqual(item2, index.ToIndexedQuery().Where(t => t.String == "asdf").ToArray().Single());
        }
Exemple #2
0
        public void CanStoreAndFindTypeWithANullableDateTimeOffset()
        {
            var item = new TypeWithANullableDateTimeOffset()
            {
                Now = null
            };
            var dateTimeOffset = DateTimeOffset.Now;
            var item2          = new TypeWithANullableDateTimeOffset()
            {
                Now = dateTimeOffset
            };

            var index = new Linqdex <TypeWithANullableDateTimeOffset>();

            index.Add(item);
            index.Add(item2);
            Assert.AreEqual(item, index.ToIndexedQuery().Where(t => t.Now == null).ToArray().Single());

            Assert.AreEqual(item2, index.ToIndexedQuery().Where(t => t.Now == dateTimeOffset).ToArray().Single());
        }
Exemple #3
0
        public void CanStoreAndFindTypeWithADateTimeOffset()
        {
            var item = new TypeWithADateTimeOffset()
            {
                Now = DateTimeOffset.Now
            };
            var index = new Linqdex <TypeWithADateTimeOffset>();

            index.Add(item);
            Assert.AreEqual(item, index.ToIndexedQuery().Where(t => t.Now > DateTimeOffset.Now.Date).ToArray().Single());
        }
Exemple #4
0
        public void CanAddAnItemAndRetreiveIt()
        {
            var indexedList = new Linqdex <Person>();
            var expected    = new Person()
            {
                Name = "Arnold"
            };

            indexedList.Add(expected);
            var actual = indexedList.ToIndexedQuery().Single(p => p.Name == "Arnold");

            Assert.AreEqual(expected, actual);
        }
Exemple #5
0
        public void CanRemoveAnItemAndNotRetreiveIt()
        {
            var indexedList = new Linqdex <Person>();
            var expected    = new Person()
            {
                Name = "Arnold"
            };

            indexedList.Add(expected);
            indexedList.Remove(expected);
            var actual = indexedList.ToIndexedQuery().SingleOrDefault(p => p.Name == "Arnold");

            Assert.Null(actual);
        }
Exemple #6
0
        public void CanUpdateAnItemAndNotRetreiveIt()
        {
            var observableCollection = new Linqdex <Person>();
            var expected             = new Person()
            {
                Name = "Arnold"
            };

            observableCollection.Add(expected);
            expected.Name = "Todd";
            var actual = observableCollection.ToIndexedQuery().SingleOrDefault(p => p.Name == "Arnold");

            Assert.Null(actual);
        }
Exemple #7
0
        public void CanChangeAnItemAndRetreiveIt()
        {
            var indexedList = new Linqdex <Person>();
            var expected    = new Person()
            {
                Name = "Arnold"
            };

            indexedList.Add(expected);

            expected.Name = "Marvin";

            var actual = indexedList.ToIndexedQuery().SingleOrDefault(p => p.Name == "Marvin");

            Assert.NotNull(actual);
        }