mirror of
				https://github.com/nsnail/spectre.console.git
				synced 2025-11-04 02:25:28 +08:00 
			
		
		
		
	Initial work on TextPath widget
This commit is contained in:
		
				
					committed by
					
						
						Phil Scott
					
				
			
			
				
	
			
			
			
						parent
						
							d6cdd1fbda
						
					
				
				
					commit
					66fc949e2a
				
			
							
								
								
									
										45
									
								
								test/Spectre.Console.Tests/Unit/Widgets/TextPathTests.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										45
									
								
								test/Spectre.Console.Tests/Unit/Widgets/TextPathTests.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,45 @@
 | 
			
		||||
namespace Spectre.Console.Tests.Unit;
 | 
			
		||||
 | 
			
		||||
public sealed class TextPathTests
 | 
			
		||||
{
 | 
			
		||||
    [Fact]
 | 
			
		||||
    public void Should_Render_Full_Path_If_Possible()
 | 
			
		||||
    {
 | 
			
		||||
        // Given
 | 
			
		||||
        var console = new TestConsole().Width(40);
 | 
			
		||||
 | 
			
		||||
        // When
 | 
			
		||||
        console.Write(new TextPath("C:/Foo/Bar/Baz.txt"));
 | 
			
		||||
 | 
			
		||||
        // Then
 | 
			
		||||
        console.Output.ShouldBe("C:/Foo/Bar/Baz.txt");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    [Fact]
 | 
			
		||||
    public void Should_Pop_Segments_From_Left()
 | 
			
		||||
    {
 | 
			
		||||
        // Given
 | 
			
		||||
        var console = new TestConsole().Width(17);
 | 
			
		||||
 | 
			
		||||
        // When
 | 
			
		||||
        console.Write(new TextPath("C:/My documents/Bar/Baz.txt"));
 | 
			
		||||
 | 
			
		||||
        // Then
 | 
			
		||||
        console.Output.ShouldBe("C:/…/Bar/Baz.txt");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    [Theory]
 | 
			
		||||
    [InlineData(8, "1234567890", "…4567890")]
 | 
			
		||||
    [InlineData(9, "1234567890", "…34567890")]
 | 
			
		||||
    public void Should_Use_Last_Segments_If_Less_Than_Three(int width, string input, string expected)
 | 
			
		||||
    {
 | 
			
		||||
        // Given
 | 
			
		||||
        var console = new TestConsole().Width(width);
 | 
			
		||||
 | 
			
		||||
        // When
 | 
			
		||||
        console.Write(new TextPath(input));
 | 
			
		||||
 | 
			
		||||
        // Then
 | 
			
		||||
        console.Output.ShouldBe(expected);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user