.NET 8 Testing Times

Sdílet
Vložit
  • čas přidán 21. 12. 2023
  • It's always been difficult to test anything that depends on time, because time is out of control. But with the .NET 8 TimeProvider, we can take control of time itself.
    Source code available at: github.com/JasperKent/Timer-T...
    There were a couple of imperfections in the final version on the video, which I've fixed in the latest revision on GitHub. The mocking of GetUtcNow() in TickFiresEvent() was unnecessary, and the events in the Blazor component needed to be unsubscribed before the clock was switched.
    Related videos:
    - C# 12 Primary Constructors • C# 12 Primary Construc...
    - .NET 8 Keyed Dependency Injection • .NET 8 Keyed Dependenc...
    Topics include:
    - The problems of testing time-based applications
    - CSS animation in Blazor
    - Using the NSubstitute mocking library
    - The TimeProvider class
    - The DateTimeOffset struct
    - The ITimer interface
    - The null coalescing assignment operator (??=)
    - Keyed dependency injection
    - Mocking the current time
    - Mocking timers
  • Věda a technologie

Komentáře • 5

  • @CodingTutorialsAreGo
    @CodingTutorialsAreGo  Před 6 měsíci

    Any other areas of testing you find particularly tricky? Leave a comment.
    Source code available at: github.com/JasperKent/Timer-Testing
    Remember to subscribe at czcams.com/channels/qWQzlUDdllnLmtgfSgYTCA.html
    And if you liked the video, click the 👍.

  • @mahdi4581
    @mahdi4581 Před 6 měsíci +1

    good👍

  • @alfflasymphonyx
    @alfflasymphonyx Před 6 měsíci +1

    Nice video but I still find it way too complicated. I would siimply launch the application with the value of TimeProvider set to whatever needs testing. Thus no mocking and all the rest.
    But thanks for the very nice video.

  • @jonbakari1330
    @jonbakari1330 Před 6 měsíci +1

    did you want comment? okay. It is my comment - I was 4th. It is mean I gave you 4th like (probably). Why am I not seriously man? It is simple reason. I am foreigner and English is not my native language so when I try to say (or to write) in this f-words lang I feel like baby. This make me little bit nervous and I cover self under jokes. I am foreigner but I am not alien - I am csharp programmer. Do you remember "old man from Nantucket"? It is me. I am interest how many nowadays guys understand my last joke-hidden information.