Welcome to Typemock Answers. Here you can ask and receive answers from other community members. And if you liked or disliked an answer or thread: react with an up- or downvote Enjoy!

TypeMock.ArrangeActAssert.Suggest.TestUtil.AssertRunningInSandbox()

0 votes

When I have TypeMock Suggest and Save tests for a small test project I've created I get the error below.  If I create the same tests manually in a separate project then the tests work.  Any ideas?

Initialization method UnitTestMovieRatings.PriceTests.Setup_RunBeforeEachTest threw exception. TypeMock.TypeMockException: TypeMock.TypeMockException: 
*** *** To protect you from disk deletions and registry corruptions this test class may only run using Typemock SmartRunner.
    at TypeMock.ArrangeActAssert.Suggest.TestUtil.AssertRunningInSandbox()
   at UnitTestMovieRatings.PriceTests.Setup_RunBeforeEachTest() in C:\Users\christian.king\documents\visual studio 2015\Projects\MovieRatings\TypeMockGeneratedTests\MovieRatingsUnitTests\PriceTests.cs:line 59
   at TypeMock.MockManager.getReturn(Object context, String typeName, String methodName, Object methodGenericParams, Boolean isDecorated, Boolean isInterceptedType, Object[] methodArguments)
   at Typemock.Interceptors.Profiler.InternalMockManager.getReturn(Object that, String typeName, String methodName, Object methodParameters, Boolean isInjected, Boolean isInterceptedType)
   at UnitTestMovieRatings.PriceTests.Setup_RunBeforeEachTest() in C:\Users\christian.king\documents\visual studio 2015\Projects\MovieRatings\TypeMockGeneratedTests\MovieRatingsUnitTests\PriceTests.cs:line 57
asked Nov 8, 2016 by chking999 (170 points)

1 Answer

0 votes
Hello,

It's likely you had [SafetyNet] attribute on your test class. It protects you from harming your system by smth like Directory.Delete() call etc.

How you tried to run this test?
answered Nov 10, 2016 by eva (1,580 points)

If I comment out these two lines then it works:

  • [SafetyNet(typeof(Index))]
  • TypeMock.ArrangeActAssert.Suggest.AssertRunningInSandbox()

Which doesn't make a whole lot of sense because the method under test is a very simple method:

        private static decimal Price(int age)
        {
            if (age < 12)
            {
                return 5m;
            }
 
            if (age < 18)
            {
                return 10m;
            }
 
            return 14.5m;
        }
It's how Suggest works - it defends each test by SafetyNet attribute. And you can always run it via SmartRunner without any problems.

So you can even run it with SmartRunner, or comment/delete these lines.
...