MSpec tests work until I use Moq

2 posts, 0 answers
  1. Aaron
    Aaron  avatar
    1 posts
    Member since:
    Jan 2012

    Posted 19 Feb 2013 Link to this post

    I get an error in JustCode when I try to run tests.  When I run the tests using TestDriven .NET they run fine.  Any idea on what I might be doing wrong.  Simple tests work but once I try to fake something goes wrong.  I don't think it's MSpec because the simple hello world test works.

    ERROR 2013-02-19 15:31:53.166 : TestExecutor (4448): Unhandled Exception [HResult: 80131577]
    System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
       at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
       at Telerik.JustCode.UnitTesting.MSpec.Runner.MSpecRunner.#p.#jb.#2Wc(IGrouping`2 specsByTestType) in c:\_J\workspace\Installer-release\src\UnitTesting.MSpec.Runner\MSpecRunner.cs:line 142
       at System.Linq.Enumerable.<>c__DisplayClass12`3.<CombineSelectors>b__11(TSource x)
       at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
       at System.Linq.Enumerable.<UnionIterator>d__88`1.MoveNext()
       at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
       at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
       at Telerik.JustCode.UnitTesting.MSpec.Runner.MSpecRunner.#JWc(Assembly assembly, IEnumerable`1 contextTasks) in c:\_J\workspace\Installer-release\src\UnitTesting.MSpec.Runner\MSpecRunner.cs:line 185
       at Telerik.JustCode.UnitTesting.MSpec.Runner.MSpecRunner.#JWc(Assembly assembly, MSpecAssemblyTask assemblyTask) in c:\_J\workspace\Installer-release\src\UnitTesting.MSpec.Runner\MSpecRunner.cs:line 124
       at Telerik.JustCode.UnitTesting.MSpec.Runner.MSpecRunner.RunTestTask(UnitTestRunTask testRunTask) in c:\_J\workspace\Installer-release\src\UnitTesting.MSpec.Runner\MSpecRunner.cs:line 93
       at Telerik.JustCode.UnitTesting.TestExecutor.CurrentAppDomainHost.Execute(UnitTestRunTask task) in c:\_J\workspace\Installer-release\src\UnitTesting.TestExecutor\CurrentAppDomainHost.cs:line 38
       at Telerik.JustCode.UnitTesting.TestExecutor.CurrentAppDomainHost.Execute(UnitTestRunTask task)
       at Telerik.JustCode.UnitTesting.TestExecutor.IsolatedAppDomainHost.ExecuteTask() in c:\_J\workspace\Installer-release\src\UnitTesting.TestExecutor\IsolatedAppDomainHost.cs:line 69
       at Telerik.JustCode.UnitTesting.TestExecutor.Executor.<>c__DisplayClass3.<Main>b__2() in c:\_J\workspace\Installer-release\src\UnitTesting.TestExecutor\Executor.cs:line 96
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
    Log Site Stacktrace:
       at Telerik.JustCode.Common.Logging.ExceptionInfo.GetExceptionString(Exception ex)
       at Telerik.JustCode.Common.Logging.ExceptionInfo..ctor(Exception exception, String message)
       at Telerik.JustCode.Common.Logging.LogService.LogException(Exception ex, String message)
       at Telerik.JustCode.Common.Logger.LogException(Exception ex, String message)
       at Telerik.JustCode.UnitTesting.TestExecutor.Executor.CurrentDomain_UnhandledException(Object sender, UnhandledExceptionEventArgs e) in c:\_J\workspace\Installer-release\src\UnitTesting.TestExecutor\Executor.cs:line 123
       at Telerik.JustCode.UnitTesting.TestExecutor.CurrentAppDomainHost.Execute(UnitTestRunTask task)
       at Telerik.JustCode.UnitTesting.TestExecutor.IsolatedAppDomainHost.ExecuteTask() in c:\_J\workspace\Installer-release\src\UnitTesting.TestExecutor\IsolatedAppDomainHost.cs:line 69
       at Telerik.JustCode.UnitTesting.TestExecutor.Executor.<>c__DisplayClass3.<Main>b__2() in c:\_J\workspace\Installer-release\src\UnitTesting.TestExecutor\Executor.cs:line 96
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()

     

    using **.*********.Cqrs.Domain;
    using Machine.Fakes;
    using Machine.Specifications;
    using System;
     
    namespace **.*********.Cqrs.UnitTests.Domain
    {
        public class With_AggregateRoot : WithFakes
        {
            #region Tests
            [Subject("AggregateRoot")]
            public class When_Register_Entity_Is_Called_Entity_Aggegrate_Root_Is_Assigned : With_AggregateRoot
            {
                Establish context = () =>
                {
                    aggregateRoot = An<AggregateRoot>();
                    entity = An<Entity>();
                };
                Because of = () =>
                {
                    aggregateRoot.RegisterEntity(entity);
                };
                It should_be_the_same_as_entity_aggregateRoot = () => aggregateRoot.ShouldBeTheSameAs(entity.AggregateRoot);
                It should_have_the_same_id = () => aggregateRoot.Id.ShouldBeLike(entity.AggregateRoot.Id);
            }
     
     
            #endregion
     
            #region Context
            static AggregateRoot aggregateRoot;
            static Entity entity;
            #endregion
        }
    }

  2. Zdravko
    Admin
    Zdravko avatar
    657 posts

    Posted 20 Feb 2013 Link to this post

    Hello,

     Thanks for reporting the exception that you have encountered.
    I logged it to our system and we will do our best to investigate and fix it as soon as possible.
    Thank you and sorry for the inconvenience.

    Regards,
    Zdravko
    the Telerik team
    Share what you think about JustCode with us, so we can help you even better! You can use the built-in feedback tool inside JustCode, our forum, or our JustCode feedback portal.
  3. DevCraft banner
Back to Top