Exemple #1
0
        public void LoadFromAppConfig_should_return_valid_session_after_checking_specified_assembly()
        {
            using (new IndirectionsContext())
            {
                // Arrange
                var myConfiguration = new MyConfiguration();
                myConfiguration.Assembly = typeof(object).Assembly.FullName;

                var assemblyMock = new PAssemblyMock();
                assemblyMock.SetupLoadString(myConfiguration.Assembly);

                var configurationManagerMock = new PConfigurationManagerMock();
                configurationManagerMock.SetupGetSectionString("my");


                // Act
                var section = myConfiguration.LoadFromAppConfig();


                // Assert
                assemblyMock.VerifyLoadString();
                configurationManagerMock.VerifyGetSectionString();
                Assert.IsNotNull(section);
            }
        }
Exemple #2
0
        public void LoadFromSettings_should_return_valid_session_after_checking_specified_assembly_by_AssemblyFrom()
        {
            using (new IndirectionsContext())
            {
                // Arrange
                var myConfiguration = new MyConfiguration();
                myConfiguration.AssemblyFrom = typeof(object).Assembly.Location;
                myConfiguration.Settings     = Guid.NewGuid().ToString("N") + ".my";

                var assemblyMock = new PAssemblyMock();
                assemblyMock.SetupLoadFromString(myConfiguration.AssemblyFrom);

                var configurationMock = new PProxyConfigurationMock();
                configurationMock.SetupGetSectionString("my");
                var configurationManagerMock = new PConfigurationManagerMock();
                configurationManagerMock.SetupOpenMappedExeConfigurationExeConfigurationFileMapConfigurationUserLevel(myConfiguration.Settings, configurationMock);


                // Act
                var section = myConfiguration.LoadFromSettings();


                // Assert
                assemblyMock.VerifyLoadString();
                configurationMock.VerifyGetSectionString();
                configurationManagerMock.VerifyOpenMappedExeConfigurationExeConfigurationFileMapConfigurationUserLevel();
                Assert.IsNotNull(section);
            }
        }
Exemple #3
0
        public void LoadFromSettings_should_throw_InvalidOperationException_if_configuration_contains_the_assembly_information_that_is_different_from_the_specified()
        {
            using (new IndirectionsContext())
            {
                // Arrange
                var myConfiguration = new MyConfiguration();
                myConfiguration.Assembly = typeof(object).Assembly.FullName;
                myConfiguration.Settings = Guid.NewGuid().ToString("N") + ".my";

                var configurationMock = new PProxyConfigurationMock();
                configurationMock.SetupGetSectionString("my", typeof(ConfigurationManager).GetMethods().First());
                var configurationManagerMock = new PConfigurationManagerMock();
                configurationManagerMock.SetupOpenMappedExeConfigurationExeConfigurationFileMapConfigurationUserLevel(myConfiguration.Settings, configurationMock);


                // Act, Assert
                Assert.Throws <InvalidOperationException>(() => myConfiguration.LoadFromSettings());
            }
        }