November Happy Hour will be moved to Thursday December 5th.
Hi there!
I have a Unit test, and in the function, I've used GetUrl() but they gave me a null value.
This is the mock config.
GetMock<UrlResolver>() .Setup(x => x.GetUrl(It.Is<ContentReference>(y => y == contentReference), It.Is<string>(y => y == "de-CH"))) .Returns("de-ch/test.html"); GetMock<UrlResolver>() .Setup(x => x.GetUrl(It.Is<ContentReference>(y => y == contentReference), It.Is<string>(y => y == "it-CH"))) .Returns("it-ch/test.html"); GetMock<UrlResolver>() .Setup(x => x.GetUrl(It.Is<ContentReference>(y => y == contentReference), It.Is<string>(y => y == "fr-CH"))) .Returns("fr-ch/test.html");
and in the services class, I'm using DI
public class ServicesClass { private readonly UrlResolver _urlResolver; public HrefLangsViewComponent( UrlResolver urlResolver) { _urlResolver = urlResolver; }
In this service, I've used GetUrl(), but it always gives me a null value.
var url = _urlResolver.GetUrl(contentLink, hrefWebsitePrefix);
I don't know why, anybody has the solutions?
Thanks.
did you debug to see if contentLink matches contentReference, and hrefWebsitePrefix is exactly "de-CH" etc.? because == requires case sensetive
Hi there!
I have a Unit test, and in the function, I've used GetUrl() but they gave me a null value.
This is the mock config.
and in the services class, I'm using DI
In this service, I've used GetUrl(), but it always gives me a null value.
I don't know why, anybody has the solutions?
Thanks.