public void Load_TradeDataLoadersSectionSpecifiedButIncorrectClassName_ConfigurationErrorsException()
        {
            // arrange
            // all expected values that we gonna mock into further
            const int expectedPeriod    = 5;
            string    expectedDirectory = Environment.CurrentDirectory;

            var mockedConfigManager = A.Fake <IConfigurationManager>(); // mock System.Configuration.Manager

            #region mock fake values for AppSettings elements of app.config of System.Configuration.Manager
            var fakeAppSettings = new NameValueCollection
            {
                { "UpdatesMonitoringPeriodSeconds", expectedPeriod.ToString() },
                { "MonitoringDirectoryPath", expectedDirectory }
            };
            mockedConfigManager.CallsTo(cm => cm.AppSettings).Returns(fakeAppSettings);
            #endregion

            #region mock TradeDataLoadersSection of app.config of System.Configuration.Manager
            var appConfigSection = A.Fake <TradeDataLoadersSection>();
            var fakeTradeDataLoaderElementCollection = new TradeDataLoaderElementCollection();
            var tradeDataLoaderElement = new TradeDataLoaderElement
            {
                Assembly = "TradeDataMonitoring.dll",
                Class    = "NOT-EXISTENT-TYPENAME###TradeDataMonitoring.TradeDataLoaders.CsvFileTradeDataLoader" // INCORRECT VALUE
            };
            fakeTradeDataLoaderElementCollection.Add(tradeDataLoaderElement);
            appConfigSection.CallsTo(section => section.TradeDataLoaders).Returns(fakeTradeDataLoaderElementCollection);
            mockedConfigManager.CallsTo(cm => cm.GetSection("TradeDataLoadersSection")).Returns(appConfigSection);
            #endregion

            // act
            TradeDataMonitorAppSettings.Load(mockedConfigManager); // call Load with all the mocked stuff
        }
        public void AllProperties_LoadedSettingsCorrect_NoException()
        {
            // arrange
            // all expected values that we gonna mock into further
            const int expectedPeriod    = 5;
            string    expectedDirectory = Environment.CurrentDirectory;
            var       expectedLoaders   = new List <ITradeDataLoader>()
            {
                new CsvFileTradeDataLoader()
            };

            var mockedConfigManager = A.Fake <IConfigurationManager>(); // mock System.Configuration.Manager

            #region mock fake values for AppSettings elements of app.config of System.Configuration.Manager
            var fakeAppSettings = new NameValueCollection
            {
                { "UpdatesMonitoringPeriodSeconds", expectedPeriod.ToString() },
                { "MonitoringDirectoryPath", expectedDirectory }
            };
            mockedConfigManager.CallsTo(cm => cm.AppSettings).Returns(fakeAppSettings);
            #endregion

            #region mock TradeDataLoadersSection of app.config of System.Configuration.Manager
            var appConfigSection = A.Fake <TradeDataLoadersSection>();
            var fakeTradeDataLoaderElementCollection = new TradeDataLoaderElementCollection();
            var tradeDataLoaderElement = new TradeDataLoaderElement
            {
                Assembly = "TradeDataMonitoring.dll",
                Class    = "TradeDataMonitoring.TradeDataLoaders.CsvFileTradeDataLoader"
            };
            fakeTradeDataLoaderElementCollection.Add(tradeDataLoaderElement);
            appConfigSection.CallsTo(section => section.TradeDataLoaders).Returns(fakeTradeDataLoaderElementCollection);
            mockedConfigManager.CallsTo(cm => cm.GetSection("TradeDataLoadersSection")).Returns(appConfigSection);
            #endregion


            // call Load with all the mocked stuff
            TradeDataMonitorAppSettings.Load(mockedConfigManager);

            // act
            var tryReadPeriod    = TradeDataMonitorAppSettings.MonitoringPeriodSeconds;
            var tryReadDirectory = TradeDataMonitorAppSettings.MonitoringDirectoryPath;
            var tryReadLoaders   = TradeDataMonitorAppSettings.TradeDataLoaders;

            // assert
            Assert.AreEqual(expectedPeriod, tryReadPeriod);
            Assert.AreEqual(expectedDirectory, tryReadDirectory);
            Assert.IsTrue(expectedLoaders.Count == tryReadLoaders.Count &&
                          expectedLoaders.First().GetType() == tryReadLoaders.First().GetType());
        }