Exemple #1
0
        public void ShouldReplaceMappedQueueItem(BiConverter <Converter <TestObj, int>, IComparer <TestObj>, SortedMappedQueue <TestObj> > queueCreator)
        {
            // given
            Converter <TestObj, int> keyExtractor = obj => obj.Id;
            var comparer = Comparers.CompareBy <TestObj, DateTime>(obj => obj.Date);
            var queue    = queueCreator(keyExtractor, comparer);
            var obj1     = new TestObj {
                Id = 1, Date = new DateTime(2015, 6, 17, 13, 30, 0)
            };
            var obj2 = new TestObj {
                Id = 1, Date = new DateTime(2015, 6, 17, 15, 30, 0)
            };
            var obj3 = new TestObj {
                Id = 2, Date = new DateTime(2015, 6, 17, 13, 35, 0)
            };

            // when
            var offer1Accepted = queue.Offer(obj1);
            var offer2Accepted = queue.Offer(obj2);
            var offer3Accepted = queue.Offer(obj3);

            queue.Put(obj2);

            // then
            Check.That(offer1Accepted).IsTrue();
            Check.That(offer2Accepted).IsFalse();
            Check.That(offer3Accepted).IsTrue();
            Check.That(queue).ContainsExactly(obj3, obj2);
        }
 public WriteControlled_Item(BiConverter <TReadable, TWritable> converter)
 {
     this.converter = converter;
 }
Exemple #3
0
        private static IEnumerable <BiConverter <Converter <TestObj, int>, IComparer <TestObj>, SortedMappedQueue <TestObj> > > ComplexMappedQueues()
        {
            BiConverter <Converter <TestObj, int>, IComparer <TestObj>, SortedMappedQueue <TestObj> > result =
                SortedSetMappedQueue <int, TestObj> .Create;

            yield return(result);

            result = ArrayListSortedMappedQueue <int, TestObj> .Create;
            yield return(result);
        }
Exemple #4
0
 // Constructor
 public WriteControlled_Set(BiConverter <TReadable, TWritable> subConverter)
 {
     this.subConverter = subConverter;
 }