public void Constructor_ExpectedValues() { // Call using (var plugin = new SimplePlugin()) { // Assert Assert.IsNull(plugin.Gui); } }
public void GetStateInfos_ReturnsEmpty() { // Setup using (var plugin = new SimplePlugin()) { // Call IEnumerable <StateInfo> infos = plugin.GetStateInfos(); // Assert CollectionAssert.IsEmpty(infos); } }
public void Deactivate_DoesNotThrow() { // Setup using (var plugin = new SimplePlugin()) { // Call TestDelegate call = () => plugin.Deactivate(); // Assert Assert.DoesNotThrow(call); } }
public void GetChildDataWithViewDefinitions_ReturnsEmpty() { // Setup using (var plugin = new SimplePlugin()) { // Call IEnumerable <object> chidrenWithViewDefinitions = plugin.GetChildDataWithViewDefinitions(null); // Assert CollectionAssert.IsEmpty(chidrenWithViewDefinitions); } }
void Reload() { var container = TinyIoCContainer.Current; IConfigProvider service = container.Resolve <IConfigProvider>(ContainerNSR.APP_SETTINGS); service.Load(); this.Domain = service.Domain; this.EnableCredentials = service.EnableCredentials; this.EnableProxy = service.EnableProxy; this.Host = service.Host; this.Password = SecurityUtils.DecryptString(service.Password); this.Port = service.Port; this.User = service.User; this.BassUser = service.BassUser; this.BassCode = service.BassCode; this.SelectedTheme = service.SelectedTheme; IList <PluginVM> source = ((PluginsHandler.Instance.Plugins).Select((i, o) => new PluginVM(i))).ToList(); foreach (PluginVM item in source) { SimplePlugin plugin = service.Plugins.Where((i, o) => i.Name.Equals(item.Plugin.Name)).FirstOrDefault(); if (plugin != null) { item.IsEnabled = plugin.IsEnabled; item.Position = plugin.Position; } if (item.IsEnabled && item.Plugin.CanLoadSave()) { item.Plugin.Load(); } } //this.Plugins = new ObservableCollection<PluginVM>(source.OrderBy(i => i.Position)); /* avoid memory leaks (multiple calls on Helper.TabControlBehavior) */ if (this.plugins == null) { this.plugins = new ObservableCollection <PluginVM>(); } this.plugins.ToList().All(i => this.plugins.Remove(i)); source.OrderBy(i => i.Position).All(o => { this.plugins.Add(o); return(true); }); IAudioConfigProvider audioservice = container.Resolve <IAudioConfigProvider>(ContainerNSR.AUDIO_SETTINGS); audioservice.Load(); this.SelectedDevice = audioservice.Device; TriggerSafeEvent(SettingsReloadEvent); }
public void GetInquiryHelper_GuiIsNull_ThrowsInvalidOperationException() { // Setup var plugin = new SimplePlugin(); // Call void Call() => plugin.GetInquiryHelperFromBase(); // Assert var exception = Assert.Throws <InvalidOperationException>(Call); Assert.AreEqual("Gui cannot be null", exception.Message); }
public void Gui_SetValue_GetNewlySetValue() { // Setup var mocks = new MockRepository(); var gui = mocks.Stub <IGui>(); mocks.ReplayAll(); using (var plugin = new SimplePlugin()) { // Call plugin.Gui = gui; // Assert Assert.AreEqual(gui, plugin.Gui); } mocks.VerifyAll(); }
public void Dispose_SetGuiToNull() { // Setup var mocks = new MockRepository(); var gui = mocks.Stub <IGui>(); mocks.ReplayAll(); var plugin = new SimplePlugin { Gui = gui }; // Call plugin.Dispose(); // Assert Assert.IsNull(plugin.Gui); mocks.VerifyAll(); }
public void GetInquiryHelper_WithGui_ReturnsDialogBasedInquiryHelper() { // Setup var mocks = new MockRepository(); var mainWindow = mocks.Stub <IMainWindow>(); var gui = mocks.Stub <IGui>(); gui.Stub(g => g.MainWindow).Return(mainWindow); mocks.ReplayAll(); var plugin = new SimplePlugin { Gui = gui }; // Call IInquiryHelper inquiryHelper = plugin.GetInquiryHelperFromBase(); // Assert Assert.IsInstanceOf <DialogBasedInquiryHelper>(inquiryHelper); mocks.VerifyAll(); }
public void GivenPluginWithGui_WhenGetInquiryHelperCalled_ThenAlwaysSameInquiryHelperReturned() { // Given var mocks = new MockRepository(); var mainWindow = mocks.Stub <IMainWindow>(); var gui = mocks.Stub <IGui>(); gui.Stub(g => g.MainWindow).Return(mainWindow); mocks.ReplayAll(); var plugin = new SimplePlugin { Gui = gui }; // When IInquiryHelper inquiryHelper1 = plugin.GetInquiryHelperFromBase(); IInquiryHelper inquiryHelper2 = plugin.GetInquiryHelperFromBase(); // Then Assert.AreSame(inquiryHelper1, inquiryHelper2); mocks.VerifyAll(); }
void LoadPlugins() { var container = TinyIoCContainer.Current; IConfigProvider service = container.Resolve <IConfigProvider>(ContainerNSR.APP_SETTINGS); //IAppUpdateCheckService updateCheckService = container.Resolve<IAppUpdateCheckService>(ContainerNSR.UPDATE_CHECK_SERVICE); service.Load(); IList <PluginVM> source = ((PluginsHandler.Instance.Plugins).Select((i, o) => new PluginVM(i))).ToList(); foreach (PluginVM item in source) { SimplePlugin plugin = service.Plugins.Where((i, o) => i.Name.Equals(item.Plugin.Name)).FirstOrDefault(); if (plugin != null) { item.IsEnabled = plugin.IsEnabled; item.Position = plugin.Position; } } this.Plugins = new List <PluginVM>(source.OrderBy(i => i.Position)); foreach (PluginVM plugin in Plugins) { if (plugin.IsEnabled) { bool init = plugin.Plugin.Init(AudioControllerService.Current.LibPath, AudioControllerService.Current.StreamMixer); if (!init) { plugin.IsEnabled = false; TriggerSafeEvent(PluginInitFailedEvent, new MessageEventArgs { Message = string.Format("{0} - plugin init failed", plugin.Plugin.Name) }); } //plugin.Plugin.UpdateCheckService = updateCheckService; // TODO should be injected instead plugin.Plugin.SendActionSignal += (s, e) => { SignalArgs args = (SignalArgs)e; switch (args.Action) { case PLAYER_ACTION.RESET: AudioControllerService.Current.Pause(); AudioControllerService.Current.SetPosition(0); break; case PLAYER_ACTION.PLAY: AudioControllerService.Current.Play(false); break; case PLAYER_ACTION.STOP: AudioControllerService.Current.Stop(); break; } }; } } RaisePropertyChanged(() => Plugins); }