1

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?

Thanks in advance for your help.

EdsonF
  • 2,719
  • 3
  • 30
  • 34

1 Answers1

1

In 7.3, the EnsureUmbracoContext method was enhanced so that doing this should no longer be necessary. See https://github.com/garydevenay/Umbraco-Context-Mock for an example of how to mock out UmbracoContext in 7.3.

nizmow
  • 579
  • 2
  • 10