Пример #1
0
        public void WithInstancePrefixWorksAsExpected()
        {
            // --- Arrange
            var configSettings = new AppConfigurationSettings(
                typeof(AppConfigProvider), null, null, "TestInstancePrefix", "TestInstanceName");

            AppConfigurationManager.Configure(configSettings);
            WindowsEventLogger.LogSourceMapper = new DefaultLogSourceNameMapper();
            var eventLog = new EventLog(SEEMPLEST_LOG2);

            // --- Act
            WindowsEventLogger.Log <WithStringNameAttribute>("Message");

            // --- Assert
            var after      = eventLog.Entries;
            var afterCount = after.Count;

            afterCount.ShouldEqual(1);
            var lastentry = after[after.Count - 1];

            lastentry.Category.ShouldEqual("(5)");
            lastentry.InstanceId.ShouldEqual(3);
            lastentry.Message.ShouldEqual("Message");
            lastentry.Source.ShouldEqual("TestInstancePrefix" + SEEMPLEST_SOURCE);
            lastentry.EntryType.ShouldEqual(EventLogEntryType.Information);
            eventLog.Dispose();
        }
Пример #2
0
        public void WriteXmlAndReadXmlWorksAsExpectedWithEmptyProperties()
        {
            // --- Act
            var settings = new AppConfigurationSettings(null, null);

            var element    = settings.WriteToXml("Temp");
            var newSetting = new AppConfigurationSettings(element);

            // --- Assert
            newSetting.Provider.ShouldEqual(typeof(AppConfigProvider));
            newSetting.InstancePrefix.ShouldEqual("");
            newSetting.InstanceName.ShouldEqual("");
            newSetting.ConstructorParameters.ShouldHaveCountOf(0);
            newSetting.Properties.ShouldHaveCountOf(0);
        }
Пример #3
0
        public void TestInit()
        {
            if (EventLog.Exists(SEEMPLEST_LOG))
            {
                EventLog.Delete(SEEMPLEST_LOG);
            }
            if (EventLog.Exists(SEEMPLEST_LOG2))
            {
                EventLog.Delete(SEEMPLEST_LOG2);
            }
            var configSettings = new AppConfigurationSettings(typeof(AppConfigProvider));

            AppConfigurationManager.Configure(configSettings);
            WindowsEventLogger.LogSourceMapper = new DefaultLogSourceNameMapper();
            WindowsEventLogger.Reset();
        }
Пример #4
0
        public void GetSettingValueWorksWithCustomProvider()
        {
            // --- Arrange
            var newSettings = new AppConfigurationSettings(
                typeof(TestConfigProvider), null, null, "instance1", "name");

            AppConfigurationManager.Configure(newSettings);

            // --- Act
            var value1 = AppConfigurationManager.GetSettingValue("key1");
            var value2 = AppConfigurationManager.GetSettingValue("key2");
            var value3 = AppConfigurationManager.GetSettingValue("key3");

            // --- Assert
            value1.ShouldEqual("value1");
            value2.ShouldEqual("value2");
            value3.ShouldBeNull();
        }
Пример #5
0
        public void ConfigurationWorksWithSettings()
        {
            // --- Arrange
            var settings = new AppConfigurationSettings(typeof(TestConfigProvider),
                                                        new ConstructorParameterSettingsCollection(),
                                                        new PropertySettingsCollection(),
                                                        "Prefix", "Name");

            // --- Act
            var before = AppConfigurationManager.CurrentProvider;

            AppConfigurationManager.Configure(settings);
            var after = AppConfigurationManager.CurrentProvider;

            // --- Assert
            _configurationChangedVisited.ShouldBeTrue();
            before.ShouldBeOfType(typeof(AppConfigProvider));
            after.ShouldBeOfType(typeof(TestConfigProvider));
            before.ShouldEqual(_before);
            after.ShouldEqual(_after);
        }
Пример #6
0
        public void DefaultLogSourceMapperWorksAsExpected()
        {
            // --- Arrange
            var configSettings = new AppConfigurationSettings(
                typeof(AppConfigProvider), null, null, "TestInstancePrefix", "TestInstanceName");

            AppConfigurationManager.Configure(configSettings);
            var mapper1 = new DefaultLogSourceNameMapper();

            configSettings = new AppConfigurationSettings(typeof(AppConfigProvider));
            AppConfigurationManager.Configure(configSettings);
            var mapper2 = new DefaultLogSourceNameMapper();
            var mapper3 = new DefaultLogSourceNameMapper("Dummy");

            // --- Act
            var name1 = mapper1.Map("Hi");
            var name2 = mapper2.Map("Hello");
            var name3 = mapper3.Map("Howdy");

            // --- Assert
            name1.ShouldEqual("TestInstancePrefixHi");
            name2.ShouldEqual("Hello");
            name3.ShouldEqual("DummyHowdy");
        }
Пример #7
0
        /// <summary>
        /// Constructure for User Info.
        /// </summary>
        /// <param name="_appSettingsSection"></param>
        /// <param name="_baseService"></param>

        public UserInfoAPIController(IOptions <AppConfigurationSettings> _appSettingsSection, IBaseService <UserInfo> _baseService)
        {
            objAppConfigurationSettings = _appSettingsSection.Value;
            baseService = _baseService;
        }