public void WhenCallingComputeMetricsWithoutSpecifyingFileTypeShouldIgnoreFile() { List<string> files = new List<string>().AddItem("file1.cs"); FileStreamFactoryMock streamFactory = new FileStreamFactoryMock(); streamFactory.AddFileMock("file1.cs", TestResources.SourceFile1); CountLOCProvider provider = new CountLOCProvider(streamFactory); provider.AddMetadata("FileTypes", ".vb=VB.NET"); var measures = provider.ComputeMetrics(new List<string>().AddItem("FileLOC").AddItem("EmptyLOC").AddItem("CommentLOC"), files).ToList(); Assert.AreEqual(0, measures.Count); }
public void WhenCallingComputeMetricsShouldReturnMeasures() { List<string> files = new List<string>().AddItem("file1.cs"); FileStreamFactoryMock streamFactory = new FileStreamFactoryMock(); streamFactory.AddFileMock("file1.cs", TestResources.SourceFile1); CountLOCProvider provider = new CountLOCProvider(streamFactory); provider.AddMetadata("FileTypes", ".cs=C#"); var measures = provider.ComputeMetrics(new List<string>().AddItem("FileLOC").AddItem("EmptyLOC").AddItem("CommentLOC"), files).ToList(); Assert.AreEqual("TotalLOC", measures[0].MetricName); Assert.AreEqual("C#", measures[0].MeasureName); Assert.AreEqual(34, measures[0].Value); Assert.AreEqual("EmptyLOC", measures[2].MetricName); Assert.AreEqual("C#", measures[2].MeasureName); Assert.AreEqual(3, measures[2].Value); Assert.AreEqual("CommentLOC", measures[3].MetricName); Assert.AreEqual("C#", measures[3].MeasureName); Assert.AreEqual(7, measures[3].Value); Assert.AreEqual("CodeLOC", measures[1].MetricName); Assert.AreEqual("C#", measures[1].MeasureName); Assert.AreEqual(24, measures[1].Value); }