public void RemoveIncorrectLinesTestLineFailed()
        {
            // Arrange
            DesignerReader designerReader = new DesignerReader();

            string[] outputLines = { "   public C1.Win.C1TrueDBGrid.C1TrueDBGrid grd1;",
                                     "    private void InitializeComponent()",
                                     "    this.grid1.CaptionStyle.ForeColor = System.Drawing.SystemColors.ControlText;",
                                     "    this.grid1.CaptionStyle.Font = ggfxdfsdfdfsd;" };
            designerReader.OutputDesignerLines = outputLines.ToList();
            int expectedResult = 4;

            // Act
            try
            {
                designerReader.RemoveIncorrectLines();
            }
            catch (Exception ex)
            {
                // ignore
            }
            int actualResult = designerReader.CurrentLineIndex;

            // Assert
            Assert.AreEqual(expectedResult, actualResult);
        }
        public void ProcessAllLinesTest_LineFailed()
        {
            // Arrange
            DesignerReader designerReader = new DesignerReader();

            designerReader.Resx = new XDocument(new XElement("root"));
            string[] lines =
            {
                "public C1.Win.C1TrueDBGrid.C1TrueDBGrid grid1;",
                "private void InitializeComponent()",
                "this.grid1.CaptionStyle.Font = ggfxdfsdfdfsd;",
                "this.grid1.CaptionStyle.ForeColor = System.Drawing.SystemColors.ControlText;"
            };
            int expectedResult = 3;

            // Act
            try
            {
                designerReader.CheckGridVariables(lines);
                designerReader.ProcessAllLines(lines);
            } catch (Exception)
            {
                // do nothing
            }
            int actualResult = designerReader.CurrentLineIndex;

            // Assert
            Assert.AreEqual(expectedResult, actualResult);
        }
        public void GridsDictionaryTestEmptyByDefault()
        {
            // Arrange
            DesignerReader designerReader = new DesignerReader();
            // Act
            bool actualResult = designerReader.Grids.Count == 0;

            //Assert
            Assert.IsTrue(actualResult);
        }
        public void GetResxFilename()
        {
            //Arrange
            DesignerReader designerReader = new DesignerReader();
            string         expectedResult = "TestForm.resX";
            // Act
            string actualResult = designerReader.GetResxFilename("TestForm.Designer.cs");

            // Assert
            Assert.AreEqual(expectedResult, actualResult);
        }
        public void MustWritePropBagLinesTest()
        {
            //Arrange
            DesignerReader designerReader = new DesignerReader();
            bool           expectedResult = true;
            //Act
            bool actualResult = designerReader.MustWritePropBagLines("this.SuspendLayout();");

            //Assert
            Assert.AreEqual(expectedResult, actualResult);
        }
        public void ResxTagsInsertedTestDefaultValue()
        {
            //Arrange
            DesignerReader designerReader = new DesignerReader();
            int            expectedResult = 0;
            //Act
            int actualResult = designerReader.ResxTagsInserted;

            //Assert
            Assert.AreEqual(expectedResult, actualResult);
        }
        public void TotalGridsTestDefaultValue()
        {
            //Arrange
            DesignerReader designerReader = new DesignerReader();
            int            expectedResult = 0;
            //Act
            int actualResult = designerReader.TotalGrids;

            //Assert
            Assert.AreEqual(expectedResult, actualResult);
        }
        public void TotalGridsIncorrectPropsInDesignerAndExistingPropBagTestDefaultValue()
        {
            //Arrange
            DesignerReader designerReader = new DesignerReader();
            int            expectedResult = 0;
            //Act
            int actualResult = designerReader.TotalGridsIncorrectPropsInDesignerAndExistingPropBag;

            //Assert
            Assert.AreEqual(expectedResult, actualResult);
        }
        public void CheckRemoveLineTest()
        {
            // Arrange
            DesignerReader designerReader = new DesignerReader();

            designerReader.Grids["TDBGrid1"] = new C1TrueDBGrid();
            // Act
            bool actualResult = designerReader.CheckRemoveLine("   this.TDBGrid1.Columns[0].EditMaskUpdate = false;");

            // Assert
            Assert.IsTrue(actualResult);
        }
        public void ProcessGridNameTestPrivate()
        {
            //Arrange
            DesignerReader designerReader = new DesignerReader();

            designerReader.Resx = new XDocument();
            //Act
            designerReader.ProcessGridName("private C1.Win.C1TrueDBGrid.C1TrueDBGrid _grid00;");
            bool actualResult = designerReader.Grids.ContainsKey("_grid00");

            //Assert
            Assert.IsTrue(actualResult);
        }
        public void LineFailedTestSetAndGet()
        {
            //Arrange
            DesignerReader designerReader = new DesignerReader();

            designerReader.CurrentLineIndex = 2341;
            int expectedResult = 2341;
            //Act
            int actualResult = designerReader.CurrentLineIndex;

            //Assert
            Assert.AreEqual(expectedResult, actualResult);
        }
        public void TotalGridsTestSetAndGet()
        {
            //Arrange
            DesignerReader designerReader = new DesignerReader();

            designerReader.TotalGrids = 9;
            int expectedResult = 9;
            //Act
            int actualResult = designerReader.TotalGrids;

            //Assert
            Assert.AreEqual(expectedResult, actualResult);
        }
        public void FilePathTestSetAndGet()
        {
            //Arrange
            DesignerReader designerReader = new DesignerReader();

            designerReader.FilePath = @"C:\Users\TSUser\Desktop\tabla elaborada_.Net - Copy\Upgraded";
            string expectedResult = @"C:\Users\TSUser\Desktop\tabla elaborada_.Net - Copy\Upgraded";
            //Act
            string actualResult = designerReader.FilePath;

            //Assert
            Assert.AreEqual(expectedResult, actualResult);
        }
        public void ProcessGridNameTestHelper()
        {
            //Arrange
            DesignerReader designerReader = new DesignerReader();

            designerReader.Resx = new XDocument();
            //Act
            designerReader.ProcessGridName("public UpgradeHelpers.Helpers.C1TrueDBGridHelper grd2;");
            bool actualResult = designerReader.Grids.ContainsKey("grd2");

            //Assert
            Assert.IsTrue(actualResult);
        }
        public void ProcessValueItemNameTest()
        {
            //Arrange
            DesignerReader designerReader = new DesignerReader();

            designerReader.Resx = new XDocument();
            //Act
            designerReader.ProcessValueItemName("public C1.Win.C1TrueDBGrid.ValueItem ValueItem_0_Column_1_TDBGrid;");
            bool actualResult = designerReader.ValueItems.ContainsKey("ValueItem_0_Column_1_TDBGrid");

            //Assert
            Assert.IsTrue(actualResult);
        }
        public void ProcessColumnNameTest()
        {
            //Arrange
            DesignerReader designerReader = new DesignerReader();

            designerReader.Resx = new XDocument();
            //Act
            designerReader.ProcessColumnName("public C1.Win.C1TrueDBGrid.C1DataColumn column0;");
            bool actualResult = designerReader.Columns.ContainsKey("column0");

            //Assert
            Assert.IsTrue(actualResult);
        }
        public void ResxTagsInsertedTestSetAndGet()
        {
            //Arrange
            DesignerReader designerReader = new DesignerReader();

            designerReader.ResxTagsInserted = 7;
            int expectedResult = 7;
            //Act
            int actualResult = designerReader.ResxTagsInserted;

            //Assert
            Assert.AreEqual(expectedResult, actualResult);
        }
        public void RemoveIncorrectLinesTest_MustNotRemove1()
        {
            // Arrange
            DesignerReader designerReader = new DesignerReader();

            designerReader.Grids["TDBGrid1"] = new C1TrueDBGrid();
            // Act
            designerReader.ProcessLine("this.TDBGrid1.CellTipsDelay = 1001;");
            bool actualResult = designerReader.OutputDesignerLines.Contains("this.TDBGrid1.CellTipsDelay = 1001;");

            // Assert
            Assert.IsTrue(actualResult);
        }
        public void ProcessGridNameTestInternal()
        {
            //Arrange
            DesignerReader designerReader = new DesignerReader();

            designerReader.Resx = new XDocument();
            //Act
            designerReader.ProcessGridName("internal C1.Win.C1TrueDBGrid.C1TrueDBGrid IntGrid;");
            bool actualResult = designerReader.Grids.ContainsKey("IntGrid");

            //Assert
            Assert.IsTrue(actualResult);
        }
        public void TotalGridsWithExistingPropBagsTestSetAndGet()
        {
            //Arrange
            DesignerReader designerReader = new DesignerReader();

            designerReader.GridsWithExistingPropBags.Add("Grid0");
            int expectedResult = 1;
            //Act
            int actualResult = designerReader.TotalGridsWithExistingPropBags;

            //Assert
            Assert.AreEqual(expectedResult, actualResult);
        }
        public void ExistingValueItemsPropertyRegExTest1()
        {
            //Arrange
            DesignerReader designerReader = new DesignerReader();

            designerReader.ValueItems.Add("value1", new ValueItem());
            string expectedResult = @"^this\.(value1)\.?";
            //Act
            string actualResult = designerReader.ExistingValueItemsPropertyRegEx();

            //Assert
            Assert.AreEqual(expectedResult, actualResult);
        }
        public void ExistingColumnsPropertyRegExTest1()
        {
            //Arrange
            DesignerReader designerReader = new DesignerReader();

            designerReader.Columns.Add("column0", new C1DataColumn());
            string expectedResult = @"^this\.(column0)\.?";
            //Act
            string actualResult = designerReader.ExistingColumnPropertyRegEx();

            //Assert
            Assert.AreEqual(expectedResult, actualResult);
        }
        public void ExistingGridsPropertyRegExTest1()
        {
            //Arrange
            DesignerReader designerReader = new DesignerReader();

            designerReader.Grids.Add("TDBGrid", new C1TrueDBGrid());
            string expectedResult = @"^this\.(TDBGrid)\.";
            //Act
            string actualResult = designerReader.ExistingGridsPropertyRegEx();

            //Assert
            Assert.AreEqual(expectedResult, actualResult);
        }
        public void TotalGridsIncorrectPropsInDesignerAndExistingPropBagTestSetAndGet()
        {
            //Arrange
            DesignerReader designerReader = new DesignerReader();

            designerReader.GridsIncorrectPropsInDesignerAndExistingPropBag.Add("Grid1");
            designerReader.GridsIncorrectPropsInDesignerAndExistingPropBag.Add("Grid2");
            int expectedResult = 2;
            //Act
            int actualResult = designerReader.TotalGridsIncorrectPropsInDesignerAndExistingPropBag;

            //Assert
            Assert.AreEqual(expectedResult, actualResult);
        }
        public void ProcessGridNameTest2()
        {
            //Arrange
            DesignerReader designerReader = new DesignerReader();

            designerReader.Resx = new XDocument();
            designerReader.Resx.Add(new XElement("root", new XElement("data", new XAttribute("name", "TDBGrid.PropBag"))));
            //Act
            designerReader.ProcessGridName("public C1.Win.C1TrueDBGrid.C1TrueDBGrid TDBGrid;");
            bool actualResult = designerReader.Grids.ContainsKey("TDBGrid");

            //Assert
            Assert.IsTrue(actualResult);
        }
        public void RemoveIncorrectLinesTest_MustRemove1()
        {
            // Arrange
            DesignerReader designerReader = new DesignerReader();

            designerReader.Grids["TDBGrid1"] = new C1TrueDBGrid();
            designerReader.OutputDesignerLines.Add("this.TDBGrid1.Columns[0].EditMaskUpdate = false;");
            // Act
            designerReader.RemoveIncorrectLines();
            bool actualResult = designerReader.OutputDesignerLines.Count == 0;

            // Assert
            Assert.IsTrue(actualResult);
        }
        public void RemoveIncorrectLinesTest_MustRemove2()
        {
            // Arrange
            DesignerReader designerReader = new DesignerReader();

            designerReader.Grids["TDBGrid1"] = new C1TrueDBGrid();
            designerReader.OutputDesignerLines.Add("this.TDBGrid1.Splits[0].FetchRowStyle = false;");
            // Act
            designerReader.RemoveIncorrectLines();
            bool actualResult = !designerReader.OutputDesignerLines.Contains("this.TDBGrid1.Splits[0].FetchRowStyle = false;");

            // Assert
            Assert.IsTrue(actualResult);
        }
        public void RemovePropBagTest()
        {
            // Arrange
            DesignerReader designerReader = new DesignerReader();

            designerReader.Resx = new XDocument();
            designerReader.Resx.Add(new XElement("root", new XElement("data", new XAttribute("name", "TDBGrid.PropBag"))));
            // Act
            designerReader.RemovePropertyBag("TDBGrid");
            bool actualResult = designerReader.Resx.XPathSelectElement($"//data[@name='TDBGrid.PropBag']") == null;

            // Assert
            Assert.IsTrue(actualResult);
        }
        public void ProcessLineTest_ValueItemNames()
        {
            // Arrange
            DesignerReader designerReader = new DesignerReader();

            designerReader.Resx = new XDocument();
            StringWriter strWr = new StringWriter();

            // Act
            designerReader.ProcessLine("public C1.Win.C1TrueDBGrid.ValueItem valueItem01;");
            bool actualResult = !designerReader.OutputDesignerLines.Contains("public C1.Win.C1TrueDBGrid.ValueItem valueItem01;");

            // Assert
            Assert.IsTrue(actualResult);
        }
        public void PropBagLinesIdxTest()
        {
            // Arrange
            DesignerReader designerReader = new DesignerReader();

            designerReader.OutputDesignerLines.Add("private void InitializeComponent()");
            designerReader.OutputDesignerLines.Add("    this.SuspendLayout();");
            designerReader.OutputDesignerLines.Add("    this.TDBGrid.Name = \"TDBGrid\";");
            int expectedResult = 2;
            //Act
            int actualResult = designerReader.PropBagLinesIdx();

            // Assert
            Assert.AreEqual(expectedResult, actualResult);
        }