Base solution for your next web application
Ends in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

SettingManager Null in When Running from test project #1351


User avatar
0
justin created

I added MySettingProvider under core project

public class MYSettingProvider : SettingProvider
    {
        public const string SearchResultPageSize = "SearchResultPageSize";
        public override IEnumerable<SettingDefinition> GetSettingDefinitions(SettingDefinitionProviderContext context)
        {
            return new[]
                {
                    new SettingDefinition(
                        SearchResultPageSize,
                        "10"
                        ),
                };
        }

Then Under MYCoreModule.cs
            Configuration.Settings.Providers.Add<MYSettingProvider>();

Then under application Service project
SettingManager.GetSettingValue<int>(MYSettingProvider.PSearchResultPageSize);
    }

Above code works when i run web project

But when i try to run my Unit Test and call service method under application project it fails with SettingManager being null. i tried adding below under MyTestModule with no success any ideas?

Configuration.Settings.Providers.Add<MySettingProvider>();

2 Answer(s)
  • User Avatar
    0
    justin created

    any idea?

  • User Avatar
    0
    hikalkan created
    Support Team

    Does your test module depends on your code module? maybe your module is not being initialized in unit tests. add a breakpoint and run a test in debug to see it.