示例#1
0
        public void ShouldContainNumbers()
        {
            LazySequence sequence = new LazySequence(new NumberSequenceFunction(0));

            for (int k=0; k<100; k++)
                Assert.IsTrue(sequence.Contains(k));
        }
示例#2
0
        public void ShouldCreateWithConsAsIPersistentCollectionAndNumberSequence()
        {
            LazySequence seq = new LazySequence(new NumberSequenceFunction(1));
            IPersistentCollection coll = ((IPersistentCollection)seq).Cons(0);

            Assert.IsNotNull(coll);
            Assert.IsInstanceOfType(coll, typeof(ISequence));

            ISequence sequence = (ISequence)coll;

            object value = sequence.First();

            Assert.IsNotNull(value);
            Assert.IsInstanceOfType(value, typeof(int));
            Assert.AreEqual(0, (int)value);

            value = sequence.Next().First();

            Assert.IsNotNull(value);
            Assert.IsInstanceOfType(value, typeof(int));
            Assert.AreEqual(1, (int)value);
        }
示例#3
0
        public void ShouldCreateWithConsAndNumberSequence()
        {
            ISequence seq = new LazySequence(new NumberSequenceFunction(1));
            seq = seq.Cons(0);

            Assert.IsNotNull(seq);
            Assert.IsInstanceOfType(seq, typeof(ISequence));

            ISequence sequence = (ISequence) seq;

            object value = sequence.First();

            Assert.IsNotNull(value);
            Assert.IsInstanceOfType(value, typeof(int));
            Assert.AreEqual(0, (int)value);

            value = sequence.Next().First();

            Assert.IsNotNull(value);
            Assert.IsInstanceOfType(value, typeof(int));
            Assert.AreEqual(1, (int)value);
        }
示例#4
0
 public void ShouldRaiseWhenClear()
 {
     LazySequence sequence = new LazySequence(new NumberSequenceFunction(0));
     sequence.Clear();
 }
示例#5
0
        public void ShouldGetZeroCountFromNull()
        {
            LazySequence sequence = new LazySequence(new NullSequenceFunction());

            Assert.AreEqual(0, sequence.Count);
        }
示例#6
0
        public void ShouldGetSecondNumber()
        {
            LazySequence sequence = new LazySequence(new NumberSequenceFunction(0));

            Assert.IsNotNull(sequence);

            object value = sequence.Next().First();

            Assert.IsNotNull(value);
            Assert.IsInstanceOfType(value, typeof(int));
            Assert.AreEqual(1, (int)value);
        }
示例#7
0
        public void ShouldCreateWithNumberSequence()
        {
            LazySequence sequence = new LazySequence(new NumberSequenceFunction(0));

            Assert.IsNotNull(sequence);

            object value = sequence.First();

            Assert.IsNotNull(value);
            Assert.IsInstanceOfType(value, typeof(int));
            Assert.AreEqual(0, (int)value);
        }
示例#8
0
 public void ShouldRaiseWhenRemoveAt()
 {
     LazySequence sequence = new LazySequence(new NumberSequenceFunction(0));
     sequence.RemoveAt(0);
 }
示例#9
0
        public void ShouldGetIndexOf()
        {
            LazySequence sequence = new LazySequence(new NumberSequenceFunction(0));

            for (int k = 0; k < 100; k++)
                Assert.AreEqual(k, sequence.IndexOf(k));
        }
示例#10
0
 public void ShouldGetHashCode()
 {
     LazySequence sequence = new LazySequence(new DeferredSequenceFunction(EmptyList.Instance));
     Assert.AreEqual(sequence.GetHashCode(), Utilities.Hash(EmptyList.Instance.ToSequence()));
 }
示例#11
0
        public void ShouldGetEmptyListAsIPersistentCollection()
        {
            LazySequence sequence = new LazySequence(new NumberSequenceFunction(0));
            IPersistentCollection empty = ((IPersistentCollection)sequence).Empty;

            Assert.IsNotNull(empty);
            Assert.IsInstanceOfType(empty, typeof(EmptyList));
        }
示例#12
0
        public void ShouldGetEmptyListAsEmpty()
        {
            LazySequence sequence = new LazySequence(new NumberSequenceFunction(0));
            ISequence empty = sequence.Empty;

            Assert.IsNotNull(empty);
            Assert.IsInstanceOfType(empty, typeof(EmptyList));
        }
示例#13
0
        public void ShouldGetEmptyList()
        {
            LazySequence sequence = new LazySequence(new NumberSequenceFunction(10));

            ISequence coll = sequence.Empty;

            Assert.IsNotNull(coll);
            Assert.IsInstanceOfType(coll, typeof(EmptyList));
        }
示例#14
0
        public void ShouldGetAndProcessEnumerator()
        {
            LazySequence sequence = new LazySequence(new NumberSequenceFunction(0));
            IEnumerator enumerator = sequence.GetEnumerator();

            for (int k = 0; k < 100; k++)
            {
                Assert.IsTrue(enumerator.MoveNext());
                Assert.AreEqual(k, enumerator.Current);
            }
        }
示例#15
0
        public void ShouldBeEquivToNull()
        {
            LazySequence sequence = new LazySequence(new NullSequenceFunction());

            Assert.IsTrue(sequence.Equiv(null));
        }
示例#16
0
 public void ShouldRaiseWhenInsert()
 {
     LazySequence sequence = new LazySequence(new NumberSequenceFunction(0));
     sequence.Insert(0, 1);
 }
示例#17
0
        public void ShouldGetMoreFromNull()
        {
            LazySequence sequence = new LazySequence(new NullSequenceFunction());

            ISequence value = sequence.More();

            Assert.IsNotNull(value);
            Assert.IsInstanceOfType(value, typeof(EmptyList));
        }
示例#18
0
 public void ShouldRaiseWhenSetValue()
 {
     LazySequence sequence = new LazySequence(new NumberSequenceFunction(0));
     sequence[0] = 1;
 }
示例#19
0
        public void ShouldGetNext()
        {
            LazySequence sequence = new LazySequence(new NumberSequenceFunction(0));

            ISequence value = sequence.Next();

            Assert.IsNotNull(value);
            Assert.IsInstanceOfType(value, typeof(LazySequence));
            Assert.AreEqual(1, value.First());
        }
示例#20
0
        public void ShouldGetNextFromNull()
        {
            LazySequence sequence = new LazySequence(new NullSequenceFunction());

            ISequence value = sequence.Next();

            Assert.IsNull(value);
        }
示例#21
0
        public void ShouldGetOneHundredValues()
        {
            LazySequence sequence = new LazySequence(new NumberSequenceFunction(0));

            Assert.IsNotNull(sequence);

            for (int k = 0; k < 100; k++)
            {
                object value = sequence[k];

                Assert.IsNotNull(value);
                Assert.IsInstanceOfType(value, typeof(int));
                Assert.AreEqual(k, (int)value);
            }
        }
示例#22
0
 public void RaiseWhenAdd()
 {
     LazySequence sequence = new LazySequence(new NumberSequenceFunction(0));
     sequence.Add(0);
 }
示例#23
0
        public void ShouldCreateWithNullMetadata()
        {
            LazySequence sequence = new LazySequence(new NumberSequenceFunction(0));

            IObject iobj = sequence.WithMetadata(null);

            Assert.IsNotNull(iobj);
            Assert.IsInstanceOfType(iobj, typeof(LazySequence));
            Assert.IsTrue(iobj != sequence);
        }