public void Cutting_RemaingStringBingLargerThanCutSize_ReturnsCutSizeString_AndKeepsRestOfString()
        {
            // Arrange
            const string Str = "Hello World";
            var          sut = new StringCutter(Str);

            // Act
            sut.Cut(Str.Length - 1, out var actualCutString);
            sut.Cut(1, out var actualRemainingString);

            // Assert
            actualCutString.Should().Be(Str.Substring(0, Str.Length - 1));
            actualRemainingString.Should().Be(Str.Substring(Str.Length - 1));
        }
        public void Cutting_RemaingStringBeingSmallerThanCutSize_ReturnsRemainingString_RestBeingEmpty()
        {
            // Arrange
            const string Str = "Hello World";
            var          sut = new StringCutter(Str);

            // Act
            sut.Cut(Str.Length + 1, out var actualCutString);
            sut.Cut(1, out var actualRemainingString);

            // Assert
            actualCutString.Should().Be(Str);
            actualRemainingString.Should().BeEmpty();
        }
Пример #3
0
        public void NullStringsAreLeftAsNull()
        {
            var cutter = new StringCutter();

            cutter.Cut(null, 150)
            .ShouldBeNull();
        }
Пример #4
0
        public void LeavesShortStringsUntouched()
        {
            var cutter = new StringCutter();

            cutter.Cut("Lorem ipsum dolor sit amet, consectetur adipiscing elit.", 150)
            .ShouldBe("Lorem ipsum dolor sit amet, consectetur adipiscing elit.");
        }
Пример #5
0
        public void ShortensString()
        {
            var cutter = new StringCutter();

            cutter.Cut("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed non risus. Suspendisse lectus tortor, dignissim sit amet, adipiscing nec, ultricies sed, dolor. Cras elementum ultrices diam. Maecenas ligula massa, varius a, semper congue, euismod non, mi. Proin porttitor, orci nec nonummy molestie, enim est eleifend mi, non fermentum diam nisl sit amet erat. Duis semper. Duis arcu massa, scelerisque vitae, consequat in, pretium a, enim. Pellentesque congue. Ut in risus volutpat libero pharetra tempor. Cras vestibulum bibendum augue. Praesent egestas leo in pede. Praesent blandit odio eu enim. Pellentesque sed dui ut augue blandit sodales. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Aliquam nibh. Mauris ac mauris sed pede pellentesque fermentum. Maecenas adipiscing ante non diam sodales hendrerit. "
                       , 150)
            .ShouldBe("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed non risus. Suspendisse lectus tortor, dignissim sit amet, adipiscing nec, ultricies sed,...");
        }
        public void Cutting_StringBeingNullOrEmpty_ReturnsEmpty(string str)
        {
            // Arrange
            var cutter = new StringCutter(str);

            // Act
            cutter.Cut(1, out var actualCutString);

            // Assert
            actualCutString.Should().BeEmpty();
        }