The Dummy Data Provider

As we can easily see, we're emulating the role of a Data Provider returning one or more sample Quizzes in a credible fashion. The reason for this can't be more obvious; we don't have any Data Provider in place for the time being (and we won't until we reach Chapter 4, Data Model with Entity Framework Core); hence, this is the only way we have to output some stuff and see some decent results on screen.

It's also worth noting that we built it in a way that it will always return identical items, as long as the num parameter value remains the same:

  • The generated items Id will follow a linear sequence, from 1 to num.
  • Any generated item will have incremental CreatedDate and LastModifiedDate values; the higher the Id is, the most recent these dates will be. This follows the assumption that most recent items will have a higher Id, as it normally is for DBMS records featuring numeric, auto incremental keys.

While it obviously lacks any insert/update/delete feature, this trivial technique is viable enough to serve our purposes until we'll replace it with an actual, persistence-based Data Source.

Technically speaking, we can do something better than we did using one of the many Mocking Frameworks available through NuGet: Moq, NMock3, NSubstitute, or Rhino, just to name a few.
These frameworks are the ideal choice when using a Test-Driven Development (TDD) approach, which is not the case in this book. In this specific scenario, our Dummy Data Provider is still a viable way to get what we need, while keeping the focus on our main topic--ASP.NET Core and Angular interaction.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.223.172.132