London Dev Meetup Rescheduled! Due to unavoidable reasons, the event has been moved to 21st May. Speakers remain the same—any changes will be communicated. Seats are limited—register here to secure your spot!
AI OnAI Off
London Dev Meetup Rescheduled! Due to unavoidable reasons, the event has been moved to 21st May. Speakers remain the same—any changes will be communicated. Seats are limited—register here to secure your spot!
Seems you ran into a Naming missmatch.
EpiServers PageData has a Name property that gets the PageName property. If you call it Foo instead does it pass?
I read a good article regarding set up the basic unit test in episerver 7 (http://tedgustaf.com/blog/2013/10/unit-testing-in-episerver-7/)
I copy the same code from the above article with slight modification and trying to run it in my episerver 7.5 project with nunit instead of VisualStudio Unit test, However I keep receiving " EPiServer.Core.EPiServerException : Property 'PageName' does not exist, can only assign values to existing properties" error.
Can someone tell me where I made the mistake?
Thanks
[TestFixture] public class Test1 { [SetUp] public void Setup() { // Create a mock repository var mockRepository = new Mock<IContentRepository>(); // Setup the repository to return a start page with a preset property value mockRepository.Setup(r => r.Get<StartPage>(ContentReference.StartPage)).Returns(new StartPage { Name = "Start" }); // Create a mock service locator var mockLocator = new Mock<IServiceLocator>(); // Setup the service locator to return our mock repository when an IContentRepository is requested mockLocator.Setup(l => l.GetInstance<IContentRepository>()).Returns(mockRepository.Object); // Make use of our mock objects throughout EPiServer ServiceLocator.SetLocator(mockLocator.Object); } [Test] public void TestStartPage() { var startPage = ServiceLocator.Current.GetInstance<IContentRepository>().Get<StartPage>(ContentReference.StartPage); Assert.AreEqual(startPage.Name, "Start"); } }