public void Should_save_external_editor() { DISetup.SetupContainer(); IPreferences saved = null; var preferencesService = new Mock <IPreferencesService>(); preferencesService.Setup(p => p.Save(It.IsAny <IPreferences>())).Returns((IPreferences pref) => { saved = pref; return(true); }); var storageProvider = new Mock <IStorageProvider>(); var mapper = new Mock <IMapper>(); mapper.Setup(s => s.Map(It.IsAny <IExternalEditor>(), It.IsAny <IPreferences>())).Returns((IExternalEditor o, IPreferences p) => { return(new Preferences() { ExternalEditorLocation = o.ExternalEditorLocation, ExternalEditorParameters = o.ExternalEditorParameters }); }); var service = new ExternalEditorService(preferencesService.Object, storageProvider.Object, mapper.Object); service.Save(new ExternalEditor() { ExternalEditorLocation = "test" }).Should().BeTrue(); saved.ExternalEditorLocation.Should().Be("test"); }
public void Should_not_return_launch_args() { DISetup.SetupContainer(); var pref = new Preferences() { ExternalEditorLocation = "test", }; var preferencesService = new Mock <IPreferencesService>(); preferencesService.Setup(p => p.Get()).Returns(() => { return(pref); }); var storageProvider = new Mock <IStorageProvider>(); var mapper = new Mock <IMapper>(); mapper.Setup(s => s.Map <IExternalEditor>(It.IsAny <IPreferences>())).Returns((IPreferences o) => { return(new ExternalEditor() { ExternalEditorLocation = o.ExternalEditorLocation, ExternalEditorParameters = o.ExternalEditorParameters }); }); var service = new ExternalEditorService(preferencesService.Object, storageProvider.Object, mapper.Object); var result = service.GetLaunchArguments("test1", "test2"); result.Should().BeNullOrWhiteSpace(); }
public void Should_return_external_editor() { DISetup.SetupContainer(); var pref = new Preferences() { ExternalEditorLocation = "test", ExternalEditorParameters = "{Left} {Right}" }; var preferencesService = new Mock <IPreferencesService>(); preferencesService.Setup(p => p.Get()).Returns(() => { return(pref); }); var storageProvider = new Mock <IStorageProvider>(); var mapper = new Mock <IMapper>(); mapper.Setup(s => s.Map <IExternalEditor>(It.IsAny <IPreferences>())).Returns((IPreferences o) => { return(new ExternalEditor() { ExternalEditorLocation = o.ExternalEditorLocation, ExternalEditorParameters = o.ExternalEditorParameters }); }); var service = new ExternalEditorService(preferencesService.Object, storageProvider.Object, mapper.Object); var result = service.Get(); result.Should().NotBeNull(); result.ExternalEditorParameters.Should().Be(pref.ExternalEditorParameters); result.ExternalEditorLocation.Should().Be(pref.ExternalEditorLocation); }
public void Should_return_files() { DISetup.SetupContainer(); DISetup.Container.Register <ITempFile, DummyTempFile>(); DISetup.Container.RemoveTransientWarning <ITempFile>(); DI.DIContainer.Finish(true); var preferencesService = new Mock <IPreferencesService>(); var storageProvider = new Mock <IStorageProvider>(); var mapper = new Mock <IMapper>(); var service = new ExternalEditorService(preferencesService.Object, storageProvider.Object, mapper.Object); var result = service.GetFiles(); result.LeftDiff.File.Should().Be("test"); result.RightDiff.File.Should().Be("test"); }