private void initialize(SharpSerializerXmlSettings settings)
        {
            // PropertiesToIgnore
            PropertyProvider.PropertiesToIgnore = settings.AdvancedSettings.PropertiesToIgnore;
            PropertyProvider.AttributesToIgnore = settings.AdvancedSettings.AttributesToIgnore;
            //RootName
            RootName = settings.AdvancedSettings.RootName;
            // TypeNameConverter)
            ITypeNameConverter typeNameConverter = settings.AdvancedSettings.TypeNameConverter ??
                                                   DefaultInitializer.GetTypeNameConverter(
                settings.IncludeAssemblyVersionInTypeName,
                settings.IncludeCultureInTypeName,
                settings.IncludePublicKeyTokenInTypeName);
            // SimpleValueConverter
            ISimpleValueConverter simpleValueConverter = settings.AdvancedSettings.SimpleValueConverter ??
                                                         DefaultInitializer.GetSimpleValueConverter(settings.Culture, typeNameConverter);
            // XmlWriterSettings
            XmlWriterSettings xmlWriterSettings = DefaultInitializer.GetXmlWriterSettings(settings.Encoding);
            // XmlReaderSettings
            XmlReaderSettings xmlReaderSettings = DefaultInitializer.GetXmlReaderSettings();

            // Create Serializer and Deserializer
            var reader = new DefaultXmlReader(typeNameConverter, simpleValueConverter, xmlReaderSettings);
            var writer = new DefaultXmlWriter(typeNameConverter, simpleValueConverter, xmlWriterSettings);

            _serializer   = new XmlPropertySerializer(writer);
            _deserializer = new XmlPropertyDeserializer(reader);
        }
Beispiel #2
0
        internal int ExecuteValidCommandLine(CmdLineHandler clh, IRecipe recipe)
        {
            var result = 0;

            SetUpCategorySelector("testCategory", clh, recipe);
            SetUpCategorySelector("fixtureCategory", clh, recipe);
            SetUpRegexSelector(clh, recipe);

            DefaultXmlWriter resultWriter = null;

            if (clh.HasOption("xml"))
            {
                var resultPathName = clh.GetOptionValueFor("xml");
                resultPathName = resultPathName == string.Empty ? "csUnit.results.xml" : resultPathName;
                resultWriter   = new DefaultXmlWriter(recipe, resultPathName);
            }

            recipe.Aborted += RecipeAborted;
            recipe.RunTests(new TestRun(new AllTestsCriterion()));

            recipe.Join();

            if (resultWriter != null)
            {
                resultWriter.Save();
                result = resultWriter.Result;
            }
            if (result == 0 && _recipeAborted)
            {
                Console.Error.WriteLine("Tests Aborted: " + _recipeAbortMessage);
                result = 2;
            }
            return(result);
        }
Beispiel #3
0
 public SaveResultsAsXmlCommand(ICommandTarget commandTarget, CsUnitControl csUnitCtrl)
     : base(commandTarget, csUnitCtrl, "&File", "Save Result As &XML...", _menuPosition, true)
 {
     _results              = new DefaultXmlWriter(RecipeFactory.Current, string.Empty);
     RecipeFactory.Loaded += RecipeFactory_Loaded;
     Enabled = false;
 }
Beispiel #4
0
        public void WriteToStream(Stream os, Object obj)
        {
            DefaultXmlWriter writer = new DefaultXmlWriter(new AppendableStreamEncoder(os, Encoding.UTF8), XmlController);

            WritePrefix(writer);
            writer.WriteObject(obj);
            PostProcess(writer);
            WritePostfix(writer);
            os.Flush();
        }
Beispiel #5
0
        public String PrintCUDResult(ICUDResult cudResult, IIncrementalMergeState state)
        {
            StringBuilder    sb     = new StringBuilder();
            DefaultXmlWriter writer = new DefaultXmlWriter(new AppendableStringBuilder(sb), null);

            writer.SetBeautifierActive(true);
            writer.SetBeautifierLinebreak("\n");

            WriteCUDResult(cudResult, writer, (IncrementalMergeState)state);
            return(sb.ToString());
        }
Beispiel #6
0
        public String Write(Object obj)
        {
            StringBuilder    sb     = new StringBuilder();
            DefaultXmlWriter writer = new DefaultXmlWriter(new AppendableStringBuilder(sb), XmlController);

            WritePrefix(writer);
            writer.WriteObject(obj);
            PostProcess(writer);
            WritePostfix(writer);
            return(sb.ToString());
        }
Beispiel #7
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            var config = new ConfigCurrentUser();

            Location = config.MainFormLocation;
            Size     = config.MainFormSize;

            Command.CreateCommands(this, _csUnitControl);
            Command.FillToolStrip(_toolStrip);

            if (_clh.HasOption("recipe"))
            {
                if (Utils.FileExists(_clh.GetOptionValueFor("recipe"), true))
                {
                    RecipeFactory.Load(_clh.GetOptionValueFor("recipe"));
                }
            }
            else if (_clh.HasOption("assembly"))
            {
                if (Utils.FileExists(_clh.GetOptionValueFor("assembly"), true))
                {
                    var assemblyPathName = _clh.GetOptionValueFor("assembly");
                    if (!Path.IsPathRooted(assemblyPathName))
                    {
                        assemblyPathName = Path.Combine(Environment.CurrentDirectory, assemblyPathName);
                    }
                    RecipeFactory.Current.AddAssembly(assemblyPathName);
                }
            }
            else
            {
                switch (config.StartupLoadItem)
                {
                case "Recipe":
                    if (config.RecentRecipies.Count > 0 &&
                        Utils.FileExists(config.RecentRecipies[0], true))
                    {
                        RecipeFactory.Load(config.RecentRecipies[0]);
                    }
                    break;

                case "Assembly":
                    if (config.RecentAssemblies.Count > 0 &&
                        Utils.FileExists(config.RecentAssemblies[0], true))
                    {
                        RecipeFactory.Current.AddAssembly(config.RecentAssemblies[0]);
                    }
                    break;
                }
            }

            // Setup the xml handler
            if (_clh.HasOption("xml"))
            {
                _xmlWriter = new DefaultXmlWriter(RecipeFactory.Current, _clh.GetOptionValueFor("xml"));
            }

            // Automatically start the recipe
            if (_clh.HasOption("autorun"))
            {
                if (RecipeFactory.Current != null)
                {
                    var testRun = new TestRun(new AllTestsCriterion());
                    RecipeFactory.Current.RunTests(testRun);
                }
            }
        }
Beispiel #8
0
        private void initialize(SharpSerializerXmlSettings settings)
        {
            // PropertiesToIgnore
            PropertyProvider.PropertiesToIgnore = settings.AdvancedSettings.PropertiesToIgnore;
            PropertyProvider.AttributesToIgnore = settings.AdvancedSettings.AttributesToIgnore;
            //RootName
            RootName = settings.AdvancedSettings.RootName;
            // TypeNameConverter)
            ITypeNameConverter typeNameConverter = settings.AdvancedSettings.TypeNameConverter ??
                                                   DefaultInitializer.GetTypeNameConverter(
                                                       settings.IncludeAssemblyVersionInTypeName,
                                                       settings.IncludeCultureInTypeName,
                                                       settings.IncludePublicKeyTokenInTypeName);
            // SimpleValueConverter
            ISimpleValueConverter simpleValueConverter = settings.AdvancedSettings.SimpleValueConverter ??
                                                         DefaultInitializer.GetSimpleValueConverter(settings.Culture, typeNameConverter);
            // XmlWriterSettings
            XmlWriterSettings xmlWriterSettings = DefaultInitializer.GetXmlWriterSettings(settings.Encoding);
            // XmlReaderSettings
            XmlReaderSettings xmlReaderSettings = DefaultInitializer.GetXmlReaderSettings();

            // Create Serializer and Deserializer
            var reader = new DefaultXmlReader(typeNameConverter, simpleValueConverter, xmlReaderSettings);
            var writer = new DefaultXmlWriter(typeNameConverter, simpleValueConverter, xmlWriterSettings);

            _serializer = new XmlPropertySerializer(writer);
            _deserializer = new XmlPropertyDeserializer(reader);
        }
Beispiel #9
0
 protected virtual void PostProcess(DefaultXmlWriter writer)
 {
     // Intended blank
 }
Beispiel #10
0
 void RecipeFactory_Loaded(object sender, RecipeEventArgs args)
 {
     _results = new DefaultXmlWriter(RecipeFactory.Current, string.Empty);
     RecipeFactory.Current.Finished += Current_Finished;
     Enabled = false;
 }