示例#1
0
		public void TestMatching()
		{
			Parser parser = new Parser(new ReportSettings());
			MockMatcher mockmatcher = new MockMatcher(null);

			string source = GetCodeFile();
			parser.Matchers.Clear();
			parser.Matchers.Add(mockmatcher);
			
			mockmatcher.InsertPointReturnValue = -1;
			string result = parser.ParseString(source);

			Assert.IsTrue(mockmatcher.InsertPointCalled);
			Assert.IsFalse(mockmatcher.MatchCalled);
			Assert.AreEqual(result, source);
			
			mockmatcher.InsertPointReturnValue = -2;
			mockmatcher.InsertPointCalled = false;

			result = parser.ParseString(source);

			Assert.IsTrue(mockmatcher.InsertPointCalled);
			Assert.IsTrue(mockmatcher.MatchCalled);
			Assert.AreEqual("foofoo", result);
		}
示例#2
0
		public void TestLiveMatching()
		{
			Parser parser = new Parser(new ReportSettings());
			string source = GetCodeFile();
			string result = parser.ParseString(source);
			Assert.IsTrue(source != result);
		}
示例#3
0
		public void TestConstructor()
		{
			Parser parser = new Parser(new ReportSettings());
			Assert.AreEqual(0, parser.CoveragePoints.Length);
			Assert.IsNotNull(parser.Matchers);
			Assert.IsTrue(parser.Matchers.Count > 0);
		}
示例#4
0
		public void TestParseFile()
		{
			Parser parser = new Parser(new ReportSettings());
			
			string filename = Path.GetTempFileName();

			FileStream fs = new FileStream(filename, FileMode.Create);
			ResourceManager.WriteResourceToStream(fs ,"SharpCover.Resources.CodeFile.vb", ResourceType.Text, this.GetType().Assembly);
			fs.Close();

			string source = GetCodeFile();
			
			string fileresult = parser.Parse(filename);
			Assert.IsNotNull(fileresult);
			string stringresult = parser.ParseString(source);
			Assert.IsNotNull(stringresult);
		}