public void AddMethodByKeyAndValueFiresCollectionAddingEventBeforeAdding() { Guid id = Guid.NewGuid(); var mockPipe = new Mock<IPipe>(); HelperForCollections helper = new HelperForCollections(); _pipes.Adding += new PipeCollectionEventHandler<IPipes, PipeCollectionEventArgs>(helper.Adding_DummyHandler); using (RecordExpectations recorder = RecorderManager.StartRecording()) { recorder.ExpectAndReturn(mockPipe.Id, id); new PipeCollectionEventArgs(PipeCollectionEventArgs.CollectionAction.Add, mockPipe); recorder.CheckArguments(); helper.Adding_DummyHandler(null, null); } _pipes.Add(id, mockPipe); MockManager.Verify(); }
public void AddMethodByKeyValuePairFiresCollectionAddingEventBeforeAdding() { Guid id = Guid.NewGuid(); var mockEl = new Mock<IElement>(); KeyValuePair<Guid, IElement> kvp = new KeyValuePair<Guid,IElement>(id, mockEl); HelperForCollections helper = new HelperForCollections(); _elements.Adding += new ElementCollectionEventHandler<IElements, ElementCollectionEventArgs>(helper.Adding_DummyHandler); using (RecordExpectations recorder = RecorderManager.StartRecording()) { recorder.ExpectAndReturn(mockEl.Id, id); new ElementCollectionEventArgs(ElementCollectionEventArgs.CollectionAction.Add, mockEl); recorder.CheckArguments(); helper.Adding_DummyHandler(null, null); } _elements.Add(kvp); MockManager.Verify(); }
public void AddMethodFiresCollectionAddingEventBeforeAdding() { Guid id = Guid.NewGuid(); var mockEl = new Mock<IUtility>(); HelperForCollections helper = new HelperForCollections(); _comments.Adding += new UtilityCollectionEventHandler<IUtilitiesMgr, UtilityCollectionEventArgs>(helper.Adding_DummyHandler); using (RecordExpectations recorder = RecorderManager.StartRecording()) { recorder.ExpectAndReturn(mockEl.Id, id).Repeat(2); new UtilityCollectionEventArgs(UtilityCollectionEventArgs.CollectionAction.Add, mockEl); recorder.CheckArguments(); helper.Adding_DummyHandler(null, null); } _comments.Add(mockEl); MockManager.Verify(); }