Exemplo n.º 1
0
        public void ShouldContainNumbers()
        {
            LazySequence sequence = new LazySequence(new NumberSequenceFunction(0));

            for (int k=0; k<100; k++)
                Assert.IsTrue(sequence.Contains(k));
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 4
0
 public void ShouldRaiseWhenClear()
 {
     LazySequence sequence = new LazySequence(new NumberSequenceFunction(0));
     sequence.Clear();
 }
Exemplo n.º 5
0
        public void ShouldGetZeroCountFromNull()
        {
            LazySequence sequence = new LazySequence(new NullSequenceFunction());

            Assert.AreEqual(0, sequence.Count);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 8
0
 public void ShouldRaiseWhenRemoveAt()
 {
     LazySequence sequence = new LazySequence(new NumberSequenceFunction(0));
     sequence.RemoveAt(0);
 }
Exemplo n.º 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));
        }
Exemplo n.º 10
0
 public void ShouldGetHashCode()
 {
     LazySequence sequence = new LazySequence(new DeferredSequenceFunction(EmptyList.Instance));
     Assert.AreEqual(sequence.GetHashCode(), Utilities.Hash(EmptyList.Instance.ToSequence()));
 }
Exemplo n.º 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));
        }
Exemplo n.º 12
0
        public void ShouldGetEmptyListAsEmpty()
        {
            LazySequence sequence = new LazySequence(new NumberSequenceFunction(0));
            ISequence empty = sequence.Empty;

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

            ISequence coll = sequence.Empty;

            Assert.IsNotNull(coll);
            Assert.IsInstanceOfType(coll, typeof(EmptyList));
        }
Exemplo n.º 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);
            }
        }
Exemplo n.º 15
0
        public void ShouldBeEquivToNull()
        {
            LazySequence sequence = new LazySequence(new NullSequenceFunction());

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

            ISequence value = sequence.More();

            Assert.IsNotNull(value);
            Assert.IsInstanceOfType(value, typeof(EmptyList));
        }
Exemplo n.º 18
0
 public void ShouldRaiseWhenSetValue()
 {
     LazySequence sequence = new LazySequence(new NumberSequenceFunction(0));
     sequence[0] = 1;
 }
Exemplo n.º 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());
        }
Exemplo n.º 20
0
        public void ShouldGetNextFromNull()
        {
            LazySequence sequence = new LazySequence(new NullSequenceFunction());

            ISequence value = sequence.Next();

            Assert.IsNull(value);
        }
Exemplo n.º 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);
            }
        }
Exemplo n.º 22
0
 public void RaiseWhenAdd()
 {
     LazySequence sequence = new LazySequence(new NumberSequenceFunction(0));
     sequence.Add(0);
 }
Exemplo n.º 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);
        }