public void Simple() { var list = GetTestList(); var trackingList = new List <int>(); // All items should be visited... trackingList.Add(1); trackingList.Add(2); trackingList.Add(3); trackingList.Add(8); trackingList.Add(5); var generalVisitor = new GeneralVisitor <int>( delegate(int value) { trackingList.Add(value); return(false); } ); list.AcceptVisitor(generalVisitor); Assert.AreEqual(1, trackingList[0]); Assert.AreEqual(2, trackingList[1]); Assert.AreEqual(3, trackingList[2]); Assert.AreEqual(8, trackingList[3]); Assert.AreEqual(5, trackingList[4]); }
public void Simple() { var list = GetTestList(); var mockRepository = new MockRepository(); var trackingList = mockRepository.StrictMock<IList<int>>(); // All items should be visited... trackingList.Add(1); trackingList.Add(2); trackingList.Add(3); trackingList.Add(8); trackingList.Add(5); mockRepository.ReplayAll(); var generalVisitor = new GeneralVisitor<int>( delegate (int value) { trackingList.Add(value); return false; } ); list.AcceptVisitor(generalVisitor); mockRepository.VerifyAll(); }
public void StoppedVisitor() { var visitableList = GetTestList(); var mockRepository = new MockRepository(); var trackingList = mockRepository.StrictMock <IList <int> >(); // No items should be visited. mockRepository.ReplayAll(); var generalVisitor = new GeneralVisitor <int>( delegate(int value) { trackingList.Add(value); return(true); } ) { HasCompleted = true }; visitableList.AcceptVisitor(generalVisitor); mockRepository.VerifyAll(); }
public void Simple() { var list = GetTestList(); var mockRepository = new MockRepository(); var trackingList = mockRepository.StrictMock <IList <int> >(); // All items should be visited... trackingList.Add(1); trackingList.Add(2); trackingList.Add(3); trackingList.Add(8); trackingList.Add(5); mockRepository.ReplayAll(); var generalVisitor = new GeneralVisitor <int>( delegate(int value) { trackingList.Add(value); return(false); } ); list.AcceptVisitor(generalVisitor); mockRepository.VerifyAll(); }
public void StoppingVisitor() { var list = GetTestList(); var trackingList = new List <int>(); var generalVisitor = new GeneralVisitor <int>( delegate(int value) { trackingList.Add(value); return(true); } ); list.AcceptVisitor(generalVisitor); Assert.AreEqual(1, trackingList.Count); Assert.AreEqual(1, trackingList[0]); }
public void StoppedVisitor() { var visitableList = GetTestList(); var trackingList = new List <int>(); // No items should be visited. var generalVisitor = new GeneralVisitor <int>( delegate(int value) { trackingList.Add(value); return(true); } ) { HasCompleted = true }; visitableList.AcceptVisitor(generalVisitor); Assert.IsEmpty(trackingList); }
public void StoppedVisitor() { var visitableList = GetTestList(); var mockRepository = new MockRepository(); var trackingList = mockRepository.StrictMock<IList<int>>(); // No items should be visited. mockRepository.ReplayAll(); var generalVisitor = new GeneralVisitor<int>( delegate (int value) { trackingList.Add(value); return true; } ) {HasCompleted = true}; visitableList.AcceptVisitor(generalVisitor); mockRepository.VerifyAll(); }
public void StoppingVisitor() { var list = GetTestList(); var mockRepository = new MockRepository(); var trackingList = mockRepository.StrictMock <IList <int> >(); // Only the first item should be visited. trackingList.Add(1); mockRepository.ReplayAll(); var generalVisitor = new GeneralVisitor <int>( delegate(int value) { trackingList.Add(value); return(true); } ); list.AcceptVisitor(generalVisitor); mockRepository.VerifyAll(); }
public void StoppingVisitor() { var list = GetTestList(); var mockRepository = new MockRepository(); var trackingList = mockRepository.StrictMock<IList<int>>(); // Only the first item should be visited. trackingList.Add(1); mockRepository.ReplayAll(); var generalVisitor = new GeneralVisitor<int>( delegate (int value) { trackingList.Add(value); return true; } ); list.AcceptVisitor(generalVisitor); mockRepository.VerifyAll(); }