Copied to clipboard

Flag this post as spam?

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


  • Daniel B Christensen 15 posts 115 karma points
    Jan 30, 2018 @ 17:20
    Daniel B Christensen
    0

    Testing with Umbraco and TypedContent

    Hi everyone,

    I'm hoping that someone here can give me a helping hand. We have started to expand the number of tests in our products which is based off Umbraco, and for this reason we of cause want to test as much as possible with automated unit tests.

    For starters we have take some inspiration from this blog post: http://blog.aabech.no/archive/the-basics-of-unit-testing-umbraco/

    However while this solves some of the problems that we had encountered with testing, we still have one glaring problem.

    How can we fake the results from the UmbracoHelper.TypedContent & TypedMedia?

  • Ed Parry 64 posts 252 karma points c-trib
    Feb 22, 2018 @ 10:20
    Ed Parry
    0

    Similar question here - have some functionality that effectively requires getting all child nodes that match certain criteria (via some linq).

    There's a great article on Skrift that starts to go into some detail on this, effectively mocking IPublishedContent items then mocking the return object of TypedContent. It starts from the "Complex Situation" heading in the article.

    We're working through an implementation of this now so will report back if we get it up and running, but would be interested if others have solved this issue in different ways?

  • croban 25 posts 96 karma points
    Mar 18, 2018 @ 00:48
    croban
    0

    I would like to have an Test which has real database and real published content so that this could be possible:

    var data= UmbracoHelper.TypedContet(1234) Assert.IsTrue(data.GetPropertyValue<bool>("db real property and data"))

    I don't want to speak with Mock. I just want to use real database and published content (cache).

    I saw this post from "Skrift" just I don't get it, how to configure all those dependencies ;). Basically, DbContext and IPublishedContent should be injected with real data, if someone has solution for this?

Please Sign in or register to post replies

Write your reply to:

Draft