public void ExecutorExecuteShouldReturnArgumentProcessorResultSuccess()
        {
            var executor = new EnableLoggerArgumentExecutor(null);
            var result   = executor.Execute();

            Assert.AreEqual(ArgumentProcessorResult.Success, result);
        }
예제 #2
0
        public void ExecutorExecuteShouldReturnArgumentProcessorResultSuccess()
        {
            var executor = new EnableLoggerArgumentExecutor(RunSettingsManager.Instance);
            var result   = executor.Execute();

            Assert.AreEqual(ArgumentProcessorResult.Success, result);
        }
        public void ExecutorInitializeWithValidArgumentsShouldAddConsoleloggerToTestLoggerManager()
        {
            RunTestsArgumentProcessorTests.SetupMockExtensions();
            var testloggerManager = new DummyTestLoggerManager();
            var executor          = new EnableLoggerArgumentExecutor(testloggerManager);

            executor.Initialize("console;verbosity=minimal");
            Assert.IsTrue(testloggerManager.GetInitializedLoggers.Contains("logger://Microsoft/TestPlatform/ConsoleLogger/v2"));
        }
        public void ExecutorInitializeWithValidArgumentsOtherThanConsoleLoggerShouldGetStoreInLoggerList()
        {
            var testloggerManager = new DummyTestLoggerManager();
            var executor          = new EnableLoggerArgumentExecutor(testloggerManager);

            executor.Initialize("DummyLoggerExtension;Collection=http://localhost:8080/tfs/DefaultCollection;TeamProject=MyProject;BuildName=DailyBuild_20121130.1");

            Assert.IsTrue(testloggerManager.LoggerExist("DummyLoggerExtension"));
        }
        public void ExecutorInitializeWithNullOrEmptyArgumentsShouldThrowException()
        {
            var executor = new EnableLoggerArgumentExecutor(TestLoggerManager.Instance);

            Assert.ThrowsException <CommandLineException>(() =>
            {
                executor.Initialize(null);
            });
        }
        public void ExectorInitializeShouldThrowExceptionIfInvalidArgumentIsPassed()
        {
            var executor = new EnableLoggerArgumentExecutor(TestLoggerManager.Instance);

            Assert.ThrowsException <CommandLineException>(() =>
            {
                executor.Initialize("TestLoggerExtension;==;;;Collection=http://localhost:8080/tfs/DefaultCollection;TeamProject=MyProject;BuildName=DailyBuild_20121130.1");
            });
        }
        public void ExecutorInitializeWithValidArgumentsShouldAddTestLoggerToTestLoggerManager()
        {
            RunTestsArgumentProcessorTests.SetupMockExtensions();
            var testloggerManager = new DummyTestLoggerManager();
            var executor          = new EnableLoggerArgumentExecutor(testloggerManager);

            var countBefore = testloggerManager.GetInitializedLoggers.Count;

            executor.Initialize("TestLoggerExtension;Collection=http://localhost:8080/tfs/DefaultCollection;TeamProject=MyProject;BuildName=DailyBuild_20121130.1");
            var countAfter = testloggerManager.GetInitializedLoggers.Count;

            Assert.IsTrue(countBefore == 0);
            Assert.IsTrue(countAfter == 1);
        }
예제 #8
0
        public void ExecutorInitializeShouldCorrectlyAddLoggerParametersInRunSettings()
        {
            string settingsXml =
                @"<?xml version=""1.0"" encoding=""utf-8""?>
                <RunSettings>
                  <RunConfiguration>
                  </RunConfiguration>
                  <DataCollectionRunSettings>
                    <DataCollectors>
                      <DataCollector friendlyName=""Code Coverage"">
                      </DataCollector>
                    </DataCollectors>
                  </DataCollectionRunSettings>
                </RunSettings>";

            var runSettings = new RunSettings();

            runSettings.LoadSettingsXml(settingsXml);
            RunSettingsManager.Instance.SetActiveRunSettings(runSettings);

            var executor = new EnableLoggerArgumentExecutor(RunSettingsManager.Instance);

            executor.Initialize("logger://DummyLoggerUri;Collection=http://localhost:8080/tfs/DefaultCollection;TeamProject=MyProject;BuildName=DailyBuild_20121130.1");

            string expectedSettingsXml =
                @"<?xml version=""1.0"" encoding=""utf-16""?>
<RunSettings>
  <RunConfiguration>
  </RunConfiguration>
  <DataCollectionRunSettings>
    <DataCollectors>
      <DataCollector friendlyName=""Code Coverage"">
      </DataCollector>
    </DataCollectors>
  </DataCollectionRunSettings>
  <LoggerRunSettings>
    <Loggers>
      <Logger uri=""logger://dummyloggeruri/"" enabled=""True"">
        <Configuration>
          <Collection>http://localhost:8080/tfs/DefaultCollection</Collection>
          <TeamProject>MyProject</TeamProject>
          <BuildName>DailyBuild_20121130.1</BuildName>
        </Configuration>
      </Logger>
    </Loggers>
  </LoggerRunSettings>
</RunSettings>";

            Assert.AreEqual(expectedSettingsXml, RunSettingsManager.Instance.ActiveRunSettings?.SettingsXml);
        }
예제 #9
0
        public void ExectorInitializeShouldThrowExceptionIfInvalidArgumentIsPassed(string argument)
        {
            var executor = new EnableLoggerArgumentExecutor(RunSettingsManager.Instance);

            try
            {
                executor.Initialize(argument);
            }
            catch (Exception e)
            {
                string exceptionMessage = string.Format(CultureInfo.CurrentUICulture, CommandLineResources.LoggerUriInvalid, argument);
                Assert.IsTrue(e.GetType().Equals(typeof(CommandLineException)));
                Assert.IsTrue(e.Message.Contains(exceptionMessage));
            }
        }
예제 #10
0
        public void ExecutorInitializeShouldAddLoggerWithFriendlyNameInRunSettingsIfNamePresentInArg()
        {
            string settingsXml =
                @"<?xml version=""1.0"" encoding=""utf-8""?>
                <RunSettings>
                  <RunConfiguration>
                  </RunConfiguration>
                  <DataCollectionRunSettings>
                    <DataCollectors>
                      <DataCollector friendlyName=""Code Coverage"">
                      </DataCollector>
                    </DataCollectors>
                  </DataCollectionRunSettings>
                </RunSettings>";

            var runSettings = new RunSettings();

            runSettings.LoadSettingsXml(settingsXml);
            RunSettingsManager.Instance.SetActiveRunSettings(runSettings);

            var executor = new EnableLoggerArgumentExecutor(RunSettingsManager.Instance);

            executor.Initialize("DummyLoggerExtension");

            string expectedSettingsXml =
                @"<?xml version=""1.0"" encoding=""utf-16""?>
<RunSettings>
  <RunConfiguration>
  </RunConfiguration>
  <DataCollectionRunSettings>
    <DataCollectors>
      <DataCollector friendlyName=""Code Coverage"">
      </DataCollector>
    </DataCollectors>
  </DataCollectionRunSettings>
  <LoggerRunSettings>
    <Loggers>
      <Logger friendlyName=""DummyLoggerExtension"" enabled=""True"" />
    </Loggers>
  </LoggerRunSettings>
</RunSettings>";

            Assert.AreEqual(expectedSettingsXml, RunSettingsManager.Instance.ActiveRunSettings?.SettingsXml);
        }
예제 #11
0
        public void ExecutorInitializeShouldCorrectlyAddLoggerWhenRunSettingsNotPassed()
        {
            RunSettingsManager.Instance.SetActiveRunSettings(new RunSettings());

            var executor = new EnableLoggerArgumentExecutor(RunSettingsManager.Instance);

            executor.Initialize("logger://DummyLoggerUri;Collection=http://localhost:8080/tfs/DefaultCollection;TeamProject=MyProject;BuildName=DailyBuild_20121130.1");

            string expectedSettingsXml =
                @"
  <LoggerRunSettings>
    <Loggers>
      <Logger uri=""logger://dummyloggeruri/"" enabled=""True"">
        <Configuration>
          <Collection>http://localhost:8080/tfs/DefaultCollection</Collection>
          <TeamProject>MyProject</TeamProject>
          <BuildName>DailyBuild_20121130.1</BuildName>
        </Configuration>
      </Logger>
    </Loggers>
  </LoggerRunSettings>";

            Assert.IsTrue(RunSettingsManager.Instance.ActiveRunSettings.SettingsXml.Contains(expectedSettingsXml));
        }
예제 #12
0
        public void ExecutorInitializeShouldPreferCommandLineLoggerWithParamsOverRunSettingsLoggerIfSame()
        {
            string settingsXml =
                @"<?xml version=""1.0"" encoding=""utf-8""?>
                <RunSettings>
                  <RunConfiguration>
                  </RunConfiguration>
                  <DataCollectionRunSettings>
                    <DataCollectors>
                      <DataCollector friendlyName=""Code Coverage"">
                      </DataCollector>
                    </DataCollectors>
                  </DataCollectionRunSettings>
                  <LoggerRunSettings>
                    <Loggers>
                      <Logger uri=""logger://dummyloggeruriTemp/"" enabled=""False"">
                        <Configuration>
                          <Collection1>http://localhost:8080/tfs/DefaultCollection1</Collection1>
                          <TeamProject>MyProject</TeamProject>
                          <BuildName1>DailyBuild_20121130.11</BuildName1>
                        </Configuration>
                      </Logger>
                      <Logger friendlyName=""tempLogger1"" />
                      <Logger friendlyName=""tempLogger2"" enabled=""False"">
                      </Logger>
                      <Logger uri=""logger://dummyloggeruri/"" enabled=""True"">
                        <Configuration>
                          <Collection>http://localhost:8080/tfs/DefaultCollection</Collection>
                          <TeamProject>MyProject</TeamProject>
                          <BuildName>DailyBuild_20121130.1</BuildName>
                          <NewAttr>value</NewAttr>
                        </Configuration>
                      </Logger>
                    </Loggers>
                  </LoggerRunSettings>
                </RunSettings>";

            var runSettings = new RunSettings();

            runSettings.LoadSettingsXml(settingsXml);
            RunSettingsManager.Instance.SetActiveRunSettings(runSettings);

            var executor = new EnableLoggerArgumentExecutor(RunSettingsManager.Instance);

            executor.Initialize("logger://DummyLoggerUri;Collection=http://localhost:8080/tfs/DefaultCollectionOverride;TeamProjectOverride=MyProject;BuildName=DailyBuild_20121130.1Override;NewAttr=value");

            string expectedSettingsXml =
                @"<?xml version=""1.0"" encoding=""utf-16""?>
<RunSettings>
  <RunConfiguration>
  </RunConfiguration>
  <DataCollectionRunSettings>
    <DataCollectors>
      <DataCollector friendlyName=""Code Coverage"">
      </DataCollector>
    </DataCollectors>
  </DataCollectionRunSettings>
  <LoggerRunSettings>
    <Loggers>
      <Logger uri=""logger://dummyloggeruritemp/"" enabled=""False"">
        <Configuration>
          <Collection1>http://localhost:8080/tfs/DefaultCollection1</Collection1>
          <TeamProject>MyProject</TeamProject>
          <BuildName1>DailyBuild_20121130.11</BuildName1>
        </Configuration>
      </Logger>
      <Logger friendlyName=""tempLogger1"" enabled=""True"" />
      <Logger friendlyName=""tempLogger2"" enabled=""False"" />
      <Logger uri=""logger://dummyloggeruri/"" enabled=""True"">
        <Configuration>
          <Collection>http://localhost:8080/tfs/DefaultCollectionOverride</Collection>
          <TeamProjectOverride>MyProject</TeamProjectOverride>
          <BuildName>DailyBuild_20121130.1Override</BuildName>
          <NewAttr>value</NewAttr>
        </Configuration>
      </Logger>
    </Loggers>
  </LoggerRunSettings>
</RunSettings>";

            Assert.AreEqual(expectedSettingsXml, RunSettingsManager.Instance.ActiveRunSettings?.SettingsXml);
        }
예제 #13
0
        public void ExecutorInitializeShouldPreferCommandLineLoggerOverRunSettingsLoggerEvenIfCaseMismatch()
        {
            string settingsXml =
                @"<?xml version=""1.0"" encoding=""utf-8""?>
                <RunSettings>
                  <RunConfiguration>
                  </RunConfiguration>
                  <DataCollectionRunSettings>
                    <DataCollectors>
                      <DataCollector friendlyName=""Code Coverage"">
                      </DataCollector>
                    </DataCollectors>
                  </DataCollectionRunSettings>
                  <LoggerRunSettings>
                    <Loggers>
                      <Logger uri=""logger://dummyloggeruriTemp/"" enabled=""False"">
                        <Configuration>
                          <Collection1>http://localhost:8080/tfs/DefaultCollection1</Collection1>
                          <TeamProject>MyProject</TeamProject>
                          <BuildName1>DailyBuild_20121130.11</BuildName1>
                        </Configuration>
                      </Logger>
                      <Logger friendlyName=""tempLogger1"" />
                      <Logger FRiendlyName=""tEMPLogger2"" enabled=""FaLse"">
                      </Logger>
                    </Loggers>
                  </LoggerRunSettings>
                </RunSettings>";

            var runSettings = new RunSettings();

            runSettings.LoadSettingsXml(settingsXml);
            RunSettingsManager.Instance.SetActiveRunSettings(runSettings);

            var executor = new EnableLoggerArgumentExecutor(RunSettingsManager.Instance);

            executor.Initialize("tempLoggER2");

            string expectedSettingsXml =
                @"<?xml version=""1.0"" encoding=""utf-16""?>
<RunSettings>
  <RunConfiguration>
  </RunConfiguration>
  <DataCollectionRunSettings>
    <DataCollectors>
      <DataCollector friendlyName=""Code Coverage"">
      </DataCollector>
    </DataCollectors>
  </DataCollectionRunSettings>
  <LoggerRunSettings>
    <Loggers>
      <Logger uri=""logger://dummyloggeruritemp/"" enabled=""False"">
        <Configuration>
          <Collection1>http://localhost:8080/tfs/DefaultCollection1</Collection1>
          <TeamProject>MyProject</TeamProject>
          <BuildName1>DailyBuild_20121130.11</BuildName1>
        </Configuration>
      </Logger>
      <Logger friendlyName=""tempLogger1"" enabled=""True"" />
      <Logger friendlyName=""tempLoggER2"" enabled=""True"" />
    </Loggers>
  </LoggerRunSettings>
</RunSettings>";

            Assert.AreEqual(expectedSettingsXml, RunSettingsManager.Instance.ActiveRunSettings?.SettingsXml);
        }