Mocking Umbraco Context - GetUmbracoContextWithRouteData Method on UmbracoContextHelper class missing
Is there an alternative method for GetUmbracoContextWithRouteData() on the UmbracoContextHelper class (Umbraco.Tests assembly) in Umbraco v7.3.4?
I need to mock an instance of IUmbracoContext on my Unit Tests, which I could do previously with the Umbraco.Tests.dll on v7.2.8, but this method has disappeared from the same dll after upgrading to v7.3.4.
This is the my code currently:
var umbracoContextHelper = new UmbracoContextHelper();
var umbracoContext = UmbracoTests.GetUmbracoContextWithRouteData("http://rb.com", 0);
_umbracoContextMock = new Mock<IUmbracoContext>();
_umbracoContextMock.Setup(x => x.Current).Returns(() => umbracoContext);
Is there a different way of doing this in v.7.3.4?
Mocking Umbraco Context - GetUmbracoContextWithRouteData Method on UmbracoContextHelper class missing
Is there an alternative method for GetUmbracoContextWithRouteData() on the UmbracoContextHelper class (Umbraco.Tests assembly) in Umbraco v7.3.4?
I need to mock an instance of IUmbracoContext on my Unit Tests, which I could do previously with the Umbraco.Tests.dll on v7.2.8, but this method has disappeared from the same dll after upgrading to v7.3.4.
This is the my code currently:
Is there a different way of doing this in v.7.3.4?
Thanks in advance for your help.
Hi Edson, I have released a NuGet package to do exactly this. You can find it at https://www.nuget.org/packages/GDev.Umbraco.Testing/ and also a blog post on how to get started http://garydevenay.com/articles/unit-testing-in-umbraco-7x/
Let me know if you need any assistance getting up and running.
Thanks Gary!
is working on a reply...