Example #1
0
 private void CompareWithDefaultConfig()
 {
     Assert.AreEqual(
         DynamicCoverageDataCollectorImplTests.GetDefaultCodeCoverageConfig().Replace(" ", string.Empty)
         .Replace(Environment.NewLine, string.Empty),
         File.ReadAllText(this.aConfigFileName).Replace(" ", string.Empty).Replace(Environment.NewLine, string.Empty));
 }
Example #2
0
        public void InitializeShouldInitializeVanguardWithRightCoverageSettings()
        {
            XmlElement configElement =
                DynamicCoverageDataCollectorImplTests.CreateXmlElement(@"<Configuration><CodeCoverage></CodeCoverage></Configuration>");

            this.directoryHelperMock.Setup(d => d.CreateDirectory(It.IsAny <string>()))
            .Callback <string>((path) =>
            {
                this.tempSessionDir = path;
                Directory.CreateDirectory(path);
            });

            this.fileHelperMock.Setup(f => f.WriteAllText(It.IsAny <string>(), It.IsAny <string>()))
            .Callback <string, string>((path, content) => { File.WriteAllText(path, content); });

            this.collectorImpl.Initialize(configElement, this.dataCollectionSinkMock.Object, this.dataCollectionLoggerMock.Object);

            XmlDocument defaultDocument = new XmlDocument();

            defaultDocument.LoadXml(DynamicCoverageDataCollectorImplTests.GetDefaultCodeCoverageConfig());

            Assert.AreEqual(DynamicCoverageDataCollectorImplTests.DefaultConfigFileName, Path.GetFileName(this.aConfigFileName));

            XmlDocument currentDocument = new XmlDocument();

            currentDocument.LoadXml(File.ReadAllText(this.aConfigFileName));

            var codeCoverageNodes = new Tuple <XmlNode, XmlNode>(currentDocument.DocumentElement, defaultDocument.DocumentElement);

            this.CompareResults(codeCoverageNodes.Item1, codeCoverageNodes.Item2, "./ModulePaths/Exclude");
            this.CompareResults(codeCoverageNodes.Item1, codeCoverageNodes.Item2, "./Functions/Exclude");
            this.CompareResults(codeCoverageNodes.Item1, codeCoverageNodes.Item2, "./Attributes/Exclude");
            this.CompareResults(codeCoverageNodes.Item1, codeCoverageNodes.Item2, "./Sources/Exclude");
        }