示例#1
0
		public void ReadNextText_MultilineTagStateFollowedByTextOnly_2ndLineText()
		{
			Stream stream = new MemoryStream(Encoding.ASCII.GetBytes(
					"\\tag\nmore text"));
			SFMReader test = new SFMReader(stream);

			Assert.AreEqual("more text", test.ReadNextText());
		}
示例#2
0
		public void ReadNextText_MultilineInitialTextStateFollowedByMedialTag_Null()
		{
			Stream stream = new MemoryStream(Encoding.ASCII.GetBytes(
					"text first\ntext \\tag"));
			SFMReader test = new SFMReader(stream);

			Assert.AreEqual(string.Empty, test.ReadNextText());
		}
示例#3
0
		public void ReadNextText_MultilineInitialTextStateFollowedByInitialTagThenText_2ndLineText()
		{
			Stream stream = new MemoryStream(Encoding.ASCII.GetBytes(
					"text first\n\\tag more text"));
			SFMReader test = new SFMReader(stream);

			Assert.AreEqual("more text", test.ReadNextText());
		}
示例#4
0
		public void ReadNextText_MultilineTagStateFollowedByTagOnly_Empty()
		{
			Stream stream = new MemoryStream(Encoding.ASCII.GetBytes(
					"\\tag\n\\tag"));
			SFMReader test = new SFMReader(stream);

			Assert.AreEqual(string.Empty, test.ReadNextText());
		}
示例#5
0
		public void ReadNextText_MultilineInitialTextStateFollowedByEmpty_Null()
		{
			Stream stream = new MemoryStream(Encoding.ASCII.GetBytes(
					"text first\n"));
			SFMReader test = new SFMReader(stream);

			Assert.AreEqual("text first\n", test.ReadInitialText());
			Assert.IsNull(test.ReadNextText());
		}
示例#6
0
		public void ReadNextTag_MultilineEmptyFollowedByText_Null()
		{
			Stream stream = new MemoryStream(Encoding.ASCII.GetBytes(
					"\ntext"));
			SFMReader test = new SFMReader(stream);

			string token = test.ReadNextTag();
			Assert.IsNull(token);
		}
示例#7
0
		public void ReadNextTextThenReadNextTag()
		{
			Stream stream = new MemoryStream(Encoding.ASCII.GetBytes(
					@"\tag1 some text\tag2"));
			SFMReader test = new SFMReader(stream);

			test.ReadNextText();
			Assert.AreEqual("tag2", test.ReadNextTag());
		}
示例#8
0
		public void Offset_ShoeboxModeAfter4LetterTagWithStarAfterEOF_5()
		{
			Stream stream = new MemoryStream(Encoding.ASCII.GetBytes(
					"\\tag*"));
			SFMReader test = new SFMReader(stream);
			test.Mode = SFMReader.ParseMode.Shoebox;
			test.ReadNextTag();
			test.ReadNextText();

			Assert.AreEqual(5, test.Offset);
		}
示例#9
0
		public void Offset_After3LetterTag4LetterWordAndASpace_10()
		{
			Stream stream = new MemoryStream(Encoding.ASCII.GetBytes(
					"\\tag text "));
			SFMReader test = new SFMReader(stream);
			test.ReadNextTag();
			test.ReadNextText();

			Assert.AreEqual(10, test.Offset);
		}
示例#10
0
		public void ShoeboxMode_TagsWithoutNewline_TreatedAsText()
		{
			Stream stream = new MemoryStream(Encoding.ASCII.GetBytes(
					@"\tag text first\bf"));
			SFMReader test = new SFMReader(stream);
			test.Mode = SFMReader.ParseMode.Shoebox;
			Assert.AreEqual("text first\\bf", test.ReadNextText());
			string token = test.ReadNextTag();
			Assert.IsNull(token);
		}
示例#11
0
		public void DefaultMode_TagTerminiatedByAsterisk()
		{
			Stream stream = new MemoryStream(Encoding.ASCII.GetBytes(
					@"\tag1*some text"));
			SFMReader test = new SFMReader(stream);

			Assert.AreEqual("tag1*some", test.ReadNextTag());
			Assert.AreEqual("text", test.ReadNextText());
		}
示例#12
0
		public void ReadNextTagThenReadInitialText_Throw()
		{
			Stream stream = new MemoryStream(Encoding.ASCII.GetBytes(@"\tag1 some text\tag2"));
			SFMReader test = new SFMReader(stream);
			test.ReadNextTag();
			Assert.Throws<InvalidOperationException>(
				() => test.ReadInitialText());
		}
示例#13
0
		public void ReadNextTag_EmptyTag()
		{
			Stream stream = new MemoryStream(Encoding.ASCII.GetBytes(
					@"\ some text"));
			SFMReader test = new SFMReader(stream);

			string token = test.ReadNextTag();
			Assert.AreEqual(string.Empty, token);
		}
示例#14
0
		public void ReadNextTag_TextOnly_Null()
		{
			Stream stream = new MemoryStream(Encoding.ASCII.GetBytes(
					@"text first\bf"));
			SFMReader test = new SFMReader(stream);

			string token = test.ReadNextTag();
			Assert.AreEqual("bf", token);
		}
示例#15
0
		public void ReadNextTag_AfterFinalText_Null()
		{
			Stream stream = new MemoryStream(Encoding.ASCII.GetBytes(
					@"\bf text"));
			SFMReader test = new SFMReader(stream);

			test.ReadNextTag();
			string token = test.ReadNextTag();
			Assert.IsNull(token);
		}
示例#16
0
		public void ReadNextTag_MedialTag()
		{
			Stream stream = new MemoryStream(Encoding.ASCII.GetBytes(
					@"\tag text first\bf more text"));
			SFMReader test = new SFMReader(stream);
			test.ReadNextTag();
			string token = test.ReadNextTag();
			Assert.AreEqual("bf", token);
		}
示例#17
0
		public void ReadInitialText_MultiLineTagFollowedByText_Empty()
		{
			Stream stream = new MemoryStream(Encoding.ASCII.GetBytes(
					"\\tag\ntext"));
			SFMReader test = new SFMReader(stream);

			string token = test.ReadInitialText();
			Assert.AreEqual(string.Empty, token);
		}
示例#18
0
		public void ReadInitialText_MultiLineTextFollowedByTextAndTag_1stLineAndBeginning2ndLine()
		{
			Stream stream = new MemoryStream(Encoding.ASCII.GetBytes(
					"text\nmore text\\tag"));
			SFMReader test = new SFMReader(stream);

			string token = test.ReadInitialText();
			Assert.AreEqual("text\nmore text", token);
		}
示例#19
0
		public void UsfmMode_TagTerminiatedByAsterisk()
		{
			Stream stream = new MemoryStream(Encoding.ASCII.GetBytes(
					@"\tag1*some text"));
			SFMReader test = new SFMReader(stream);
			test.Mode = SFMReader.ParseMode.Usfm;

			Assert.AreEqual("tag1*", test.ReadNextTag());
			Assert.AreEqual("some text", test.ReadNextText());
		}
示例#20
0
		public void ReadNextTag_MultilineEmptyFollowedByTagThenText()
		{
			Stream stream = new MemoryStream(Encoding.ASCII.GetBytes(
					"\n\\tag text"));
			SFMReader test = new SFMReader(stream);

			string token = test.ReadNextTag();
			Assert.AreEqual("tag", token);
		}
示例#21
0
		public void Mode_InitializedToDefault()
		{
			Stream stream = new MemoryStream(Encoding.ASCII.GetBytes(
					@"\tag text first\bf"));
			SFMReader test = new SFMReader(stream);
			Assert.AreEqual(SFMReader.ParseMode.Default, test.Mode);
		}
示例#22
0
		public void ReadNextTag_MultilineInitialTextFollowedByText()
		{
			Stream stream = new MemoryStream(Encoding.ASCII.GetBytes(
					"initial text\nsome text"));
			SFMReader test = new SFMReader(stream);

			string token = test.ReadNextTag();
			Assert.IsNull(token);
		}
示例#23
0
		public void Offset_BeforeAnyTextIsRead_0()
		{
			Stream stream = new MemoryStream(Encoding.ASCII.GetBytes(
					"\\tag text more text"));
			SFMReader test = new SFMReader(stream);

			Assert.AreEqual(0, test.Offset);
		}
示例#24
0
		public void ReadNextTag_MultilineInitialTextFollowedByTextThenTag()
		{
			Stream stream = new MemoryStream(Encoding.ASCII.GetBytes(
					"initial text\ntext\\tag"));
			SFMReader test = new SFMReader(stream);

			string token = test.ReadNextTag();
			Assert.AreEqual("tag", token);
		}
示例#25
0
		public void Offset_After5CharactersOfInitialText_5()
		{
			Stream stream = new MemoryStream(Encoding.ASCII.GetBytes(
					"hello"));
			SFMReader test = new SFMReader(stream);
			test.ReadInitialText();

			Assert.AreEqual(5, test.Offset);
		}
示例#26
0
		public void ReadNextTag_MultilineTagModeFollowedByTextOnly_Null()
		{
			Stream stream = new MemoryStream(Encoding.ASCII.GetBytes(
					"\\taginitial\nsome text"));
			SFMReader test = new SFMReader(stream);

			test.ReadNextTag();
			string token = test.ReadNextTag();
			Assert.IsNull(token);
		}
示例#27
0
		public void Offset_After3LetterTagAfterEOF_4()
		{
			Stream stream = new MemoryStream(Encoding.ASCII.GetBytes(
					"\\tag"));
			SFMReader test = new SFMReader(stream);
			test.ReadNextTag();
			test.ReadNextText();

			Assert.AreEqual(4, test.Offset);
		}
示例#28
0
		public void ReadNextTag_MultilineTagModeFollowedByTagOnly_2ndLineTag()
		{
			Stream stream = new MemoryStream(Encoding.ASCII.GetBytes(
					"\\taginitial\n\\tag"));
			SFMReader test = new SFMReader(stream);

			test.ReadNextTag();
			string token = test.ReadNextTag();
			Assert.AreEqual("tag", token);
		}
示例#29
0
		public void ReadNextText_MultilineTextStateFollowedByMedialTag_1stLineTextAnd2ndLineBeginningText()
		{
			Stream stream = new MemoryStream(Encoding.ASCII.GetBytes(
					"\\tag text first\ntext \\tag more text"));
			SFMReader test = new SFMReader(stream);

			Assert.AreEqual("text first\ntext ", test.ReadNextText());
			Assert.AreEqual("more text", test.ReadNextText());
		}
示例#30
0
		public void ReadNextTag_TwoTagsInARow()
		{
			Stream stream = new MemoryStream(Encoding.ASCII.GetBytes(
					@"\tag1\tag2"));
			SFMReader test = new SFMReader(stream);

			Assert.AreEqual("tag1", test.ReadNextTag());
			Assert.AreEqual("tag2", test.ReadNextTag());
		}