~/talk

.NET Testing Best Practices

Talkat Øredev 2024 · 2024-11-06..11-08· [testing]
slides:none on file

Sample ASP.NET Core IoT code gets unit tests added with XUnit and FluentAssertions and mocks supplied via Moq / NSubstitute and AutoMocker. Tests verify actuateLights scenarios (motion, time period, last‑motion) and lead to concrete changes: extract ITimePeriodHelper, replace singleton with constructor injection, introduce TimePeriod enum to turn a runtime magic‑string bug into a compile‑time error. CI runs dotnet test, publishes JUnit results via GitHub Actions, and the example suite ends up green.

AI-written summary · about

  1. 0:00.NET testing intro
  2. 1:06Demo code access
  3. 2:30Speaker & community
  4. 3:14Light controller app
  5. 4:19New xUnit project
  6. 5:58Basic test with Fluent Assertions
  7. 9:32Run tests after build
  8. 9:52Light actuator tests
  9. 12:28Light control scenarios
  10. 15:40Arrange Act Assert pattern
  11. 18:10Making code testable
  12. 21:04Fixing Singleton for testing
  13. 23:55Mocking with Moq
  14. 25:45Motion detection tests
  15. 26:06Injecting time dependency
  16. 28:11DI in console app
  17. 30:18AutoMock for dependencies
  18. 32:07Mocking time & light switcher
  19. 35:20Light turn-off tests
  20. 37:11Debugging test failures
  21. 39:04Magic strings to enums
  22. 41:13GitHub Actions setup
  23. 42:19Publishing test results
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.