Copied to clipboard

Flag this post as spam?

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


  • Charlie Haley 7 posts 119 karma points
    Mar 12, 2019 @ 08:35
    Charlie Haley
    0

    Unit testing - testing Basket

    Hi all,

    I'm using MSTest as my testing framework and I'm wanting to Mock the Basket object so I can test the add to basket functionality.

    I have a AddToBasket function in one of my surface controllers that does a small amount of business logic then adds to the basket using Basket.AddItemVariant, I want to be able to sucesfully test this.

    I noticed there's a Merchello.Tests package on NuGet but one of its dependencies is Umbraco.Core which doesn't exist (Should it be UmbracoCms.Core?). Either way, I managed to install this package and it's not clear what objects I should be using for mocking. Are there any docs for unit testing online?

    I had a look through the solution on GitHub and noticed everything was inherting from DatabaseIntegrationTestBase or a similar base class.

    _customer = PreTestDataWorker.MakeExistingAnonymousCustomer();
    _basket = Basket.GetBasket(MerchelloContext.Current, _customer);
    

    This looks like what I need but I can't for the life of me get MerchelloContext working properly.

    Thanks!

Please Sign in or register to post replies

Write your reply to:

Draft