private SaveFileWizard Setup(ISaveFileDialog saveFileDialog = null) { var saveFileDialogCreator = new StubISaveFileDialogCreator { CreateIFile = file => saveFileDialog }; var fileFactory = new StubIFileFactory(); return new SaveFileWizard(saveFileDialogCreator, fileFactory); }
public void WhenFileIsNotSelectedItWillReturnDefaultTypeValue() { var saveFileDialog = new StubISaveFileDialog { FileNameGet = () => null }; var file = new MockFile(); var fileCreator = new StubIFileFactory<MockFile> { CreateString = s => file }; var fileResult = Setup(saveFileDialog).Save(fileCreator); Assert.AreEqual(default(MockFile), fileResult); }
public void WhenFileIsSelectedItWillCreateIt() { const string fileName = "fileName"; var saveFileDialog = new StubISaveFileDialog { FileNameGet = () => fileName }; var file = new MockFile(); var fileCreator = new StubIFileFactory<MockFile> { CreateString = s => file }; var fileResult = Setup(saveFileDialog).Save(fileCreator); Assert.AreEqual(file, fileResult); }