1
votes

My unitTests not longer work after Update from Kentico 9 to Kentico 10.

I have a UnitTest like this. (worked fine on Kentico 9)

    [SetUp]
    public void setUp()
    {
        this.pageCreator = new PageCreator();
        this.fixture = new Fixture();
        this.fixture.Customize(new AutoMoqCustomization());
    }
     [Test]
    public void execute()
    {
        this.pageCreator.Execute(null);
    }

I just try to call this Function

 public class PageCreator : ITask
 {
  public string Execute(TaskInfo task)
    {
        try
        {
            this.treeProvider = new TreeProvider(MembershipContext.AuthenticatedUser);
            this.createPages(this.treeProvider);

            return successMessage;
        }
        catch (Exception ex)
        {
            this.sendMailToDeveloper(ex.Message);
            return "Fail";
        }

The Problem is, when I try run my test, I get an Error (because of MembershipContext.AuthenticatedUser [CMS.Membership.MembershipContext.AuthenticatedUser" hat eine Ausnahme vom Typ "System.InvalidOperationException" verursacht])

enter image description here

When I try to make the same in debugMode, everything is working fine.

enter image description here

What can be the problem and how can I fix it ?
I have load all the new Dll from Kentico 10 but nothing changed.

Thanks for your help

1
Are you using the official release of Kentico to perform your upgrade or do you have a prelease or beta version? - Brenden Kehren
Yes the first one. I had kentico 9 full version and used kentico upgrade tool to upgrade to kentico 10. - Dawid Cz

1 Answers

0
votes

try updating your references on the test project to use the Kentico10 nuget packages. the release notes have a section on Automated Tests - https://docs.kentico.com/k10/release-notes-kentico-10

"Automated testing – New Kentico.Libraries.Tests integration package, which separately provides all functionality related to automated testing of the Kentico API. The testing API is no longer available directly within Kentico projects or the main Kentico.Libraries integration package."