Exemplo n.º 1
0
 public KarmaServer(KarmaSettings settings, ITestLogger logger)
     : base(logger)
 {
     if (!settings.AreValid)
     {
         throw new ArgumentException("Settings are not valid", "settings");
     }
     Settings = settings;
 }
Exemplo n.º 2
0
        protected override void Init()
        {
            Settings = new KarmaSettings(Name, Source, f => File.Exists(f), BaseDirectory, Logger);
            Validate(Settings.AreValid, Settings.InvalidReason);
            if (Settings.AreValid)
            {
                if (Settings.HasSettingsFile)
                {
                    Validate(Project.HasFile(Settings.SettingsFile), "File {1} is not included in project {0}", Project.GetProjectName(), GetRelativePath(Settings.SettingsFile));
                    Validate(Discoverer.ServiceProvider.HasFile(Settings.KarmaConfigFile), "File {0} is not included in solution", GetRelativePath(Settings.KarmaConfigFile));
                }
                else
                {
                    Validate(Project.HasFile(Settings.KarmaConfigFile), "File {1} is not included in project {0}", Project.GetProjectName(), GetRelativePath(Settings.KarmaConfigFile));
                }
            }

            if (Settings.Disabled)
            {
                Validate(false, string.Format("Karma is disabled in {0}", GetRelativePath(Settings.SettingsFile)));
            }
        }
        protected override void Init()
        {
            Settings = new KarmaSettings(Name, Source, f => File.Exists(f), BaseDirectory, Logger);
            Validate(Settings.AreValid, Settings.InvalidReason);
            if (Settings.AreValid)
            {
                if (Settings.HasSettingsFile)
                {
                    Validate(Project.HasFile(Settings.SettingsFile), "File {1} is not included in project {0}", Project.GetProjectName(), GetRelativePath(Settings.SettingsFile));
                    Validate(Discoverer.ServiceProvider.HasFile(Settings.KarmaConfigFile), "File {0} is not included in solution", GetRelativePath(Settings.KarmaConfigFile));
                }
                else
                {
                    Validate(Project.HasFile(Settings.KarmaConfigFile), "File {1} is not included in project {0}", Project.GetProjectName(), GetRelativePath(Settings.KarmaConfigFile));
                }
            }

            if (Settings.Disabled)
            {
                Validate(false, string.Format("Karma is disabled in {0}", GetRelativePath(Settings.SettingsFile)));
            }
        }
Exemplo n.º 4
0
 public async Task PopulateKarmaSpecs()
 {
     if (IsValid && _karmaSpecs == null)
     {
         Globals.IsTest = true;
         var karmaSpecs = new List<Spec>();
         var settings = new KarmaSettings(Name, KarmaConfig, f => File.Exists(f), BaseDirectory, Logger);
         if (settings.AreValid)
         {
             try
             {
                 var server = new KarmaServer(settings, Logger);
                 server.OutputReceived += line => _karmaOutput.Add(line);
                 server.ErrorReceived += line => _karmaOutput.Add(line);
                 var port = await server.StartServer(60000);
                 var stopCommand = new StopCommand(port);
                 var discoverCommand = new DiscoverCommand(port);
                 await discoverCommand.Run(spec => karmaSpecs.Add(spec));
                 await stopCommand.Run();
                 await server.Finished;
                 _karmaSpecs = karmaSpecs;
                 Logger.Info("{0} specs discovered", _karmaSpecs.Count());
             }
             catch (AggregateException ex)
             {
                 _validator.Validate(false, ex.InnerExceptions.First().Message);
             }
             catch (Exception ex)
             {
                 _validator.Validate(false, ex.Message);
             }
         }
         else
         {
             _validator.Validate(false, settings.InvalidReason);
         }
     }
 }