public void CountOfTwoItems() { Cons c1 = new Cons("abc", null); Cons c2 = new Cons("def", c1); Expect(c2.count(), EqualTo(2)); }
public void EmptyIsNull() { // Test of ASeq Cons c = new Cons("abc", null); IPersistentCollection empty = c.empty(); Expect(empty, SameAs(PersistentList.EMPTY)); }
public void ASeqICollCopyToCopiesToIndexPositive() { ICollection ic = new Cons(1, new Cons(2, new Cons(3, null))); int[] arr = new int[4]; ic.CopyTo(arr, 1); Expect(arr[0], EqualTo(0)); Expect(arr[1], EqualTo(1)); Expect(arr[2], EqualTo(2)); Expect(arr[3], EqualTo(3)); }
public void NoMetaCtorHasNoMeta() { Cons c = new Cons("abc",null); Expect(c.meta(),Null); }
public void SeqIteratorMovedToEmptyHasNoCurrent() { Cons c = new Cons(1, new Cons(2, null)); SeqEnumerator s = new SeqEnumerator(c); s.MoveNext(); s.MoveNext(); s.MoveNext(); // Have to assign to access object o = s.Current; }
public void EmptyIsNull() { // Test of ASeq Cons c = new Cons("abc", null); Expect(c.empty(), Null); }
public void Setup() { IPersistentMap meta = PersistentHashMap.create("a", 1, "b", 2); Cons c1 = new Cons("abc", null); Cons c2 = new Cons(meta,"def", c1); _obj = c2; _objWithNullMeta = c1; _expectedType = typeof(Cons); }
public void CountOfOneItem() { Cons c = new Cons("abc", null); Expect(c.count(), EqualTo(1)); }
public void Cons_ISeq_conses() { Cons c1 = new Cons("def", null); Cons c2 = new Cons("abc", c1); VerifyISeqCons(c2, "ghi", new object[] { "abc", "def" }); }
public void Cons_ISeq_with_meta_has_correct_values() { IPersistentMap meta = new DummyMeta(); Cons c1 = new Cons("def", null); Cons c2 = new Cons(meta,"abc", c1); VerifyISeqContents(c2, new object[] { "abc", "def" }); }
public void ASeqICollCopyToFailsOnMultidimArray() { ICollection ic = new Cons(1, new Cons(2, new Cons(3, null))); Array arr = Array.CreateInstance(typeof(int), 4, 4); ic.CopyTo(arr, 0); }
public void ASeqICollCopyToFailsOnInsufficientSpace2() { ICollection ic = new Cons(1, new Cons(2, new Cons(3, null))); Array arr = new object[10]; ic.CopyTo(arr, 8); }
public void ASeqICollCopyToFailsOnNullArray() { ICollection ic = new Cons(1, null); ic.CopyTo(null, 0); }
// Some aspects of ASeq have been tested above. // Here are the remaining bits private Cons CreateComplicatedCons() { Cons c1 = new Cons(1, null); Cons c2 = new Cons(2, c1); Cons c3 = new Cons("abc", null); Cons c4 = new Cons(c3, c2); Cons c5 = new Cons("def", c4); return c5; }
public void Cons_ISeq_with_meta_has_correct_values() { MockRepository mocks = new MockRepository(); IPersistentMap meta = mocks.StrictMock<IPersistentMap>(); mocks.ReplayAll(); Cons c1 = new Cons("def", null); Cons c2 = new Cons(meta,"abc", c1); VerifyISeqContents(c2, new object[] { "abc", "def" }); mocks.VerifyAll(); }
public void SeqIteratorResetAtEndWorks() { Cons c = new Cons(1, new Cons(2, null)); SeqEnumerator s = new SeqEnumerator(c); s.MoveNext(); s.MoveNext(); s.MoveNext(); s.Reset(); Expect(s.MoveNext()); Expect(s.Current, EqualTo(1)); Expect(s.MoveNext()); Expect(s.Current, EqualTo(2)); Expect(s.Current, EqualTo(2)); Expect(s.MoveNext(), False); }
public void ASeqICollCopyToFailsOnNegativeIndex() { ICollection ic = new Cons(1, new Cons(2, new Cons(3, null))); Array arr = new object[10]; ic.CopyTo(arr, -1); }
public void Cons_ISeq_has_correct_values() { Cons c1 = new Cons("def", null); Cons c2 = new Cons("abc", c1); VerifyISeqContents(c2, new object[] { "abc", "def" }); }
public void ASeqICollCountWorks() { ICollection ic = new Cons(1, new Cons(2, new Cons(3, null))); Expect(ic.Count, EqualTo(3)); }
public void MetaCtorHasMeta() { IPersistentMap meta = new DummyMeta(); Cons c = new Cons(meta, "abc", null); Expect(c.meta(), SameAs(meta)); }
public void SeqReturnsSelf() { Cons c1 = new Cons("abc", null); Expect(c1.seq(), SameAs(c1)); }
public void Setup() { IPersistentMap meta = new DummyMeta(); Cons c1 = new Cons("abc", null); Cons c2 = new Cons(meta,"def", c1); _obj = c2; _objWithNullMeta = c1; _expectedType = typeof(Cons); }
public void IPC_Cons_works() { Cons c1 = new Cons("abc", null); IPersistentCollection ipc1 = c1 as IPersistentCollection; IPersistentCollection ipc2 = ipc1.cons("def"); ISeq s = ipc2.seq(); Expect(s.first(), EqualTo("def")); Expect(s.next(), SameAs(c1)); }
public void ASeqICollIsSynchronized() { ICollection ic = new Cons(1, new Cons(2, new Cons(3, null))); Expect(ic.IsSynchronized); }
public void MetaCtorHasMeta() { MockRepository mocks = new MockRepository(); IPersistentMap meta = mocks.StrictMock<IPersistentMap>(); mocks.ReplayAll(); Cons c = new Cons(meta, "abc", null); Expect(c.meta(), SameAs(meta)); mocks.VerifyAll(); }
public void ASeqICollImplementsSyncRoot() { ICollection ic = new Cons(1, new Cons(2, new Cons(3, null))); Object o = ic.SyncRoot; Expect(o, SameAs(ic)); }
public void ASeqIEnumWorks() { ICollection ic = new Cons(1, new Cons(2, new Cons(3, null))); IEnumerator e = ic.GetEnumerator(); Expect(e.MoveNext()); Expect(e.Current, EqualTo(1)); Expect(e.MoveNext()); Expect(e.Current, EqualTo(2)); Expect(e.MoveNext()); Expect(e.Current, EqualTo(3)); Expect(e.MoveNext(),False); }
/// <summary> /// Notify all watchers. /// </summary> public void notifyWatches() { IPersistentMap ws = _watchers; if (ws.count() > 0) { ISeq args = new Cons(this, null); for (ISeq s = RT.seq(ws); s != null; s = s.rest()) { IMapEntry me = (IMapEntry)s.first(); object[] a = (object[])me.val(); Agent agent = (Agent)me.key(); try { agent.dispatch((IFn)a[0], args, (Boolean)a[1]); } catch (Exception) { // eat dispatching exceptions and continue } } } }
public void ASeqICollHasDoesntImplementSyncRoot() { ICollection ic = new Cons(1, new Cons(2, new Cons(3, null))); Object o = ic.SyncRoot; }