public void ShouldContainNumbers() { LazySequence sequence = new LazySequence(new NumberSequenceFunction(0)); for (int k=0; k<100; k++) Assert.IsTrue(sequence.Contains(k)); }
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); }
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); }
public void ShouldRaiseWhenClear() { LazySequence sequence = new LazySequence(new NumberSequenceFunction(0)); sequence.Clear(); }
public void ShouldGetZeroCountFromNull() { LazySequence sequence = new LazySequence(new NullSequenceFunction()); Assert.AreEqual(0, sequence.Count); }
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); }
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); }
public void ShouldRaiseWhenRemoveAt() { LazySequence sequence = new LazySequence(new NumberSequenceFunction(0)); sequence.RemoveAt(0); }
public void ShouldGetIndexOf() { LazySequence sequence = new LazySequence(new NumberSequenceFunction(0)); for (int k = 0; k < 100; k++) Assert.AreEqual(k, sequence.IndexOf(k)); }
public void ShouldGetHashCode() { LazySequence sequence = new LazySequence(new DeferredSequenceFunction(EmptyList.Instance)); Assert.AreEqual(sequence.GetHashCode(), Utilities.Hash(EmptyList.Instance.ToSequence())); }
public void ShouldGetEmptyListAsIPersistentCollection() { LazySequence sequence = new LazySequence(new NumberSequenceFunction(0)); IPersistentCollection empty = ((IPersistentCollection)sequence).Empty; Assert.IsNotNull(empty); Assert.IsInstanceOfType(empty, typeof(EmptyList)); }
public void ShouldGetEmptyListAsEmpty() { LazySequence sequence = new LazySequence(new NumberSequenceFunction(0)); ISequence empty = sequence.Empty; Assert.IsNotNull(empty); Assert.IsInstanceOfType(empty, typeof(EmptyList)); }
public void ShouldGetEmptyList() { LazySequence sequence = new LazySequence(new NumberSequenceFunction(10)); ISequence coll = sequence.Empty; Assert.IsNotNull(coll); Assert.IsInstanceOfType(coll, typeof(EmptyList)); }
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); } }
public void ShouldBeEquivToNull() { LazySequence sequence = new LazySequence(new NullSequenceFunction()); Assert.IsTrue(sequence.Equiv(null)); }
public void ShouldRaiseWhenInsert() { LazySequence sequence = new LazySequence(new NumberSequenceFunction(0)); sequence.Insert(0, 1); }
public void ShouldGetMoreFromNull() { LazySequence sequence = new LazySequence(new NullSequenceFunction()); ISequence value = sequence.More(); Assert.IsNotNull(value); Assert.IsInstanceOfType(value, typeof(EmptyList)); }
public void ShouldRaiseWhenSetValue() { LazySequence sequence = new LazySequence(new NumberSequenceFunction(0)); sequence[0] = 1; }
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()); }
public void ShouldGetNextFromNull() { LazySequence sequence = new LazySequence(new NullSequenceFunction()); ISequence value = sequence.Next(); Assert.IsNull(value); }
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); } }
public void RaiseWhenAdd() { LazySequence sequence = new LazySequence(new NumberSequenceFunction(0)); sequence.Add(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); }