コード例 #1
0
        public void InitializeXPlatCodeCoverageShouldAddXPlatInProcProcDataCollectoPropertiesIfNotPresent()
        {
            var runsettingsString = $"<?xml version =\"1.0\" encoding=\"utf-16\"?>\r\n<RunSettings>\r\n <DataCollectionRunSettings>\r\n    <DataCollectors>\r\n      <DataCollector friendlyName=\"MyDataCollector\" enabled=\"True\" />\r\n      <DataCollector friendlyName=\"MyDataCollector1\" enabled=\"True\" />\r\n      <DataCollector friendlyName=\"MyDataCollector2\" enabled=\"True\" />\r\n    </DataCollectors>\r\n  </DataCollectionRunSettings>\r\n  <InProcDataCollectionRunSettings>\r\n    <InProcDataCollectors>\r\n      <InProcDataCollector assemblyQualifiedName=\"{CoverletConstants.CoverletDataCollectorAssemblyQualifiedName}\" friendlyName=\"{CoverletConstants.CoverletDataCollectorFriendlyName}\" enabled=\"False\" />\r\n    </InProcDataCollectors>\r\n  </InProcDataCollectionRunSettings>\r\n</RunSettings>";

            runsettingsString = string.Format(runsettingsString, string.Empty);
            var runsettings = new RunSettings();

            runsettings.LoadSettingsXml(runsettingsString);
            this.settingsProvider.SetActiveRunSettings(runsettings);
            Mock <IFileHelper> fileHelper = new Mock <IFileHelper>();

            fileHelper.Setup(f => f.Exists(It.IsAny <string>())).Returns(true);
            CollectArgumentExecutor executor = new CollectArgumentExecutor(settingsProvider, fileHelper.Object);

            executor.Initialize("XPlat Code Coverage");

            Assert.AreEqual(string.Join(Environment.NewLine,
                                        "<?xml version=\"1.0\" encoding=\"utf-16\"?>",
                                        "<RunSettings>",
                                        "  <DataCollectionRunSettings>",
                                        "    <DataCollectors>",
                                        "      <DataCollector friendlyName=\"MyDataCollector\" enabled=\"True\" />",
                                        "      <DataCollector friendlyName=\"MyDataCollector1\" enabled=\"True\" />",
                                        "      <DataCollector friendlyName=\"MyDataCollector2\" enabled=\"True\" />",
                                        $"      <DataCollector friendlyName=\"{CoverletConstants.CoverletDataCollectorFriendlyName}\" enabled=\"True\" />",
                                        "    </DataCollectors>",
                                        "  </DataCollectionRunSettings>",
                                        "  <InProcDataCollectionRunSettings>",
                                        "    <InProcDataCollectors>",
                                        $"      <InProcDataCollector assemblyQualifiedName=\"{CoverletConstants.CoverletDataCollectorAssemblyQualifiedName}\" friendlyName=\"{CoverletConstants.CoverletDataCollectorFriendlyName}\" enabled=\"True\" codebase=\"{CoverletConstants.CoverletDataCollectorCodebase}\" />",
                                        "    </InProcDataCollectors>",
                                        "  </InProcDataCollectionRunSettings>",
                                        "</RunSettings>"), this.settingsProvider.ActiveRunSettings.SettingsXml);
        }
コード例 #2
0
        public void UpdageXPlatCodeCoverageCodebaseWithFullPathFromTestAdaptersPaths_NotFound()
        {
            var runsettingsString = string.Format(DefaultRunSettings, string.Empty);
            var runsettings       = new RunSettings();

            runsettings.LoadSettingsXml(runsettingsString);
            this.settingsProvider.SetActiveRunSettings(runsettings);
            Mock <IFileHelper> fileHelper = new Mock <IFileHelper>();

            fileHelper.Setup(f => f.Exists(It.IsAny <string>())).Returns(false);
            CollectArgumentExecutor executor = new CollectArgumentExecutor(settingsProvider, fileHelper.Object);

            executor.Initialize("XPlat Code Coverage");
            executor.Execute();

            Assert.AreEqual(string.Join(Environment.NewLine,
                                        "<?xml version=\"1.0\" encoding=\"utf-16\"?>",
                                        "<RunSettings>",
                                        "  <RunConfiguration>",
                                        "    <TestAdaptersPaths>c:\\AdapterFolderPath</TestAdaptersPaths>",
                                        "  </RunConfiguration>",
                                        "  <DataCollectionRunSettings>",
                                        "    <DataCollectors>",
                                        "      <DataCollector friendlyName=\"XPlat Code Coverage\" enabled=\"True\" />",
                                        "    </DataCollectors>",
                                        "  </DataCollectionRunSettings>",
                                        "  <InProcDataCollectionRunSettings>",
                                        "    <InProcDataCollectors>",
                                        "      <InProcDataCollector assemblyQualifiedName=\"Coverlet.Collector.DataCollection.CoverletInProcDataCollector, coverlet.collector, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null\" friendlyName=\"XPlat Code Coverage\" enabled=\"True\" codebase=\"coverlet.collector.dll\" />",
                                        "    </InProcDataCollectors>",
                                        "  </InProcDataCollectionRunSettings>",
                                        "</RunSettings>"), this.settingsProvider.ActiveRunSettings.SettingsXml);
        }