This is Xamarin's bug tracking system. For product support, please use the support links listed in your Xamarin Account.
Bug 41541 - App Config is not read in Unit Tests
Summary: App Config is not read in Unit Tests
Status: VERIFIED FIXED
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: NUnit (show other bugs)
Version: 6.0.0 (C7)
Hardware: Macintosh All
: Normal normal
Target Milestone: C7SR1
Assignee: Bugzilla
URL:
: 41967 (view as bug list)
Depends on:
Blocks:
 
Reported: 2016-06-06 23:42 UTC by emitelma
Modified: 2016-07-26 05:34 UTC (History)
7 users (show)

See Also:
Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
sample project (206.54 KB, application/zip)
2016-06-06 23:42 UTC, emitelma
Details
sample project (corrected) (2.39 MB, application/zip)
2016-06-07 20:17 UTC, emitelma
Details

Description emitelma 2016-06-06 23:42:00 UTC
Created attachment 16209 [details]
sample project

app.config is copied to build dir but ConfigManager.AppSettings[] is empty
Comment 1 emitelma 2016-06-07 20:17:52 UTC
Created attachment 16219 [details]
sample project (corrected)
Comment 2 Matt Ward 2016-06-13 14:04:19 UTC
I am unable to reproduce this with Xamarin Studio 6.0 (build 5174) and Mono 4.4.0 (mono-4.4.0-branch-c7-baseline/5995f74) which is currently on the stable channel.

Debugging the test I see 127.0.0.1 returned from ConfigurationManager.AppSettings ["server"]. Also if I change the test to assert the string matches, as shown below, then running the test also works:

        var serverString = ConfigurationManager.AppSettings ["server"];
	Assert.AreEqual ("127.0.0.1", serverString);

If there is a way to reproduce this please re-open this bug with the steps. Thanks.
Comment 3 Matt Ward 2016-06-13 14:25:57 UTC
OK I can reproduce it. The problem occurs with the attached sample project if the NUnit NuGet package is downgraded to NUnit 2.6.4. Then ConfigurationManager.AppSettings returns null with Xamarin Studio 6.0 but returns the correct string with Xamarin Studio 5.10.3. This is the case on both Windows and Mac.
Comment 4 Anthony Stivers 2016-06-14 15:08:05 UTC
I have fixed this bug and created a pull request.

The bug is caused by the TestPackage object's BasePath property being incorrectly set to the directory that contains NUnitRunner.exe rather than being set to the directory that contains the test assembly.

https://github.com/mono/monodevelop/pull/1508
Comment 5 Matt Ward 2016-06-18 08:37:43 UTC
*** Bug 41967 has been marked as a duplicate of this bug. ***
Comment 6 Lluis Sanchez 2016-07-11 09:03:25 UTC
Fixed.
Comment 7 Jatin 2016-07-11 11:36:34 UTC
I have verified the issue on Windows as well as on Mac using the attached sample project and the following builds:

XS 6.0.2.63 (buildId=ae1f7d4f82889125a2564b0b38bc3e8) downloaded from the link mentioned in the trello card: https://trello.com/c/kcbvlweE/73-xs-bug-41541

MonoFramework-MDK-4.5.1.956.macos10.xamarin.universal_7b7d32bedc3bace730f4f2be032a716e84c0fec1

And have observed that now the issue does not exists, below is the link for the screencast regarding same: http://www.screencast.com/t/zeiRkZT7UM
Comment 8 Jatin 2016-07-12 12:15:29 UTC
Hi Lluis,

We have verified this issue using the build which was provided on the trello card.

Please fix this issue on the cycle 7 as well so that we may proceed further and close this issue after verifying on cycle 7 build.
Comment 9 Lluis Sanchez 2016-07-12 13:46:51 UTC
This is already fixed in cycle7.
Comment 11 Jatin 2016-07-26 05:34:54 UTC
As mentioned in the Trello card:
https://trello.com/c/kcbvlweE/73-xs-bug-41541

I have verified the issue on Windows as well as on Mac using the attached sample project and the following builds:

XS 6.2.0.71

Below is the environment information for the same:
https://gist.github.com/jatin360/4ce6754cf4f463d65e14216adb9bcf6d

And have observed that the issue does not exists, below is the link for the screencast regarding same: http://www.screencast.com/t/haelHVMwnC

Hence, we can close this issue.

Note You need to log in before you can comment on or make changes to this bug.