public void TestDisposesETLComponents() { Mock <IDisposableExtractor <object> > extractorMock = new Mock <IDisposableExtractor <object> >(); Mock <IDisposableTransformer <object, object> > transformerMock = new Mock <IDisposableTransformer <object, object> >(); Mock <IDisposableLoader <object> > loaderMock = new Mock <IDisposableLoader <object> >(); extractorMock.Setup(_ => _.Extract()).Returns(new object()); extractorMock.Setup(_ => _.Dispose()).Verifiable(); transformerMock.Setup(_ => _.Transform(It.IsAny <object>())).Returns(new object()); transformerMock.Setup(_ => _.Dispose()).Verifiable(); loaderMock.Setup(_ => _.Dispose()).Verifiable(); IProcessor processor = new ProcessorBuilder <object>(loaderMock.Object) .AddSource("process", extractorMock.Object, transformerMock.Object) .Build(); processor.Dispose(); extractorMock.Verify(_ => _.Dispose(), Times.Once); transformerMock.Verify(_ => _.Dispose(), Times.Once); loaderMock.Verify(_ => _.Dispose(), Times.Once); }
public void TestWillDispoeEvenIfLoaderIsNotSpecified() { Mock <IDisposableExtractor <object> > extractorMock = new Mock <IDisposableExtractor <object> >(); Mock <IDisposableTransformer <object, object> > transformerMock = new Mock <IDisposableTransformer <object, object> >(); extractorMock.Setup(_ => _.Extract()).Returns(new object()); transformerMock.Setup(_ => _.Transform(It.IsAny <object>())).Returns(new object()); ICollection <ILoader <object> > loaders = new List <ILoader <object> >(); IProcessor processor = new ProcessorBuilder <object>(loaders) .AddSource("process", extractorMock.Object, transformerMock.Object) .Build(); processor.Dispose(); extractorMock.Verify(_ => _.Dispose(), Times.Once); transformerMock.Verify(_ => _.Dispose(), Times.Once); }