locked
Using System.Configuration assembly as a mole RRS feed

  • Question

  • Hi Guys,

    I am trying to use Pex to create automated testing for a legacy application

    I have created a mole for the system.configuration assembly using StubsGeneration - this produces System.Configuration.Stubs.dll

    I now try and dependancy inject the ConfigurationManager.AppSettingsGet from within the PexMethod created earlier

                System.Configuration.Stubs.MConfigurationManager.AppSettingsGet = () =>
                {
                    return new System.Collections.Specialized.NameValueCollection();
                };

    Whenever i try and allow Pex to explore the PexMethod i get the following exception:

    --- Description
    failing test: MoleNotSupportedException, The System.Collections.Specialized.NameValueCollection System.Configuration.ConfigurationSettings.get_AppSettings() cannot be moled due to limitation of the runtime instrumentation
     
    StaticDataManager staticDataManager;
    staticDataManager = StaticDataManagerFactory.Create();
    this.StartProcess(staticDataManager);

     
    [TestMethod]
    [PexGeneratedBy(typeof(StaticDataManagerTest))]
    [Ignore]
    [PexDescription("this test requires to run under the Pex profiler in order to reproduce")]
    [PexNotReproducible]
    [HostType("Pex")]
    public void StartProcess01()
    {
        StaticDataManager staticDataManager;
        staticDataManager = StaticDataManagerFactory.Create();
        this.StartProcess(staticDataManager);
    }


     
    --- Exception details
     
    Microsoft.Stubs.Framework.Moles.MoleNotSupportedException: The System.Collections.Specialized.NameValueCollection System.Configuration.ConfigurationSettings.get_AppSettings() cannot be moled due to limitation of the runtime instrumentation      at System.Void Microsoft.ExtendedReflection.Thrower.Throw(System.Object )
          at System.Void Microsoft.ExtendedReflection.Utilities.ExceptionHelper.Throw(System.Object exception)
          at System.Void Microsoft.ExtendedReflection.Interpretation.Interpreter.InstructionInterpreter.checkForUncatchableException(System.Object exception)
          at System.Void Microsoft.ExtendedReflection.Interpretation.Interpreter.InstructionInterpreter.AtCallException(System.Object exceptionObject, System.Int32 codeLabel)
          at System.Void Microsoft.ExtendedReflection.Monitoring._Checks.AtCallObject(System.Object exception, System.Int32 codeLabel)
        C:\Workspaces\Edexcel.DWSESIE\Trunk\DWSESIE\Source\Edexcel.DWSESIE.StaticDataManager\Edexcel.DWSESIE.StaticDataManager.Tests\StaticDataManagerTest.cs(44): at System.Void Edexcel.DWSESIE.StaticDataManagerTest.StartProcess(Edexcel.DWSESIE.StaticDataManager target)
          at Microsoft.ExtendedReflection.Interpretation.Term Microsoft.ExtendedReflection.__DynamicMethods.invoke:Edexcel.DWSESIE.StaticDataManagerTest.StartProcess(Microsoft.ExtendedReflection.DataAccess.ITermConstructor`1<Microsoft.ExtendedReflection.Interpretation.Term> , Microsoft.ExtendedReflection.DataAccess.ITermDestructor`1<Microsoft.ExtendedReflection.Interpretation.Term> , Microsoft.ExtendedReflection.Interpretation.Term[] )
          at System.Void Microsoft.Pex.Engine.PathExecution.PathExecutorBase.InternalRun(Microsoft.ExtendedReflection.DataAccess.ITermDestructor`1<Microsoft.ExtendedReflection.Interpretation.Term> destructor, Microsoft.Pex.Engine.PathExecution.PathSegmentPreparer segmentPreparer, Microsoft.Pex.Engine.PathExecution.PathSegmentReporter segmentReporter, System.Collections.Generic.IEnumerable`1<Microsoft.Pex.Engine.PathExecution.PathSegment> segments)
          at System.Boolean Microsoft.Pex.Engine.PathExecution.PathExecutorBase.TryRun(Microsoft.Pex.Engine.PathExecution.PexPathExecutionResult& runResult, Microsoft.ExtendedReflection.Interpretation.ISubstitution& finalSubstitution, Microsoft.ExtendedReflection.Interpretation.States.IState& finalState)
     
     
    Is the System.Configuration used by the CLR in such a way that i am unable to use DI on static methods within the assembly?

    Thanks in advance,
    Craig

    Friday, January 8, 2010 3:31 PM

Answers

  • This class and particularly this property is used in the code path that creates separate AppDomain. Due to the way we instrument mscorlib, we cannot put callbacks in this method otherwise we usually crash with a stack overflow.

    I think you raise a good point that we should explain the reasons of this limitations so I'll add that to our list.
    Jonathan "Peli" de Halleux - Give us your input about Pex!
    • Marked as answer by Craig_Jackson Monday, January 11, 2010 2:43 PM
    Friday, January 8, 2010 4:48 PM

All replies

  • This class and particularly this property is used in the code path that creates separate AppDomain. Due to the way we instrument mscorlib, we cannot put callbacks in this method otherwise we usually crash with a stack overflow.

    I think you raise a good point that we should explain the reasons of this limitations so I'll add that to our list.
    Jonathan "Peli" de Halleux - Give us your input about Pex!
    • Marked as answer by Craig_Jackson Monday, January 11, 2010 2:43 PM
    Friday, January 8, 2010 4:48 PM
  • OK Thanks Peli

    Do you think it will be possible to remedy this in future versions of Pex?

    Thanks,
    Craig

    Monday, January 11, 2010 9:23 AM
  • OK Thanks Peli

    Do you think it will be possible to remedy this in future versions of Pex?

    Thanks,
    Craig


    It seems that the info is out of date, Any latest news?
    Friday, September 3, 2010 12:34 AM
  • This should be fixed in the latest release (v0.93).
    Jonathan "Peli" de Halleux - Try Pex online at www.pexforfun.com!
    Friday, September 3, 2010 4:04 AM
  • Looks like this issue still occures in v0.94

     

    Microsoft.Moles.Framework.Moles.MoleNotSupportedException: The System.String System.Resources.ResourceManager.GetString(System.String name) cannot be moled due to limitation of the runtime instrumentation

     

     

     

     

     

     

    Thursday, October 28, 2010 2:12 PM
  • This is a new issue. Please open new threads for new issues - we do not track answered posts.
    Jonathan "Peli" de Halleux - Try Pex online at www.pexforfun.com!
    Sunday, October 31, 2010 1:25 PM