-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace Enumerable.First() with more defensive logic #15
Comments
I notice that the listed areas are using FirstOrDefault now - is more required to close this issue down? If so, I'm happy to contribute. |
The issue is still actual but let me rephrase it a little bit. The site should still be functional* if there are no (zero) content items of the following types:
*functional == the site doesn't throw any exceptions == all exceptions are either handled or prevented by null checks (the content is just not displayed) |
if you want to pick it up @Steve-Fenton just leave a note here, please. thanks! |
Hi @petrsvihlik, I'll take a look. Any preference on the test project in terms of unit testing frameworks? |
@Steve-Fenton We prefer nunit for .NET Framework and xunit for .NET Core. If you need to reference any other library (e.g. for mocking) the rule of thumb is to use libraries that target .NET Standard. So e.g. Moq or FakeItEasy will do. |
Hi @petrsvihlik - I'm hitting a few problems creating mocks for some of the types, as they are sealed and have internal-only constructors, for example Thanks, Steve |
Hi @Steve-Fenton , yes...it should be possible since yesterday :) |
@petrsvihlik brilliant stuff. I'll update the packages and get working on this. Thanks for the information. |
Hello, I have been testing this using a web crawler against my local instance, as the amount of changes I would have to make in order to bring the views under test is monumental. I ran a full crawl, then started un-publishing various content items from my copy of the demo data. The errors I found from this testing are:
Fix:
Fixed by wrapping with:
Before
After
I am currently dealing with a combination of VS2015/GitHub two-factor auth problems that is preventing this local change going up to my branch, and having to look at a live issue in my day job, so I don't know when the commit is coming for this. |
@Steve-Fenton last thing before we close this issue. Could you please verify the following three scenarios?
They were reported some time ago so I'm not sure if they're still valid. |
I have tested using "unpublish" on "Home page hero unit" and there are no errors.
I'm not sure which content to remove on this one. Can I have a hint?
Again, I unpublished all cafes. There is no error, although the page looks very blank. |
👏 🎉 👌 thanks for your help, @Steve-Fenton ! |
In ContactsController, HomeController, Home view, Coffee view, Cafe, and Product display templates, there is the Enumerable.First() being used.
Missing content can break the site.
Replace these calls with a more defensive logic.
(Internal reference: DEL-971)
The text was updated successfully, but these errors were encountered: