Git Product home page Git Product logo

Comments (12)

Steve-Fenton avatar Steve-Fenton commented on May 27, 2024 1

Hi @petrsvihlik, I'll take a look. Any preference on the test project in terms of unit testing frameworks?

from sample-app-net.

Steve-Fenton avatar Steve-Fenton commented on May 27, 2024 1

@petrsvihlik brilliant stuff. I'll update the packages and get working on this. Thanks for the information.

from sample-app-net.

Steve-Fenton avatar Steve-Fenton commented on May 27, 2024

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.

from sample-app-net.

petrsvihlik avatar petrsvihlik commented on May 27, 2024

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:

  • coffee
  • brewer
  • accessory
  • article
  • cafe
  • fact about us
  • grinder
  • hero unit

*functional == the site doesn't throw any exceptions == all exceptions are either handled or prevented by null checks (the content is just not displayed)

from sample-app-net.

petrsvihlik avatar petrsvihlik commented on May 27, 2024

if you want to pick it up @Steve-Fenton just leave a note here, please. thanks!

from sample-app-net.

petrsvihlik avatar petrsvihlik commented on May 27, 2024

@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.

from sample-app-net.

Steve-Fenton avatar Steve-Fenton commented on May 27, 2024

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 DeliveryItemListingResponse<Coffee>. Is there any chance of getting an interface over these types... or are there any suggestions for how I could mock these types?

Thanks,

Steve

from sample-app-net.

petrsvihlik avatar petrsvihlik commented on May 27, 2024

Hi @Steve-Fenton , yes...it should be possible since yesterday :)

Read more here and here.

from sample-app-net.

Steve-Fenton avatar Steve-Fenton commented on May 27, 2024

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:

  1. AboutUsController Line 21: null Facts -> foreach (var fact in response.Item.Facts)

Fix:

        public async Task<ActionResult> Index()
        {
            var response = await client.GetItemAsync<AboutUs>("about_us");

            var viewModel = new AboutUsViewModel
            {
                FactViewModels = MapFactsAboutUs(response)
            };

            return View(viewModel);
        }

        private IList<FactAboutUsViewModel> MapFactsAboutUs(DeliveryItemResponse<AboutUs> response)
        {
            var facts = new List<FactAboutUsViewModel>();

            if (response.Item == null)
            {
                return facts;
            }

            int i = 0;

            foreach (var fact in response.Item.Facts)
            {
                var factViewModel = new FactAboutUsViewModel
                {
                    Fact = (FactAboutUs)fact
                };

                if (i++ % 2 == 0)
                {
                    factViewModel.Odd = true;
                }

                facts.Add(factViewModel);
            }

            return facts;
        }
  1. Contacts/Index.cshtml Line 10: null Roastery -> <li>@Html.DisplayFor(vm => vm.Roastery.Phone)</li>

Fixed by wrapping with:

@if (Model.Roastery != null) {

  1. Shared/DisplayTemplates/PhoneNumber.cshtml: null string

Before

string strippedDashes = Model.Replace("-", string.Empty);

After

string strippedDashes = string.IsNullOrWhiteSpace(Model) ? string.Empty : Model.Replace("-", string.Empty);

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.

from sample-app-net.

petrsvihlik avatar petrsvihlik commented on May 27, 2024

@Steve-Fenton last thing before we close this issue. Could you please verify the following three scenarios?

  • When home page is missing Hero image, it ends up with an unhandled exception
  • When home page is missing content variants for personalization, it ends up with unhandled exception
  • ContactsControler - If there are no Cafes, throws exception on .First()

They were reported some time ago so I'm not sure if they're still valid.

from sample-app-net.

Steve-Fenton avatar Steve-Fenton commented on May 27, 2024
  • When home page is missing Hero image, it ends up with an unhandled exception

I have tested using "unpublish" on "Home page hero unit" and there are no errors.

no-hero

  • When home page is missing content variants for personalization, it ends up with unhandled except

I'm not sure which content to remove on this one. Can I have a hint?

  • ContactsControler - If there are no Cafes, throws exception on .First()

Again, I unpublished all cafes. There is no error, although the page looks very blank.

no-cafe

from sample-app-net.

petrsvihlik avatar petrsvihlik commented on May 27, 2024

👏 🎉 👌 thanks for your help, @Steve-Fenton !

from sample-app-net.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.