Ejemplo n.º 1
0
        public void TestAnnotations()
        {
            lock (testLock)
            {
                // Get the code namespace for the schema.
                string inputFilePath = GetInputFilePath("TestAnnotations.xsd", Resources.TestAnnotations);

                var generatorParams = new GeneratorParams {
                    InputFilePath = inputFilePath
                };
                GetGeneratorParams(inputFilePath);

                generatorParams.Miscellaneous.EnableSummaryComment = true;
                generatorParams.TargetFramework = TargetFramework.Net35;
                generatorParams.PropertyParams.AutomaticProperties = true;
                generatorParams.OutputFilePath = Path.ChangeExtension(generatorParams.InputFilePath,
                                                                      ".TestAnnotations.cs");

                var xsdGen = new GeneratorFacade(generatorParams);
                var result = xsdGen.Generate();

                Assert.IsTrue(result.Success, result.Messages.ToString());

                var compileResult = CompileCSFile(generatorParams.OutputFilePath);
                Assert.IsTrue(compileResult.Success, compileResult.Messages.ToString());
            }
        }
Ejemplo n.º 2
0
        public void GenarateVBCS()
        {
            lock (testLock)
            {
                // Get the code namespace for the schema.
                string inputFilePath = GetInputFilePath("Actor.xsd", Resources.Actor);

                var generatorParams = GetGeneratorParams(inputFilePath);
                generatorParams.TargetFramework = TargetFramework.Net30;
                generatorParams.PropertyParams.AutomaticProperties = true;
                generatorParams.GenerateDataContracts = true;
                generatorParams.Serialization.GenerateXmlAttributes = true;
                generatorParams.OutputFilePath    = GetOutputFilePath(inputFilePath);
                generatorParams.EnableDataBinding = true;
                generatorParams.Miscellaneous.EnableSummaryComment = true;
                generatorParams.Language = GenerationLanguage.VisualBasic;
                var xsdGen = new GeneratorFacade(generatorParams);
                var result = xsdGen.Generate();
                Assert.IsTrue(result.Success, result.Messages.ToString());

                generatorParams.Language = GenerationLanguage.CSharp;
                xsdGen = new GeneratorFacade(generatorParams);
                result = xsdGen.Generate();

                var canCompile = CompileCSFile(generatorParams.OutputFilePath);
                Assert.IsTrue(canCompile.Success, canCompile.Messages.ToString());
            }
        }
Ejemplo n.º 3
0
        public void ArrayOfArray()
        {
            lock (testLock)
            {
                // Copy resource file to the run-time directory
                var inputFilePath = GetInputFilePath("ArrayOfArray.xsd", Resources.ArrayOfArray);

                var generatorParams = new GeneratorParams
                {
                    GenerateCloneMethod  = true,
                    InputFilePath        = inputFilePath,
                    NameSpace            = "MyNameSpace",
                    CollectionObjectType = CollectionType.Array,
                    EnableDataBinding    = true,
                    Language             = GenerationLanguage.CSharp,
                    OutputFilePath       = Path.ChangeExtension(inputFilePath, ".TestGenerated.cs")
                };
                generatorParams.PropertyParams.AutomaticProperties = true;
                generatorParams.Serialization.Enabled = true;
                var xsdGen = new GeneratorFacade(generatorParams);
                var result = xsdGen.Generate();

                Assert.IsTrue(result.Success, result.Messages.ToString());

                var compileResult = CompileCSFile(generatorParams.OutputFilePath);
                Assert.IsTrue(compileResult.Success, compileResult.Messages.ToString());
            }
        }
Ejemplo n.º 4
0
        private void button10_Click(object sender, EventArgs e)
        {
            GeneratorFacade gen;

            gen = new GeneratorFacade(new MarkovGenerator(System.IO.File.ReadAllText("markov_data/data[okeypotolok.su].txt")));
            Console.WriteLine(gen.GenerateParagraphs(20));
        }
Ejemplo n.º 5
0
        public void UseBaseClass()
        {
            lock (testLock)
            {
                // Get the code namespace for the schema.
                GetInputFilePath("Actor.xsd", Resources.Actor);
                string inputFilePath = GetInputFilePath("dvd.xsd", Resources.dvd);

                string outputFilePath  = Path.ChangeExtension(inputFilePath, ".baseClass.cs");
                var    generatorParams = new GeneratorParams
                {
                    InputFilePath         = inputFilePath,
                    TargetFramework       = TargetFramework.Net30,
                    GenerateDataContracts = true,
                    EnableDataBinding     = true,
                    OutputFilePath        = outputFilePath
                };

                generatorParams.PropertyParams.AutomaticProperties = false;
                generatorParams.Miscellaneous.EnableSummaryComment = true;
                generatorParams.GenericBaseClass.Enabled           = true;
                generatorParams.GenericBaseClass.GenerateBaseClass = true;
                //generatorParams.GenericBaseClass.BaseClassName = "EntityObject";

                var xsdGen = new GeneratorFacade(generatorParams);
                var result = xsdGen.Generate();

                Assert.IsTrue(result.Success, result.Messages.ToString());

                var compileResult = CompileCSFile(generatorParams.OutputFilePath);
                Assert.IsTrue(compileResult.Success, compileResult.Messages.ToString());
            }
        }
Ejemplo n.º 6
0
        public void Nillables()
        {
            lock (testLock)
            {
                // Get the code namespace for the schema.
                string inputFilePath = GetInputFilePath("nillables.xsd", Resources.nillables);

                var generatorParams = GetGeneratorParams(inputFilePath);
                GetGeneratorParams(inputFilePath);

                generatorParams.Miscellaneous.EnableSummaryComment = true;
                generatorParams.TargetFramework = TargetFramework.Net35;
                generatorParams.PropertyParams.AutomaticProperties = true;
                generatorParams.EnableInitializeFields             = true;
                generatorParams.CollectionObjectType = CollectionType.List;


                var xsdGen = new GeneratorFacade(generatorParams);
                var result = xsdGen.Generate();

                Assert.IsTrue(result.Success, result.Messages.ToString());
                var compileResult = CompileCSFile(generatorParams.OutputFilePath);
                Assert.IsTrue(compileResult.Success, compileResult.Messages.ToString());
            }
        }
Ejemplo n.º 7
0
        public void SeparateFiles()
        {
            lock (testLock)
            {
                // Get the code namespace for the schema.
                string tvShowInputFilePath = GetInputFilePath("TVShow.xsd", Resources.TVShow);
                // copy included/imported files to the test folder
                GetInputFilePath("Actor.xsd", Resources.Actor);
                GetInputFilePath("Gender.xsd", Resources.Gender);

                var tvShowGeneratorParams = GetGeneratorParams(tvShowInputFilePath);
                GetGeneratorParams(tvShowInputFilePath);

                tvShowGeneratorParams.Miscellaneous.EnableSummaryComment = true;
                tvShowGeneratorParams.TargetFramework = TargetFramework.Net35;
                tvShowGeneratorParams.PropertyParams.AutomaticProperties = true;
                tvShowGeneratorParams.EnableInitializeFields             = true;
                tvShowGeneratorParams.CollectionObjectType  = CollectionType.List;
                tvShowGeneratorParams.GenerateSeparateFiles = true;
                tvShowGeneratorParams.OutputFilePath        = Path.ChangeExtension(tvShowGeneratorParams.InputFilePath, ".separate.cs");

                var           tvShowXsdGen      = new GeneratorFacade(tvShowGeneratorParams);
                var           tvShowResult      = tvShowXsdGen.Generate();
                List <string> tvShowOutputFiles = tvShowResult.Entity;
                Assert.IsTrue(tvShowResult.Success, tvShowResult.Messages.ToString());
                // compile TV show
                var compileResult = CompileCSFile(tvShowOutputFiles.ToArray());
                Assert.IsTrue(compileResult.Success, compileResult.Messages.ToString());
            }
        }
        public void T_GenerateParagraphs_Validate_Input()
        {
            GeneratorFacade facade = InitBaseFacade();

            Assert.Throws <Exceptions.InvalidArguments>(
                delegate { facade.GenerateParagraphs(0); });
            Assert.Throws <Exceptions.InvalidArguments>(
                delegate { facade.GenerateParagraphs(1, new ParagraphParams {
                    MaxSentences = 1
                }); });
            Assert.Throws <Exceptions.InvalidArguments>(
                delegate { facade.GenerateParagraphs(1, new ParagraphParams {
                    MinSentences = -1
                }); });
            Assert.Throws <Exceptions.InvalidArguments>(
                delegate { facade.GenerateParagraphs(1, new ParagraphParams {
                    MaxSentences = 4,
                    MinSentences = 5
                }); });
            Assert.Throws <Exceptions.InvalidArguments>(
                delegate { facade.GenerateParagraphs(1, new ParagraphParams {
                    ParagraphIndent = -1
                }); });
            Assert.Throws <Exceptions.InvalidArguments>(
                delegate { facade.GenerateParagraphs(1, new ParagraphParams {
                    SentenceIndent = -1
                }); });
        }
Ejemplo n.º 9
0
        public void AutomaticProperties()
        {
            lock (testLock)
            {
                // Get the code namespace for the schema.
                GetInputFilePath("Actor.xsd", Resources.Actor);
                string inputFilePath = GetInputFilePath("dvd.xsd", Resources.dvd);

                var generatorParams = new GeneratorParams {
                    InputFilePath = inputFilePath
                };
                GetGeneratorParams(inputFilePath);
                generatorParams.TargetFramework = TargetFramework.Net30;
                generatorParams.Miscellaneous.EnableSummaryComment = false;
                generatorParams.GenerateDataContracts = false;
                generatorParams.PropertyParams.AutomaticProperties  = true;
                generatorParams.Serialization.GenerateXmlAttributes = true;
                generatorParams.OutputFilePath = Path.ChangeExtension(generatorParams.InputFilePath, ".autoProp.cs");

                var xsdGen = new GeneratorFacade(generatorParams);
                var result = xsdGen.Generate();

                Assert.IsTrue(result.Success, result.Messages.ToString());

                var compileResult = CompileCSFile(generatorParams.OutputFilePath);
                Assert.IsTrue(compileResult.Success, compileResult.Messages.ToString());
            }
        }
Ejemplo n.º 10
0
        public void UseBaseClass()
        {
            lock (testLock)
            {
                // Get the code namespace for the schema.
                GetInputFilePath("Actor.xsd", Resources.Actor);
                string inputFilePath = GetInputFilePath("dvd.xsd", Resources.dvd);

                string outputFilePath  = Path.ChangeExtension(inputFilePath, ".baseClass.cs");
                var    generatorParams = new GeneratorParams
                {
                    InputFilePath         = inputFilePath,
                    TargetFramework       = TargetFramework.Net30,
                    GenerateDataContracts = true,
                    EnableDataBinding     = true,
                    OutputFilePath        = outputFilePath
                };

                generatorParams.PropertyParams.AutomaticProperties = false;
                generatorParams.Miscellaneous.EnableSummaryComment = true;
                generatorParams.GenericBaseClass.Enabled           = true;
                generatorParams.GenericBaseClass.GenerateBaseClass = true;
                generatorParams.GenericBaseClass.BaseClassName     = "EntityObject";

                var xsdGen = new GeneratorFacade(generatorParams);
                var result = xsdGen.Generate();

                Assert.IsTrue(result.Success, result.Messages.ToString());

                var compileResult = CompileCSFile(generatorParams.OutputFilePath);
                Assert.IsTrue(compileResult.Success, compileResult.Messages.ToString());

                // check if autogeneration-parameters are written to file
                var lastGenerationParamsFile = Path.ChangeExtension(inputFilePath, "xsd.xsd2code");
                if (File.Exists(lastGenerationParamsFile))
                {
                    if (File.GetLastWriteTime(lastGenerationParamsFile) > File.GetLastWriteTime(generatorParams.OutputFilePath))
                    {
                        File.Delete(lastGenerationParamsFile);
                        File.Copy(generatorParams.OutputFilePath, lastGenerationParamsFile);
                    }
                }
                else
                {
                    File.Copy(generatorParams.OutputFilePath, lastGenerationParamsFile);
                }

                var autogenParams = GeneratorParams.LoadFromFile(inputFilePath);
                Assert.AreEqual(autogenParams.TargetFramework, generatorParams.TargetFramework);
                Assert.AreEqual(autogenParams.GenerateDataContracts, generatorParams.GenerateDataContracts);
                Assert.AreEqual(autogenParams.EnableDataBinding, generatorParams.EnableDataBinding);
                Assert.AreEqual(autogenParams.PropertyParams.AutomaticProperties, generatorParams.PropertyParams.AutomaticProperties);
                Assert.AreEqual(autogenParams.Miscellaneous.EnableSummaryComment, generatorParams.Miscellaneous.EnableSummaryComment);
                Assert.AreEqual(autogenParams.GenericBaseClass.Enabled, generatorParams.GenericBaseClass.Enabled);
                Assert.AreEqual(autogenParams.GenericBaseClass.GenerateBaseClass, generatorParams.GenericBaseClass.GenerateBaseClass);
                Assert.AreEqual(autogenParams.GenericBaseClass.BaseClassName, generatorParams.GenericBaseClass.BaseClassName);
                File.Delete(lastGenerationParamsFile);
            }
        }
Ejemplo n.º 11
0
        private void GenerateAndCompile(GeneratorParams generatorParams, params string[] additionalFiles)
        {
            var xsdGen = new GeneratorFacade(generatorParams);
            var result = xsdGen.Generate();

            Assert.IsTrue(result.Success, result.Messages.ToString());

            var canCompile = CompileCSFile(generatorParams.OutputFilePath, additionalFiles);

            Assert.IsTrue(canCompile.Success, canCompile.Messages.ToString());
        }
Ejemplo n.º 12
0
        public void T_GenerateTitle_Length_And_Capitalization()
        {
            GeneratorFacade facade         = InitBaseFacade();
            string          resultingTitle = facade.GenerateTitle(9);

            string[] words = resultingTitle.Split(' ');
            Assert.AreEqual(9, words.Length);
            foreach (string word in words)
            {
                Assert.IsTrue(char.IsUpper(word[0]));
            }
        }
Ejemplo n.º 13
0
        public static void GenerateDomainSpecificInterface()
        {
            try
            {
                // Overwrite ParadigmName if DS interface is generated
                SolutionGenerator.ParadigmName = GeneratorFacade.main(MgaPath, TargetFolder + @"\" + SolutionName, "GME.CSharp." + SolutionName);

                if (GeneratorFacade.Errors.Count != 0)
                {
                    throw new Exception("Error occured during the domain specific interface generation.");
                }
            }
            catch (Exception)
            {
                object[] args = new object[1];
                args[0] = GeneratorFacade.Errors;
                if (GeneratorFacade.Errors.Count != 0)
                {
                    SolutionGenerator.mw.Dispatcher.Invoke(SolutionGenerator.mw.errorwindowdel, args);
                }
                throw;
            }

            // Add files to the projectfile
            string AddString = String.Empty;

            foreach (string s in GeneratorFacade.generatedFiles)
            {
                AddString += "\t<Compile Include=\"" + ParadigmName + @"\";
                AddString += System.IO.Path.GetFileName(s);
                AddString += "\" />";
                AddString += Environment.NewLine;
            }

            try
            {
                // Rename filereference in the csproj file
                StreamReader FileReadStream = new StreamReader(Path.Combine(TargetFolder, SolutionName) + @"\" + SolutionName + ".csproj");
                string       ContentString  = FileReadStream.ReadToEnd();
                FileReadStream.Close();

                ContentString = ContentString.Replace(@"<!--$ADDITIONALFILES$-->", AddString);

                StreamWriter FileWriteStream = new StreamWriter(Path.Combine(TargetFolder, SolutionName) + @"\" + SolutionName + ".csproj");
                FileWriteStream.Write(ContentString);
                FileWriteStream.Close();
            }
            catch (Exception)
            {
                MessageBox.Show("Error occured: Cannot find the previously generated VS projectfile in the specified folder with the specified solutionname.");
                throw;
            }
        }
Ejemplo n.º 14
0
        public void Throw_Exception_When_Database_Is_Null()
        {
            Assesment assesment = new Assesment();

            assesment.Name           = "Test";
            assesment.SourcePlatform = "OnPrem";
            assesment.Status         = "Completed";
            assesment.TargetPlatform = "Azure Managed Instance";
            //assesment.Databases = new List<Database>();
            assesment.ServerInstances = new List <ServerInstance>();
            Assert.Throws <InvalidDataException>
                (() => GeneratorFacade.Generate(assesment));
        }
Ejemplo n.º 15
0
        static void Main(string[] args)
        {
            Console.WriteLine("Test starting");
            GeneratorFacade gen = new GeneratorFacade(TimeMarkovConstructor());

            TimeGenerateWords(gen, 10, 10000);
            TimeGenerateWords(gen, 10000, 10);
            TimeGenerateSentences(gen, 10000);
            TimeGenerateParagraphs(gen, 500, 10);
            TimeGenerateParagraphs(gen, 10, 500);
            Console.WriteLine("Test complete");
            Console.ReadLine();
        }
Ejemplo n.º 16
0
        public void T_GenerateParagraphs_Length()
        {
            GeneratorFacade facade = InitBaseFacade();
            //seven sentences should be generated
            string resultStr = facade.GenerateParagraphs(3, new ParagraphParams
            {
                MinSentences = 7, MaxSentences = 7
            });

            string[] splitSentences = resultStr.Split(facade.Generator.SentenceEnd.ToArray(),
                                                      StringSplitOptions.RemoveEmptyEntries);
            Assert.AreEqual(21, splitSentences.Length);
        }
Ejemplo n.º 17
0
        public void Circular()
        {
            lock (testLock)
            {
                // Copy resource file to the run-time directory
                string inputFilePath = GetInputFilePath("Circular.xsd", Resources.Circular);

                var xsdGen = new GeneratorFacade(GetGeneratorParams(inputFilePath));
                var result = xsdGen.Generate();

                Assert.IsTrue(result.Success, result.Messages.ToString());
            }
        }
Ejemplo n.º 18
0
        public void Works_Properly_When_Valid_Input_Is_Given()
        {
            Assesment assesment = new Assesment();

            assesment.Name            = "Test";
            assesment.SourcePlatform  = "OnPrem";
            assesment.Status          = "Completed";
            assesment.TargetPlatform  = "Azure Managed Instance";
            assesment.Databases       = new List <Database>();
            assesment.ServerInstances = new List <ServerInstance>();
            var table = GeneratorFacade.Generate(assesment);

            Assert.NotNull(table);
        }
Ejemplo n.º 19
0
        static void TimeGenerateSentences(GeneratorFacade gen, int numSentences)
        {
            Stopwatch timer = new Stopwatch();

            timer.Start();
            for (int i = 0; i < numSentences; i++)
            {
                gen.GenerateSentence(3);
            }
            timer.Stop();
            double baseGenTime = timer.ElapsedMilliseconds / 1000.0;

            Console.WriteLine(string.Format("Time to generate {0} sentences: {1:0.00} seconds",
                                            numSentences, baseGenTime));
        }
Ejemplo n.º 20
0
        private Task <ConcurrentBag <string> > RunGenerator(IGenerator[]?generators = null, bool shareGlobalWriters = false)
        {
            generators ??= new[] { this.generator };
            var generatorSetups = generators.ConvertAll(x =>
                                                        new GeneratorSetup(new TypeOrObject <IGenerator>(x), null, false, shareGlobalWriters));

            return(GeneratorFacade.RunAsync(
                       new GeneratorOptions {
                ProgressReporter = this.progressReporter
            },
                       new Setup(
                           new ModelSetup(new TypeOrObject <IModelProvider>(this.modelProvider), typeof(object)),
                           new[] { new WriterSetup("AnyTarget", new TypeOrObject <IWriter>(this.writer)) },
                           generatorSetups !)));
        }
Ejemplo n.º 21
0
        static void TimeGenerateWords(GeneratorFacade gen, int numIterations, int numWords)
        {
            Stopwatch timer = new Stopwatch();

            timer.Start();
            for (int i = 0; i < numIterations; i++)
            {
                gen.GenerateWords(numWords);
            }
            timer.Stop();
            double baseGenTime = timer.ElapsedMilliseconds / 1000.0;

            Console.WriteLine(string.Format("Time to generate {0}x{1} words: {2:0.00} seconds",
                                            numIterations, numWords, baseGenTime));
        }
Ejemplo n.º 22
0
        public void Hierarchical()
        {
            lock (testLock)
            {
                // Copy resource file to the run-time directory
                string inputFilePath = GetInputFilePath("Hierarchical.xsd", Resources.Hierarchical);

                var generatorParams = GetGeneratorParams(inputFilePath);
                var xsdGen          = new GeneratorFacade(generatorParams);
                var result          = xsdGen.Generate();

                Assert.IsTrue(result.Success, result.Messages.ToString());

                var compileResult = CompileCSFile(generatorParams.OutputFilePath);
                Assert.IsTrue(compileResult.Success, compileResult.Messages.ToString());
            }
        }
Ejemplo n.º 23
0
        public void HexBinary()
        {
            lock (testLock)
            {
                // Copy resource file to the run-time directory
                string inputFilePath = GetInputFilePath("hexBinary.xsd", Resources.hexBinary);

                var generatorParams = GetGeneratorParams(inputFilePath);
                generatorParams.EnableInitializeFields = true;
                var xsdGen = new GeneratorFacade(generatorParams);
                var result = xsdGen.Generate();

                Assert.IsTrue(result.Success, result.Messages.ToString());

                var compileResult = CompileCSFile(generatorParams.OutputFilePath);
                Assert.IsTrue(compileResult.Success, compileResult.Messages.ToString());
            }
        }
Ejemplo n.º 24
0
        public void T_GenerateParagraphs_Indentation()
        {
            GeneratorFacade facade        = InitBaseFacade();
            ParagraphParams defaultParams = new ParagraphParams {
                ParagraphIndent = 8, SentenceIndent = 4
            };
            string        resultStr = facade.GenerateParagraphs(5, defaultParams);
            StringBuilder sb        = new StringBuilder();

            for (int i = 0; i < defaultParams.ParagraphIndent; i++)
            {
                sb.Append(" ");
            }
            string paragraphIndent = sb.ToString();

            sb.Length = 0;

            for (int i = 0; i < defaultParams.SentenceIndent; i++)
            {
                sb.Append(" ");
            }
            string sentenceIndent = sb.ToString();

            sb.Length = 0;
            string[] paragraphSplits = resultStr.Split(new string[] { paragraphIndent }, StringSplitOptions.RemoveEmptyEntries);

            //Verify we got 5 paragraphs
            Assert.AreEqual(5, paragraphSplits.Length);
            foreach (string paragraph in paragraphSplits)
            {
                string   trimmedParagraph = paragraph.TrimEnd();
                string[] sentenceSplits   = trimmedParagraph.Split(new string[] { sentenceIndent }, StringSplitOptions.RemoveEmptyEntries);
                //Check sentences are of appropriate sizes
                Assert.GreaterOrEqual(sentenceSplits.Length, defaultParams.MinSentences);
                Assert.LessOrEqual(sentenceSplits.Length, defaultParams.MaxSentences);

                //Check sentences actually end with a punctuation mark
                foreach (string sentence in sentenceSplits)
                {
                    Assert.Contains(sentence[sentence.Length - 1], facade.Generator.SentenceEnd);
                }
            }
        }
Ejemplo n.º 25
0
        public MarkovGen(string path)
        {
            if (!File.Exists(path))
            {
                throw new FileNotFoundException("Попробуйте указать правильный путь к файлу!");
            }
            if ((new FileInfo(path)).Length <= 0)
            {
                throw new NullReferenceException("Файл пуст!");
            }

            this.working_dir = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "/" + this.working_dir;
            this.gen         = new GeneratorFacade(new MarkovGenerator(System.IO.File.ReadAllText(path)));

            if (!Directory.Exists(working_dir))
            {
                Directory.CreateDirectory(working_dir);
            }
        }
Ejemplo n.º 26
0
        public void LazyLoading()
        {
            lock (testLock)
            {
                // Copy resource file to the run-time directory
                string inputFilePath   = GetInputFilePath("LazyLoading.xsd", Resources.LazyLoading);
                var    generatorParams = GetGeneratorParams(inputFilePath);
                generatorParams.CollectionObjectType             = CollectionType.List;
                generatorParams.TargetFramework                  = TargetFramework.Net20;
                generatorParams.PropertyParams.EnableLazyLoading = true;
                generatorParams.EnableInitializeFields           = true;

                var xsdGen = new GeneratorFacade(generatorParams);
                xsdGen.Generate();

                var compileResult = CompileCSFile(generatorParams.OutputFilePath);
                Assert.IsTrue(compileResult.Success, compileResult.Messages.ToString());
            }
        }
Ejemplo n.º 27
0
        public void AlowDebug()
        {
            lock (testLock)
            {
                // Copy resource file to the run-time directory
                GetInputFilePath("Actor.xsd", Resources.Actor);
                string inputFilePath = GetInputFilePath("Dvd.xsd", Resources.dvd);

                var generatorParams = GetGeneratorParams(inputFilePath);
                generatorParams.Miscellaneous.DisableDebug = false;
                generatorParams.OutputFilePath             = Path.ChangeExtension(generatorParams.InputFilePath, ".DebugEnabled.cs");

                var xsdGen = new GeneratorFacade(generatorParams);
                var result = xsdGen.Generate();

                Assert.IsTrue(result.Success, result.Messages.ToString());

                var compileResult = CompileCSFile(generatorParams.OutputFilePath);
                Assert.IsTrue(compileResult.Success, compileResult.Messages.ToString());
            }
        }
Ejemplo n.º 28
0
        public void Silverlight()
        {
            lock (testLock)
            {
                // Get the code namespace for the schema.
                GetInputFilePath("Actor.xsd", Resources.Actor);
                string inputFilePath = GetInputFilePath("dvd.xsd", Resources.dvd);

                var generatorParams = GetGeneratorParams(inputFilePath);
                generatorParams.TargetFramework = TargetFramework.Silverlight;
                generatorParams.OutputFilePath  = Path.ChangeExtension(generatorParams.InputFilePath,
                                                                       ".Silverlight20_01.cs");

                generatorParams.Serialization.Enabled        = true;
                generatorParams.Serialization.EnableEncoding = true;
                var xsdGen = new GeneratorFacade(generatorParams);

                var result = xsdGen.Generate();
                Assert.IsTrue(result.Success, result.Messages.ToString());
            }
        }
Ejemplo n.º 29
0
        public void WcfAttributes()
        {
            lock (testLock)
            {
                // Get the code namespace for the schema.
                GetInputFilePath("Actor.xsd", Resources.Actor);
                string inputFilePath = GetInputFilePath("dvd.xsd", Resources.dvd);

                var generatorParams = GetGeneratorParams(inputFilePath);
                generatorParams.GenerateDataContracts = true;
                generatorParams.TargetFramework       = TargetFramework.Net30;
                generatorParams.OutputFilePath        = Path.ChangeExtension(generatorParams.InputFilePath, ".wcf.cs");

                var xsdGen = new GeneratorFacade(generatorParams);
                var result = xsdGen.Generate();

                Assert.IsTrue(result.Success, result.Messages.ToString());

                var compileResult = CompileCSFile(generatorParams.OutputFilePath);
                Assert.IsTrue(compileResult.Success, compileResult.Messages.ToString());
            }
        }
Ejemplo n.º 30
0
        public void PropertyNameSpecified()
        {
            lock (testLock)
            {
                // Copy resource file to the run-time directory
                string inputFilePath   = GetInputFilePath("PropertyNameSpecified.xsd", Resources.PropertyNameSpecified);
                var    generatorParams = GetGeneratorParams(inputFilePath);
                generatorParams.TargetFramework       = TargetFramework.Net20;
                generatorParams.Serialization.Enabled = false;
                generatorParams.Miscellaneous.HidePrivateFieldInIde = false;

                // All
                generatorParams.PropertyParams.GeneratePropertyNameSpecified = PropertyNameSpecifiedType.All;
                generatorParams.OutputFilePath = Path.ChangeExtension(generatorParams.InputFilePath, ".all.cs");
                var xsdGen = new GeneratorFacade(generatorParams);
                var result = xsdGen.Generate();

                var compileResult = CompileCSFile(generatorParams.OutputFilePath);
                Assert.IsTrue(compileResult.Success, compileResult.Messages.ToString());

                // none
                generatorParams.PropertyParams.GeneratePropertyNameSpecified = PropertyNameSpecifiedType.None;
                generatorParams.OutputFilePath = Path.ChangeExtension(generatorParams.InputFilePath, ".none.cs");
                xsdGen = new GeneratorFacade(generatorParams);
                result = xsdGen.Generate();

                compileResult = CompileCSFile(generatorParams.OutputFilePath);
                Assert.IsTrue(compileResult.Success, compileResult.Messages.ToString());

                // Default
                generatorParams.PropertyParams.GeneratePropertyNameSpecified = PropertyNameSpecifiedType.Default;
                generatorParams.OutputFilePath = Path.ChangeExtension(generatorParams.InputFilePath, ".default.cs");
                xsdGen = new GeneratorFacade(generatorParams);
                result = xsdGen.Generate();

                compileResult = CompileCSFile(generatorParams.OutputFilePath);
                Assert.IsTrue(compileResult.Success, compileResult.Messages.ToString());
            }
        }