Commits

Christian Specht committed 15aab99 Draft

shutdown if CommandCenterService throws

Comments (0)

Files changed (4)

src/MissileSharp.Launcher/Properties/Resources.Designer.cs

         }
         
         /// <summary>
-        ///   Sucht eine lokalisierte Zeichenfolge, die Couldn&apos;t load config file. Error:{0}{1} ähnelt.
-        /// </summary>
-        internal static string ConfigFileError {
-            get {
-                return ResourceManager.GetString("ConfigFileError", resourceCulture);
-            }
-        }
-        
-        /// <summary>
         ///   Sucht eine lokalisierte Zeichenfolge, die Config file missing:  ähnelt.
         /// </summary>
         internal static string ConfigFileMissing {

src/MissileSharp.Launcher/Properties/Resources.resx

   <data name="ConfigFileEmpty" xml:space="preserve">
     <value>Config file empty: </value>
   </data>
-  <data name="ConfigFileError" xml:space="preserve">
-    <value>Couldn't load config file. Error:{0}{1}</value>
-  </data>
   <data name="ConfigFileMissing" xml:space="preserve">
     <value>Config file missing: </value>
   </data>

src/MissileSharp.Launcher/ViewModels/MainWindowViewModel.cs

     public class MainWindowViewModel : INotifyPropertyChanged
     {
         private ICommandCenter model;
+        private ICommandCenterService commandCenterService;
         private IConfigService configService;
         private IMessageService messageService;
         private IShutdownService shutdownService;
 
         public MainWindowViewModel(ICommandCenterService commandCenterService, IConfigService configService, IMessageService messageService, IShutdownService shutdownService)
         {
+            this.commandCenterService = commandCenterService;
             this.configService = configService;
             this.messageService = messageService;
             this.shutdownService = shutdownService;
-            this.model = commandCenterService.GetCommandCenter();
 
             Initialize();
         }
 
             try
             {
+                this.model = this.commandCenterService.GetCommandCenter();
                 this.model.LoadCommandSets(this.configService.GetConfig());
             }
             catch (Exception ex)
             {
-                Shutdown(string.Format(Resources.ConfigFileError, Environment.NewLine, ex.Message));
+                Shutdown(ex.Message);
                 return;
             }
 

src/MissileSharp.Tests/Launcher/MainWindowViewModelTests.cs

         }
 
         [Test]
+        public void Initialize_GetCommandCenterThrows_AppShutsDown()
+        {
+            this.commandcenterservice.Setup(stub => stub.GetCommandCenter()).Throws<Exception>();
+            var viewmodel = SetupViewModel(this.commandcenterservice.Object);
+
+            this.shutdownservice.Verify(mock => mock.Shutdown());
+        }
+
+        [Test]
         public void Initialize_LoadCommandSetsThrows_AppShutsDown()
         {
-            this.commandcenter.Setup(stub => stub.LoadCommandSets(It.IsAny<string[]>())).Throws<NotImplementedException>();
+            this.commandcenter.Setup(stub => stub.LoadCommandSets(It.IsAny<string[]>())).Throws<Exception>();
             var viewmodel = SetupViewModel();
             this.shutdownservice.Verify(mock => mock.Shutdown());
         }