davidvujic / episerver-fakemaker Goto Github PK
View Code? Open in Web Editor NEWHelp features for test driving EPiServer CMS
Help features for test driving EPiServer CMS
Hi David,
Your FakeMaker is great! I really enjoy working with it and I love it! So thanks a lot for this awesome tool. ๐
Is it possible to use them in ContentLoader?
Right now I create everything in FakeMaker, but I also need ContentLoader in some places so I need to add all pages also in that. Is there any easier way?
mockContentLoader.Setup(r => r.Get<StartPage>(It.IsAny<ContentReference>())).Returns((StartPage)start.Page);
Hi David,
I saw your modifications for supporting start pages and read your blog bost, for me, using ContentReference.StartPage covers quite some (test) cases so I can now clean up the extra boiler plate, thanks and thanks for the credits :).
I have one more suggestion/improvement which imho is rather essential.
When pages are registered in the fake repository they get registered as IContent or PageData and not as the actual concrete types. So now whenever I request a PageData subclass, for example 'ProductOverviewPage' I get a null reference. I guess it will work when pages are registered using their actual concrete type, even when requesting a PageData type (I think).
The difficult part in setting up the mocked calls for the fake repository is that the Get<> and GetChildren<> methods are generic methods so it will be hard to register the actual types in the Moq Setup calls. At the moment there is only one place where you actually have the generic information and that is in the FakePage.Create<T>()
method. It's ugly but in that place you could do something like: Func<IContentRepository, T> repoSetup = (repo) => repo.Get<T>(fake.Page.ContentLink);
,and in FakeMaker.AddToRepository()
you could request that delegate from the FakePage
and use it in the Mock Setup call. But to do such a thing properly really means some architectual changes I guess.
Regards,
Robert.
Hi,
It would be convenient with FakeContent instead of FakePage so we can fake blocks as well.
I tried to do this by myself, but this method internal override void HelpCreatingMockForCurrentType(IFakeMaker maker)
is marked as internal, so can't override it when inheriting from Fake
. Do you mind changing it to public, and maybe add FakeContent as well?
Add a "CONTRIBUTING.md" file to the project, describing how to contribute to the project.
TODO: Add code written by @ashkansiroos.
Hi,
I wonder what is the scope of this project, what are the goals, how long have we (or you) come so-far?
Is the goal to mimick a full running EPiServer website for unit testing? Or is the goal to run the whole EPiServer engine in memory, without the need for a database? Or is the goal to cover most of the needed data-loading functionality that EPi provides?
What's the difference between other framework attempts, like that one by @joelabrahamsson?
Thanks!
I am trying FakeMaker and have an issue in EPiServer 9. Does FakeMaker support it?
I have this at runtime:
Result Message: System.IO.FileNotFoundException : Could not load file or assembly 'EPiServer.BaseLibrary, Version=8.5.0.0, Culture=neutral, PublicKeyToken=8fe83dea738b45b7' or one of its dependencies. The system cannot find the file specified.
According to documentation EPiServer.BaseLibrary is removed in EPiServer 9:
http://world.episerver.com/documentation/Items/Upgrading/EPiServer-CMS/9/Breaking-changes/
User feedback: FakeMaker should support ContentData.
Add instructions on how (and where) to add FakeMaker to the code base.
Both alternatives: via NuGet and the GitHub source code.
The Readme file is probably the best place for it.
I just found an issue when passing InvariantCulture to Get method of IContentLoader, it returns null while it should:
If CultureInfo.InvariantCulture is passed in, the provider should return content in the master language.
It also causes other methods to not function correctly. For example, IContentLoader.GetAncestors - internally it uses Get with InvariantCulture.
Hi,
This is not really an issue but more a suggestion.
It would be nice if there was a way to somehow mark a page as the start-page so you would be able to do something like _fake.ContentRepository.GetChildren<PageData>(ContentReference.StartPage);
As an alternative I've used something like the following:
FakePage rootPage = FakePage.Create("Root");
FakePage startPage = FakePage.Create("Start").ChildOf(rootPage);
FakePage.Create("Child 1").ChildOf(startPage);
FakePage.Create("Child 2").ChildOf(startPage);
FakePage.Create("Child 3").ChildOf(startPage);
_fake.AddToRepository(rootPage);
Mock<IContentRepository> contentRepositoryMock = _fake.GetMockForFakeContentRepository();
contentRepositoryMock.Setup(x => x.GetChildren<PageData>(ContentReference.StartPage)).Returns(startPage.Children.Select(x => x.Page));
Regards,
Robert.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.