Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Neil Hartley 10 posts 31 karma points
    Jul 29, 2015 @ 13:59
    Neil Hartley
    0

    Unit Testing Controllers

    Hi guys,

    Im currently trying to hook up some unit tests for my controllers that inherit from "SurfaceController, IRenderMvcController". Ive got the Umbraco.Tests dll and configuration in my unit test project and my testfixture is inheriting from BaseRoutingTest and decorated with [DatabaseTestBehavior(DatabaseBehavior.NoDatabasePerFixture)].

    Im creating my umbraco context in the setup using umbracoContext = GetRoutingContext("/").UmbracoContext;

    The project builds but when im trying to run a test I get the following failure message

    SetUp : System.TypeLoadException : Could not load type 'Umbraco.Core.Logging.Logger' from assembly 'Umbraco.Core, Version=1.0.5632.22681, Culture=neutral, PublicKeyToken=null'.
       at Umbraco.Tests.TestHelpers.BaseUmbracoApplicationTest.InitializeFixture()
    

    Im struggling to work out exactly what it is thats causing the problem, im thinking maybe something to do with dll versioning or something but ive now spent a full day trying to work it out to no avail..

    Any suggestions would be greatly appreciated.

    Thanks

  • Neil Hartley 10 posts 31 karma points
    Jul 30, 2015 @ 10:00
    Neil Hartley
    0

    Having explored the assembly for Umbraco.Tests I can see that the code that fails is in the Umbraco.Tests.TestHelpers.BaseUmbracoApplicationTest

    [TestFixtureSetUp]
    public void InitializeFixture()
    {
      Umbraco.Core.Logging.Logger logger = new Umbraco.Core.Logging.Logger(new FileInfo(TestHelper.MapPathForTest("~/unit-test-log4net.config")));
      this.ProfilingLogger = new ProfilingLogger((ILogger) logger, (IProfiler) new LogProfiler((ILogger) logger));
    }
    

    Where or what is Umbraco.Core.Logging.Logger as I cant see it if I view the object browser on Umbraco.Core?

  • Gary Devenay 39 posts 245 karma points
    Jul 31, 2015 @ 11:36
    Gary Devenay
    0

    I think I've found the solution. I had checked out the most recent version of the Umbraco solutions to compile the Umbraco.Tests.dll, though as I am running on 7.2.5, the solutions had some changes to the logger from when 7.2.5 was released.

    Be sure to checkout the tag relating to your release.

    Hope this helps

    Gary

  • Gary Devenay 39 posts 245 karma points
    Jul 31, 2015 @ 10:34
    Gary Devenay
    0

    I'm currently having this same issue. The source of this file is here - I am continuing to investigate and will let you know if I make any progress.

  • Neil Hartley 10 posts 31 karma points
    Aug 17, 2015 @ 15:08
    Neil Hartley
    0

    Thank you all for your help, I got this working by downloading the correct version of the source code that related to the version we are running.

Please Sign in or register to post replies

Write your reply to:

Draft