⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 textboxwritertests.cs

📁 C#编写的网络爬虫程序 效率很高 很好用!
💻 CS
字号:
using System;
using System.Windows.Forms;
using NUnit.Framework;
using NUnit.UiKit;

namespace NUnit.Tests.UiKit
{
	[TestFixture]
	public class TextBoxWriterTests
	{
		private TextBoxWriter textBoxWriter;
		private RichTextBox textBox;
		
		[SetUp]
		public void Init()
		{
			textBox = new RichTextBox();
			textBoxWriter = new TextBoxWriter( textBox );
			textBox.CreateControl();
		}

		[Test]
		public void CreateWriter()
		{
			Assert.IsNotNull( textBoxWriter );
			Assert.AreEqual( 0, textBox.Lines.Length );
			Assert.AreEqual( "", textBox.Text );
			Assert.AreEqual( 0, textBox.Lines.Length );
		}

		private void WriteTestLines( int count, int start )
		{
			for( int index = start; index < start + count; ++index )
				textBoxWriter.WriteLine( string.Format( "This is line {0}", index ) );
		}

		private void WriteTestLines( int count )
		{
			WriteTestLines( count, 1 );
		}

		[Test]
		public void WriteLines()
		{
			WriteTestLines( 5 );
			Assert.AreEqual( "This is line 3", textBox.Lines[2] );
		}

		[Test]
		public void Write()
		{
			textBoxWriter.Write( "I wrote this" );
			textBoxWriter.Write( " in three parts" );
			textBoxWriter.Write( '!' );

			Assert.AreEqual( "I wrote this in three parts!", textBox.Lines[0] );
		}

		[Test]
		public void MixedWrites()
		{
			WriteTestLines( 5 );
			textBoxWriter.Write( "This line written" );
			textBoxWriter.WriteLine( " in two parts" );
			textBoxWriter.WriteLine( "The final line" );

			Assert.AreEqual( "This line written in two parts", textBox.Lines[5] );
			Assert.AreEqual( "The final line", textBox.Lines[6] );
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -