Same code work in Umbraco 8 but failure version 10
Hi :
I have to migrate unit test, but find the error in Umbraco 10
[Fact]
public void MyCodeTest() {
var parentAlias = "parentAlias";
var testParentCode = new Mock<IPublishedContent>();
var testParentCodeProperty = new Mock<IPublishedProperty>();
var cultureCodeElement = new List<IPublishedElement>();
testParentCodeProperty.Setup(s => s.Alias).Returns(parentAlias);
testParentCodeProperty.Setup(s => s.GetValue(null, null)).Returns(cultureCodeElement);
testParentCodeProperty.Setup(s => s.HasValue(null, null)).Returns(true);
testParentCode.Setup(s => s.GetProperty(parentAlias)).Returns(testParentCodeProperty.Object);
var testSiteNode = new Mock<IGetSiteNode>();
testSiteNode.Setup(x => x.FromNodePath(It.IsAny<string>())).Returns(testParentCode.Object);
var resultNode = testSiteNode.Object.FromNodePath(parentAlias);
var result = resultNode?.Value(parentAlias) as IEnumerable<IPublishedElement>;
result.Should().NotBeNull();
}
This code is work for Umbraco 8, when I go to Umbraco 10
during the code var result = resultNode?.Value(parentAlias) as IEnumerable<IPublishedElement>; it throw the exception :
System.TypeInitializationException: 'The type initializer for 'Umbraco.Extensions.FriendlyPublishedContentExtensions' threw an exception.'
Inner exception :
ArgumentNullException: Value cannot be null. (Parameter 'provider')
Hi there,
I need to write some unit tests but we still got this error. I use these packages and this code. nothing else
. umbraco v12.2.0
. xunit v2.5.3
. NSubstitute v5.1.0
var content = Substitute.For<IPublishedContent>();
content.Value<string>("title").Returns("Title");
Same code work in Umbraco 8 but failure version 10
Hi :
I have to migrate unit test, but find the error in Umbraco 10
This code is work for Umbraco 8, when I go to Umbraco 10 during the code
var result = resultNode?.Value(parentAlias) as IEnumerable<IPublishedElement>;
it throw the exception :Inner exception :
do you have any idea?
Hi there, I need to write some unit tests but we still got this error. I use these packages and this code. nothing else . umbraco v12.2.0 . xunit v2.5.3 . NSubstitute v5.1.0
@DennisAdolfi @RasmusOlofsson
is working on a reply...