Exemple #1
0
        public void LineProcessor_ShouldReturnResultsOfSecondProcessing_WhenProcessTwoLinesOnRow()
        {
            // ARRANGE
            ILineProcessor lineProcessor = new LineProcessor <MockLineSegment>();
            string         lineText1     = "My <bold> text </bold> have <s> 4 </s> tags";
            string         lineText2     = "<bold>My text </bold> <u> have </u> <s> 7 segments</s>";

            // ACT
            lineProcessor.ProcessLine(lineText1);
            lineProcessor.ProcessLine(lineText2);

            // ASSERT
            Assert.AreEqual(lineText2, string.Join(string.Empty, lineProcessor.Segments.Select(s => s.DisplayText)));
            Assert.AreEqual(13, lineProcessor.Segments.Count());
            Assert.AreEqual(6, lineProcessor.Segments.Count(s => s.IsTag));
        }
Exemple #2
0
        public void MustProcessUseLine()
        {
            // Simple Use
            var processor     = new LineProcessor(new MsSqlType("mssql.sql"), new MySqlType("mysql.sql"));
            var mssqlLine     = "USE [encontact]";
            var mysqlLine     = processor.ProcessLine(mssqlLine);
            var expectedMySql = "USE encontact;";

            Assert.Equal(expectedMySql, mysqlLine);

            // With GO Use
            mssqlLine     = @"USE [encontact]
GO";
            mysqlLine     = processor.ProcessLine(mssqlLine);
            expectedMySql = @"USE encontact
;";
            Assert.Equal(expectedMySql, mysqlLine);
        }
Exemple #3
0
        public void MustProcessEmptyLine()
        {
            // Simple Insert
            var processor     = new LineProcessor(new MsSqlType("mssql.sql"), new MySqlType("mysql.sql"));
            var mssqlLine     = "";
            var mysqlLine     = processor.ProcessLine(mssqlLine);
            var expectedMySql = "";

            Assert.Equal(expectedMySql, mysqlLine);
        }
Exemple #4
0
        public void MustProcessSetLine()
        {
            // Simple Insert
            var processor     = new LineProcessor(new MsSqlType("mssql.sql"), new MySqlType("mysql.sql"));
            var mssqlLine     = "SET IDENTITY_INSERT [dbo].[accounts] ON";
            var mysqlLine     = processor.ProcessLine(mssqlLine);
            var expectedMySql = "";

            Assert.Equal(expectedMySql, mysqlLine);
        }
Exemple #5
0
        public void MustProcessInsertLine()
        {
            // Simple Insert
            var processor     = new LineProcessor(new MsSqlType("mssql.sql"), new MySqlType("mysql.sql"));
            var mssqlLine     = "INSERT [dbo].[accounts] ([id], [create_date], [name], [email], [username], [password], [is_active], [deleted], [ClientId], [AuthMethod], [ProfileId]) VALUES (1, CAST(N'2015-03-27T10:44:10.323' AS DateTime), N'Admin', N'*****@*****.**', N'*****@*****.**', N'481F6CC0511143CCDD7E2D1B1B94FAF0A700A8B49CD13922A70B5AE28ACAA8C5', 1, 0, 0, 0, 1)";
            var mysqlLine     = processor.ProcessLine(mssqlLine);
            var expectedMySql = "INSERT accounts (id, create_date, name, email, username, password, is_active, deleted, ClientId, AuthMethod, ProfileId) VALUES (1, CAST(N'2015-03-27T10:44:10.323' AS DateTime), N'Admin', N'*****@*****.**', N'*****@*****.**', N'481F6CC0511143CCDD7E2D1B1B94FAF0A700A8B49CD13922A70B5AE28ACAA8C5', 1, 0, 0, 0, 1);";

            Assert.Equal(expectedMySql, mysqlLine);
        }
Exemple #6
0
        public void LineProcessor_ShouldReturnSegmentsEquivalentToTheOriginalText()
        {
            // ARRANGE
            ILineProcessor lineProcessor = new LineProcessor <MockLineSegment>();
            string         lineText      = "My <bold> text </bold> have <s> 4 </s> tags";

            // ACT
            lineProcessor.ProcessLine(lineText);

            // ASSERT
            Assert.AreEqual(lineText, string.Join(string.Empty, lineProcessor.Segments.Select(s => s.DisplayText)));
        }
Exemple #7
0
        public void LineProcessor_ShouldReturn4TagSegments_WhenReceiveLineWith4Tags()
        {
            // ARRANGE
            ILineProcessor lineProcessor = new LineProcessor <MockLineSegment>();
            string         lineText      = "My <bold> text </bold> have <s> 4 </s> tags";

            // ACT
            lineProcessor.ProcessLine(lineText);

            // ASSERT
            Assert.AreEqual(4, lineProcessor.Segments.Count(s => s.IsTag));
        }
Exemple #8
0
        public void LineProcessor_ShouldReturn9Segments_WhenReceiveLineWith4InnerTags()
        {
            // ARRANGE
            ILineProcessor lineProcessor = new LineProcessor <MockLineSegment>();
            string         lineText      = "My <bold> text </bold> have <s> 9 </s> segments";

            // ACT
            lineProcessor.ProcessLine(lineText);

            // ASSERT
            Assert.AreEqual(9, lineProcessor.Segments.Count());
        }
Exemple #9
0
        public void LineProcessor_ShouldReturn9Segments_WhenReceiveLineWith4TagsSurroundedByWhiteSpaces()
        {
            // ARRANGE
            ILineProcessor lineProcessor = new LineProcessor <MockLineSegment>();
            string         lineText      = "   <bold>My text </bold> have <s> 9 segments</s>   ";

            // ACT
            lineProcessor.ProcessLine(lineText);

            // ASSERT
            Assert.AreEqual(9, lineProcessor.Segments.Count());
        }
Exemple #10
0
        /// <summary>
        /// Inspect the template to process and construct the input and output file
        /// names from it. Together with the info from the datatype to process.
        /// </summary>
        private void ConstructInputOutputFilenames()
        {
            string templatefilename
                = GetXmlValue(m_templateDefinition.SelectSingleNode("templatefilename"), "");

            if (templatefilename == "")
            {
                throw new ApplicationException("templatefilename is mandatory in template definitions file");
            }

            string directory_expression
                = "";

            // We maken een LineProcessor voor het interpreteren van de tekst van de directory en filenaam.
            LineProcessor lp = new LineProcessor(m_current, new Hashtable(), new Hashtable(), new StringCollection(), new StringCollection(), m_log, m_KeepInfo, m_FunctionInfo, GetCurrentTemplatename(), null);

            lp.AddObserver(this);

            try
            {
                directory_expression = m_templateDefinition.SelectSingleNode("directory").InnerText;
                if (directory_expression.Contains("@"))
                {
                    m_outputfilename = lp.ProcessLine(directory_expression);
                }
                else
                {
                    m_outputfilename = directory_expression;
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException("Directory expression '" + directory_expression + "' results in error: " + ex.Message);
            }

            if (m_outputfilename == "")
            {
                throw new ApplicationException("Directory expression '" + directory_expression + "' results in empty directoryname for template: " + m_templateDefinition.SelectSingleNode("name").InnerText);
            }

            if (!m_outputfilename.EndsWith(@"\"))
            {
                m_outputfilename += @"\";
            }

            string filename_expression
                = m_templateDefinition.SelectSingleNode("filename").InnerText;
            string filename = "";

            try
            {
                filename = lp.ProcessLine(filename_expression);
            }
            catch (Exception ex)
            {
                throw new ApplicationException("Filename expression '" + filename_expression + "' results in error: " + ex.Message);
            }
            if (filename == "")
            {
                throw new ApplicationException("Filename expression '" + filename_expression + "' results in empty filename for template: " + m_templateDefinition.SelectSingleNode("name").InnerText);
            }

            m_outputfilename += filename;

            m_inputfilename = TemplateCache.Instance().SolutionLocation + @"\TemplateFile\" + m_templateDefinition.SelectSingleNode("templatefilename").InnerText;
        }