public void RemoteRun(string settings)
        {
            var materializedSettings = new SilverlightUnitTestRunSettings();

            try
            {
                materializedSettings = _serializationService.Deserialize<SilverlightUnitTestRunSettings>(settings);
            }
            catch (Exception)
            {

            }

            Run(materializedSettings);
        }
        public void Run(SilverlightUnitTestRunSettings settings)
        {
            UnitTestSettings unitTestSettings = MyUnitTestSystem.CreateDefaultSettings(settings);

            _testPage = MyUnitTestSystem.CreateTestPage(unitTestSettings) as LighthouseUnitTestRunnerPage;

            if (_testPage != null)
            {
                var userControl = Application.Current.RootVisual as UserControl;

                if (userControl != null)
                {
                    userControl.Content = _testPage;
                    userControl.Focus();

                    try
                    {
                        _testPage.StartTesting();
                    }
                    catch (Exception e)
                    {
                        ReportError(e);
                        PublishResultsWithError(e);
                    }
                }
                else
                {
                    ReportError(new Exception("Could not assign new RootVisual"));
                }
            }
        }
Ejemplo n.º 3
0
        public static UnitTestSettings CreateDefaultSettings(SilverlightUnitTestRunSettings silverlightUnitTestRunSettings)
        {
            var settings = new UnitTestSettings();
            settings.ShowTagExpressionEditor = false;
            settings.SampleTags = new List<string>();
            settings.TagExpression = null;

            if (silverlightUnitTestRunSettings != null)
            {
                if (silverlightUnitTestRunSettings.AssembliesThatContainTests.Any())
                {
                    foreach (var assemblyPartDllName in silverlightUnitTestRunSettings.AssembliesThatContainTests)
                    {
                        var partDllNameCopy = assemblyPartDllName;
                        var foundAssemblyPart = Deployment.Current.Parts.FirstOrDefault(p => p.Source == partDllNameCopy);
                        if (foundAssemblyPart != null)
                        {
                            var sri = Application.GetResourceStream(new Uri(foundAssemblyPart.Source, UriKind.Relative));
                            var assembly = new AssemblyPart().Load(sri.Stream);
                            settings.TestAssemblies.Add(assembly);
                        }
                    }
                }

                if (!string.IsNullOrWhiteSpace(silverlightUnitTestRunSettings.TagFilter))
                {
                    settings.TagExpression = silverlightUnitTestRunSettings.TagFilter;
                }
            }

            SetStandardLogProviders(settings);
            settings.TestHarness = new LighthouseUnitTestHarness();
            settings.TestHarness.Settings = settings;
            // Sets initial but user can override
            SetTestService(settings);
            return settings;
        }