public void Create_CreateDataSourceFuncThrowsExceptionWithGenericImplementation_ExceptionIsPropogated() { var filePath = @"C:\Temp\testfile.txt"; var dataReaderFactory = MockRepository.GenerateMock <IDataReaderFactory>(); var fileDataSource = new MockFileDataSource(dataReaderFactory, filePath); var createDataSourceFunc = new Func <string, MockFileDataSource>(fp => throw new InternalTestFailureException()); var fileDataSourceFactory = new FileDataSourceFactory <MockFileDataSource>(createDataSourceFunc); fileDataSourceFactory.Create(filePath); }
public void Create_CreateDataSourceFuncIsProvidedWithGenericImplementation_FileDataSourceIsCreated() { var filePath = @"C:\Temp\testfile.txt"; var dataReaderFactory = MockRepository.GenerateMock <IDataReaderFactory>(); var fileDataSource = new MockFileDataSource(dataReaderFactory, filePath); var createDataSourceFunc = new Func <string, MockFileDataSource>(fp => { Assert.AreEqual(filePath, fp); return(fileDataSource); }); var fileDataSourceFactory = new FileDataSourceFactory <MockFileDataSource>(createDataSourceFunc); var fileDataSourceReturned = fileDataSourceFactory.Create(filePath); Assert.AreEqual(fileDataSource, fileDataSourceReturned); }