Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ConfigurationManagerExtensions tests need to be revisited in .NET 5.0 or beyond #54

Closed
BryanWilhite opened this issue Oct 3, 2019 · 4 comments
Assignees
Labels

Comments

@BryanWilhite
Copy link
Owner

##[section]Starting: Visual Studio Test (Framework)
==============================================================================
Task         : Visual Studio Test
Description  : Run unit and functional tests (Selenium, Appium, Coded UI test, etc.) using the Visual Studio Test (VsTest) runner. Test frameworks that have a Visual Studio test adapter such as MsTest, xUnit, NUnit, Chutzpah (for JavaScript tests using QUnit, Mocha and Jasmine), etc. can be run. Tests can be distributed on multiple agents using this task (version 2).
Version      : 2.157.4
Author       : Microsoft Corporation
Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/test/vstest
==============================================================================
SystemVssConnection exists true
SystemVssConnection exists true
SystemVssConnection exists true
Running tests using vstest.console.exe runner.
======================================================
Test selector : Test assemblies
Test filter criteria : null
Search folder : D:\a\1\s
VisualStudio version selected for test execution : latest
Attempting to find vstest.console from a visual studio installation with version [16.0,17.0).
Run in parallel : false
Run in isolation : false
Path to custom adapters : null
Other console options : null
Code coverage enabled : false
Diagnostics enabled : false
SystemVssConnection exists true
Run the tests locally using vstest.console.exe
========================================================
Source filter: **\SonghayCore.Framework.Tests.dll
SystemVssConnection exists true
[command]D:\a\_tasks\VSTest_ef087383-ee5e-42c7-9a53-ab56c98420f9\2.157.4\Modules\DTAExecutionHost.exe --inputFile D:\a\_temp\input_e8fc48a1-e60a-11e9-a753-21b40c61d501.json
======================================================
##########################################################################
DtaExecutionHost version 17.157.29325.1.
Starting TestExecution Model...
Updated Run Settings:
<RunSettings>
  <RunConfiguration>
    <BatchSize>1000</BatchSize>
    <ResultsDirectory>D:\a\_temp\TestResults</ResultsDirectory>
  </RunConfiguration>
</RunSettings>
**************** Starting test execution *********************
[command]C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\Extensions\TestPlatform\vstest.console.exe "@C:\Users\VssAdministrator\AppData\Local\Temp\tmpDDE3.tmp"
Microsoft (R) Test Execution Command Line Tool Version 16.3.0-preview-20190715-02
Copyright (c) Microsoft Corporation.  All rights reserved.
vstest.console.exe "D:\a\1\s\SonghayCore.Framework.Tests\bin\Release\SonghayCore.Framework.Tests.dll"
"D:\a\1\s\SonghayCore.Framework.Tests\obj\Release\SonghayCore.Framework.Tests.dll"
/Settings:"D:\a\_temp\jvt34oy5g5v.runsettings"
/Logger:"trx"
/TestAdapterPath:"D:\a\1\s"
Starting test execution, please wait...
  √ ShouldHaveConfiguredTraceSources [96ms]
  √ ShouldNotHaveConfiguredTraceSource [< 1ms]
  √ ShouldListPhysicalDrives [479ms]
  √ ShouldListPhysicalNetworkAdapters [40ms]
  √ ShouldGetExternalConnectionStringSettings [119ms]
  √ ShouldGetExternalSetting [4ms]
  √ ShouldGetConnectionStringSettings [< 1ms]
  √ ShouldGetEnvironmentName [< 1ms]
  √ ShouldGetKeyWithEnvironmentName [< 1ms]
  √ ShouldGetSetting [< 1ms]
  X ShouldHaveConfiguredTraceSources [310ms]
  Error Message:
   Assert.IsNotNull failed. 
  Stack Trace:
     at Songhay.Tests.TraceSourceTest.ShouldHaveConfiguredTraceSources() in D:\a\1\s\SonghayCore.Framework.Tests\TraceSourceTest.cs:line 26
  √ ShouldNotHaveConfiguredTraceSource [< 1ms]
  √ ShouldListPhysicalDrives [62ms]
  √ ShouldListPhysicalNetworkAdapters [37ms]
  X ShouldGetExternalConnectionStringSettings [94ms]
  Error Message:
   Test method Songhay.Tests.Extensions.ConfigurationManagerExtensionsTest.ShouldGetExternalConnectionStringSettings threw exception: 
System.Configuration.ConfigurationErrorsException: The expected Name, “defaultEnvironmentName.Chinook” or “Chinook.defaultEnvironmentName”, is not here.
  Stack Trace:
      at Songhay.Extensions.ConfigurationManagerExtensions.GetConnectionNameFromEnvironment(ConnectionStringSettingsCollection collection, String unqualifiedKey, String environmentName, String delimiter, Boolean throwConfigurationErrorsException) in D:\a\1\s\SonghayCore\Extensions\ConfigurationManagerExtensions.cs:line 82
   at Songhay.Extensions.ConfigurationManagerExtensions.GetConnectionNameFromEnvironment(ConnectionStringSettingsCollection collection, String unqualifiedKey, String environmentName) in D:\a\1\s\SonghayCore\Extensions\ConfigurationManagerExtensions.cs:line 29
   at Songhay.Tests.Extensions.ConfigurationManagerExtensionsTest.ShouldGetExternalConnectionStringSettings() in D:\a\1\s\SonghayCore.Framework.Tests\Extensions\ConfigurationManagerExtensionsTest.cs:line 54
  Standard Output Messages:
 
TestContext Messages:
Finding directory: D:\a\1\s\SonghayCore.Framework.Tests\obj\Release...
 Finding directory: D:\a\1\s\SonghayCore.Framework.Tests...
 expected: Data Source=|DataDirectory|\Chinook.dev.sqlite
 Finding file: D:\a\1\s\SonghayCore.Framework.Tests\Extensions\ConfigurationManagerExtensionsTest.xml...
 Data Source=|DataDirectory|\Chinook.dev.sqlite
 Data Source=|DataDirectory|\Chinook.qa.sqlite
 Data Source=|DataDirectory|\Chinook.prod.sqlite
 data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true
  X ShouldGetExternalSetting [3ms]
  Error Message:
   Test method Songhay.Tests.Extensions.ConfigurationManagerExtensionsTest.ShouldGetExternalSetting threw exception: 
System.Configuration.ConfigurationErrorsException: The expected Key, “defaultEnvironmentName.ex-setting” or “ex-setting.defaultEnvironmentName”, is not here.
  Stack Trace:
      at Songhay.Extensions.ConfigurationManagerExtensions.GetKeyWithEnvironmentName(NameValueCollection settings, String unqualifiedKey, String environmentName, String delimiter, Boolean throwConfigurationErrorsException) in D:\a\1\s\SonghayCore\Extensions\ConfigurationManagerExtensions.cs:line 244
   at Songhay.Extensions.ConfigurationManagerExtensions.GetKeyWithEnvironmentName(NameValueCollection settings, String unqualifiedKey, String environmentName) in D:\a\1\s\SonghayCore\Extensions\ConfigurationManagerExtensions.cs:line 191
   at Songhay.Tests.Extensions.ConfigurationManagerExtensionsTest.ShouldGetExternalSetting() in D:\a\1\s\SonghayCore.Framework.Tests\Extensions\ConfigurationManagerExtensionsTest.cs:line 98
  Standard Output Messages:
 
TestContext Messages:
Finding directory: D:\a\1\s\SonghayCore.Framework.Tests\obj\Release...
 Finding directory: D:\a\1\s\SonghayCore.Framework.Tests...
 expected: the external setting for DEV
 Finding file: D:\a\1\s\SonghayCore.Framework.Tests\Extensions\ConfigurationManagerExtensionsTest.xml...
 appSettings keys:
 key: dev.ex-setting, value: the external setting for DEV
 key: qa.ex-setting, value: the external setting for QA
 key: prod.ex-setting, value: the external setting for PROD
 key: TestProjectRetargetTo35Allowed, value: true
  X ShouldGetConnectionStringSettings [1ms]
  Error Message:
   Test method Songhay.Tests.Extensions.ConfigurationManagerExtensionsTest.ShouldGetConnectionStringSettings threw exception: 
System.Configuration.ConfigurationErrorsException: The expected Name, “defaultEnvironmentName.Northwind” or “Northwind.defaultEnvironmentName”, is not here.
  Stack Trace:
      at Songhay.Extensions.ConfigurationManagerExtensions.GetConnectionNameFromEnvironment(ConnectionStringSettingsCollection collection, String unqualifiedKey, String environmentName, String delimiter, Boolean throwConfigurationErrorsException) in D:\a\1\s\SonghayCore\Extensions\ConfigurationManagerExtensions.cs:line 82
   at Songhay.Extensions.ConfigurationManagerExtensions.GetConnectionNameFromEnvironment(ConnectionStringSettingsCollection collection, String unqualifiedKey, String environmentName) in D:\a\1\s\SonghayCore\Extensions\ConfigurationManagerExtensions.cs:line 29
   at Songhay.Tests.Extensions.ConfigurationManagerExtensionsTest.ShouldGetConnectionStringSettings() in D:\a\1\s\SonghayCore.Framework.Tests\Extensions\ConfigurationManagerExtensionsTest.cs:line 117
  Standard Output Messages:
 
TestContext Messages:
expected: Data Source=|DataDirectory|\Northwind.dev.sqlite
  X ShouldGetEnvironmentName [1ms]
  Error Message:
   Assert.AreEqual failed. Expected:<dev>. Actual:<defaultEnvironmentName>. The expectedEnvironmentName is not here.
  Stack Trace:
     at Songhay.Tests.Extensions.ConfigurationManagerExtensionsTest.ShouldGetEnvironmentName() in D:\a\1\s\SonghayCore.Framework.Tests\Extensions\ConfigurationManagerExtensionsTest.cs:line 152
  Standard Output Messages:
 
TestContext Messages:
expected: dev
 actual: defaultEnvironmentName
  X ShouldGetKeyWithEnvironmentName [< 1ms]
  Error Message:
   Test method Songhay.Tests.Extensions.ConfigurationManagerExtensionsTest.ShouldGetKeyWithEnvironmentName threw exception: 
System.Configuration.ConfigurationErrorsException: The expected Key, “defaultEnvironmentName.setting” or “setting.defaultEnvironmentName”, is not here.
  Stack Trace:
      at Songhay.Extensions.ConfigurationManagerExtensions.GetKeyWithEnvironmentName(NameValueCollection settings, String unqualifiedKey, String environmentName, String delimiter, Boolean throwConfigurationErrorsException) in D:\a\1\s\SonghayCore\Extensions\ConfigurationManagerExtensions.cs:line 244
   at Songhay.Extensions.ConfigurationManagerExtensions.GetKeyWithEnvironmentName(NameValueCollection settings, String unqualifiedKey, String environmentName) in D:\a\1\s\SonghayCore\Extensions\ConfigurationManagerExtensions.cs:line 191
   at Songhay.Tests.Extensions.ConfigurationManagerExtensionsTest.ShouldGetKeyWithEnvironmentName() in D:\a\1\s\SonghayCore.Framework.Tests\Extensions\ConfigurationManagerExtensionsTest.cs:line 160
  Standard Output Messages:
 
TestContext Messages:
expected: dev.setting
  X ShouldGetSetting [1ms]
  Error Message:
   Test method Songhay.Tests.Extensions.ConfigurationManagerExtensionsTest.ShouldGetSetting threw exception: 
System.Configuration.ConfigurationErrorsException: The expected Key, “defaultEnvironmentName.setting” or “setting.defaultEnvironmentName”, is not here.
  Stack Trace:
      at Songhay.Extensions.ConfigurationManagerExtensions.GetKeyWithEnvironmentName(NameValueCollection settings, String unqualifiedKey, String environmentName, String delimiter, Boolean throwConfigurationErrorsException) in D:\a\1\s\SonghayCore\Extensions\ConfigurationManagerExtensions.cs:line 244
   at Songhay.Extensions.ConfigurationManagerExtensions.GetKeyWithEnvironmentName(NameValueCollection settings, String unqualifiedKey, String environmentName) in D:\a\1\s\SonghayCore\Extensions\ConfigurationManagerExtensions.cs:line 191
   at Songhay.Tests.Extensions.ConfigurationManagerExtensionsTest.ShouldGetSetting() in D:\a\1\s\SonghayCore.Framework.Tests\Extensions\ConfigurationManagerExtensionsTest.cs:line 176
  Standard Output Messages:
 
TestContext Messages:
expected: the setting for DEV
Results File: D:\a\_temp\TestResults\VssAdministrator_fv-az776_2019-10-03_18_23_46.trx
Total tests: 20
     Passed: 13
     Failed: 7
##[error]Test Run Failed.
 Total time: 6.0266 Seconds
Vstest.console.exe exited with code 1.
**************** Completed test execution *********************
Test results files: D:\a\_temp\TestResults\VssAdministrator_fv-az776_2019-10-03_18_23_46.trx
Created test run: 1000846
Publishing test results: 20
Publishing test results to test run '1000846'.
TestResults To Publish 20, Test run id:1000846
Test results publishing 20, remaining: 0. Test run id: 1000846
Published test results: 20
Publishing Attachments: 1
Execution Result Code 1 is non zero, checking for failed results
Completed TestExecution Model...
##[warning]Vstest failed with error. Check logs for failures. There might be failed tests.
##[error]Error: The process 'D:\a\_tasks\VSTest_ef087383-ee5e-42c7-9a53-ab56c98420f9\2.157.4\Modules\DTAExecutionHost.exe' failed with exit code 1
##[error]Vstest failed with error. Check logs for failures. There might be failed tests.
##[section]Finishing: Visual Studio Test (Framework)
@BryanWilhite BryanWilhite self-assigned this Oct 3, 2019
@BryanWilhite BryanWilhite moved this from To do to In progress in version 5.0.0 release Dec 28, 2020
@BryanWilhite
Copy link
Owner Author

BryanWilhite commented Dec 29, 2020

i apparently removed these tests when i dropped .NET Framework support for the version 5.0 release or perhaps earlier

can of worms opened: ConfigurationManager does have .NET 5.0 support [ 📖 docs] but this appears to not imply that it can be used side-by-side with the Core JSON configuration conventions

i assume this support is here to be backwards compatible with XML files with a project type that is probably hand-crafted in come kind of way

@BryanWilhite BryanWilhite removed this from In progress in version 5.0.0 release Dec 29, 2020
@BryanWilhite BryanWilhite changed the title Task : Visual Studio Test reports 7 failures on AzDO ConfigurationManagerExtensions tests need to be revisited in .NET 5.0 or beyond Dec 29, 2020
BryanWilhite pushed a commit that referenced this issue Dec 29, 2020
@BryanWilhite BryanWilhite moved this from To do to In progress in version 5.1.0 release Apr 11, 2021
@BryanWilhite
Copy link
Owner Author

BryanWilhite commented Apr 11, 2021

there is a System.Configuration.ConfigurationManager package [ 📦 nuget] that is needed here 💡

@BryanWilhite
Copy link
Owner Author

⚠️ .NET 5 replaces NameValueCollection with KeyValueConfigurationCollection [ 📖 docs]

@BryanWilhite
Copy link
Owner Author

this article seems to suggest that in .NET Core 3.x we could have *.json and *.config files side-by-side: https://rimdev.io/what-works-and-what-doesnt-with-configurationmanager-appsettings-using-aspnetcore31/

this 2019 article says we need to add a using statement to get things to work 🤷🏿 : https://www.itnota.com/use-system-configuration-configurationmanager-dot-net-core/

BryanWilhite pushed a commit that referenced this issue Apr 12, 2021
version 5.1.0 release automation moved this from In progress to Done Apr 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Development

No branches or pull requests

1 participant