예제 #1
0
        public void Should_Be_BuildFileString()
        {
            //Arrange
            var file = new WriteFile(_separator);

            var header = new LineBuilder();

            header.AddTexts("name", "lastname");
            file.AddHeader(header);
            var expectedHeader = $"name{_separator}lastname{_breakline}";

            file.NewLine();
            file.AddTexts("Iron", "Man");
            var expectedFirstLine = $"Iron{_separator}Man{_breakline}";

            file.NewLine();
            file.AddTexts("Captain", "America");
            var expectedSecondLine = $"Captain{_separator}America{_breakline}";

            var expectedResult = string.Concat(expectedHeader, expectedFirstLine, expectedSecondLine);

            //Act
            var result = file.BuildFileString();

            //Assert
            result.Should().Be(expectedResult);
        }
예제 #2
0
        public void Should_Be_Add_Text_In_Specific_Column()
        {
            //Arrange
            var file = new WriteFile(_separator);

            var header = new LineBuilder();

            header.AddTexts("name", "lastname");
            file.AddHeader(header);

            file.NewLine();
            var text = "Iron Man";

            var firstColumn = $"{_separator}";

            var expectedHeader = $"name{_separator}lastname{_breakline}";
            var expectedLine   = $"{firstColumn}{text}{_breakline}";

            var expectedResult = string.Concat(expectedHeader, expectedLine);

            //Act
            file.AddText(2, text);

            //Assert
            var result = file.BuildFileString();

            result.Should().Be(expectedResult);
        }
예제 #3
0
        public void Should_Be_Building_Line_With_Success_Without_Break_Line(string separator)
        {
            //Arrange
            var line = new LineBuilder();

            line.AddTexts("Workin\r\ng", "with\r\n", "\nfiles", "us\ning", "\r\nFile", "Builder\n");

            //Act
            var validateTest = line.BuildLine(separator);

            //Assert
            validateTest.Should().Be($"Working{separator}with{separator}files{separator}using{separator}File{separator}Builder");
        }
예제 #4
0
        public void Should_Be_Added_A_Line()
        {
            //Arrange
            var file = new WriteFile(_separator);

            var line = new LineBuilder();

            line.AddTexts("Iron", "Man");

            //Act
            file.AddLine(line);

            //Assert
            var expectedResult = $"Iron{_separator}Man{_breakline}";

            file.BuildFileString().Should().Be(expectedResult);
        }
예제 #5
0
        public void Should_Be_Added_A_Header()
        {
            //Arrange
            var file = new WriteFile(_separator);

            var header = new LineBuilder();

            header.AddTexts("name", "lastname");

            //Act
            file.AddHeader(header);

            //Assert
            var expectedResult = $"name{_separator}lastname{_breakline}";

            file.BuildFileString().Should().Be(expectedResult);
        }
예제 #6
0
        public void Should_Be_Add_Texts_Sequentially_Using_Params_Success()
        {
            //Arrange
            var line = new LineBuilder();

            var firstText  = FakerPrimitiveTypes.GetSampleText(0, 10000);
            var secondText = FakerPrimitiveTypes.GetSampleText(0, 10000);

            line.AddTexts(firstText, secondText);

            //Act
            var validateTest = line.GetCurrentPosition() == 2 &&
                               line.GetPosition(firstText) == 1 &&
                               line.GetPosition(secondText) == 2;

            //Assert
            validateTest.Should().BeTrue();
        }
예제 #7
0
        public void Should_Be_The_Position_Of_The_Inexistent_Text()
        {
            //Arrange
            var line = new LineBuilder();

            var texts = new List <string>()
            {
                $"Iron Man",
                $"Captain Marvel",
                $"Captain America",
                $"Thor",
                $"Black Panther",
                $"Hulk"
            };

            line.AddTexts(texts);

            //Assert
            line.GetPosition("xpto").Should().Be(-1);
        }
예제 #8
0
        public void Should_Be_The_Current_Position(int amount)
        {
            //Arrange
            var line = new LineBuilder();

            var texts = new List <string>();

            for (int i = 1; i <= amount; i++)
            {
                texts.Add(FakerPrimitiveTypes.GetSampleText(20));
            }

            line.AddTexts(texts);

            //ACT
            var validateTest = line.GetCurrentPosition() == amount;

            //Assert
            validateTest.Should().BeTrue();
        }
예제 #9
0
        public void Should_Be_Cloned()
        {
            //Arrange
            var line = new LineBuilder();

            var firstText  = "Captain America";
            var secondText = "Iron Main";

            line.AddTexts(firstText, secondText);

            var clone = line.Clone();

            //Act
            var validateTest = line.GetCurrentPosition() == clone.GetCurrentPosition() &&
                               line.GetPosition(firstText) == clone.GetPosition(firstText) &&
                               line.GetPosition(secondText) == clone.GetPosition(secondText);

            //Assert
            validateTest.Should().BeTrue();
        }
예제 #10
0
        public void Should_Be_The_Text_Of_The_Specific_Column()
        {
            //Arrange
            var line = new LineBuilder();

            var texts = new List <(int Position, string Value)>()
            {
                (1, $"Iron Man"),
                (2, $"Captain Marvel"),
                (3, $"Captain America"),
                (4, $"Thor"),
                (5, $"Black Panther"),
                (6, $"Hulk")
            };

            line.AddTexts(texts.Select(t => t.Value));

            //Assert
            for (int i = 1; i <= texts.Count; i++)
            {
                line.GetText(i).Should().Be(texts.FirstOrDefault(t => t.Position == i).Value);
            }
        }
예제 #11
0
        public void Should_Be_One_Current_Position()
        {
            //Arrange
            var line = new LineBuilder();

            var texts = new List <string>()
            {
                $"Iron Man",
                $"Captain Marvel",
                $"Captain America",
                $"Thor",
                $"Black Panther",
                $"Hulk"
            };

            line.AddTexts(texts);

            //Act
            line.ResetCurrentPosition();

            //Assert
            line.GetCurrentPosition().Should().Be(1);
        }
예제 #12
0
        public void Should_Be_Add_Texts_Sequentially_Using_List_Success()
        {
            //Arrange
            var line = new LineBuilder();

            IEnumerable <string> texts = new List <string>()
            {
                FakerPrimitiveTypes.GetSampleText(0, 10000),
                FakerPrimitiveTypes.GetSampleText(0, 10000),
                FakerPrimitiveTypes.GetSampleText(0, 10000),
                FakerPrimitiveTypes.GetSampleText(0, 10000)
            };

            line.AddTexts(texts);

            //Act
            var validateTest = line.GetCurrentPosition() == texts.Count() &&
                               texts.Select((text, index) => new { index, text })
                               .All(data => data.index + 1 == line.GetPosition(data.text));

            //Assert
            validateTest.Should().BeTrue();
        }
예제 #13
0
        public void Should_Be_Replaced_All_Text_With_Terms(string term)
        {
            //Arrange
            var line = new LineBuilder();

            var texts = new List <(int Position, string Value)>()
            {
                (1, $"{term} Iron Man"),
                (2, $"Captain Marvel"),
                (3, $"{term} Captain America"),
                (4, $"{term} Thor"),
                (5, $"Black Panther"),
                (6, $"{term} Hulk")
            };

            line.AddTexts(texts.Select(t => t.Value));

            //Act
            line.ReplaceAllContains(term, "Marvel Studio Hero");

            //Assert
            for (int i = 1; i <= texts.Count; i++)
            {
                var withoutTerm = new int[2] {
                    2, 5
                };

                if (withoutTerm.Contains(i))
                {
                    line.GetText(i).Should().Be(texts.FirstOrDefault(t => t.Position == i).Value);
                }
                else
                {
                    line.GetText(i).Should().Be("Marvel Studio Hero");
                }
            }
        }