sshushliapin / Sitecore.FakeDb

Unit testing framework for Sitecore.
MIT License
117 stars 36 forks source link

Sitecore 9 TrackingField #206

Open MokoPolo opened 5 years ago

MokoPolo commented 5 years ago

Hello,

When I try to use TrackingField in SiteCore 9 I get exception

System.InvalidOperationException: 'No service for type 'Sitecore.Marketing.Definitions.DefinitionManagerFactory' has been registered.'

How can I solve this issue? It used to work in Sitecore 8

sshushliapin commented 5 years ago

Hello, post your test please so that I could reproduce it. Thanks.

Надіслано з iPhone

13 бер. 2019 р. о 18:30 MokoPolo notifications@github.com пише:

Hello,

When I try to use TrackingField in SiteCore 9 I get exception

System.InvalidOperationException: 'No service for type 'Sitecore.Marketing.Definitions.DefinitionManagerFactory' has been registered.'

How can I solve this issue? It used to work in Sitecore 8

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

MokoPolo commented 5 years ago

I'll have something for you shortly I had to look at other failing unit tests so don't close this issue yet :)

MokoPolo commented 5 years ago

Here you go I hope this helps:

    [TestMethod]
    public void foo()
    {
        var trackItemId = new ID();
        var trackingValue = @"<tracking></tracking>";

        var db = new Db()
        {
            new DbItem("Tracked_Item", trackItemId)
            {
                new DbField("__Tracking") { Value = trackingValue }
            }
        };

        var item = db.GetItem(trackItemId);
        var field = item.Fields["__Tracking"];
        var trackingField = new TrackingField(field);
    }

As soon as you go to the line where TrackingField is used the exception is raised