DevChatter / ChatterBot

Highly modular Twitch chat bot.
MIT License
10 stars 5 forks source link

Dependency injection extensions and unit test to ensure correct DI registration of child dependencies #17

Closed SimonGeering closed 4 years ago

SimonGeering commented 4 years ago

WIP PR for issue #1

Code Changes so far

Changes to dependent packages:

  1. Added FluentAssertions to ChatterBot.Test to improved readability of assertions in tests.

  2. Added Xunit.StaFact to ChatterBot.Test to resolve an issue with the DI Unit Test:

    • As it was attempting to validate DI registrations for the WPF windows it failed with an exception that they can only be loaded form STA type threads, the new WpfTheory attribute allows for this while not impacting other xunit tests in the same test assembly.
  3. Upgraded xunit from V2.4.0 to V2.4.1 since this is the minimum version required by Xunit.StaFact.

Unit Test Errors - why this is a draft PR for now:

benrick commented 4 years ago

Seeing this, I'm really glad I wrapped up and merged in my code, since I knew I was adding a bunch of DI stuff that would impact how you would approach this. 👍

SimonGeering commented 4 years ago

Would be interested in your thoughts on this as I think it may center around if you want VM injection into Forms, or the other way around, or if you take a MediatR messaging approach and have something centrally such as the app class, act as the handler for management of forms.

Either way if you want to pull it down and see if you can make more sense of it than I can, happy to put it in with the test turned off for now though.

benrick commented 4 years ago

Yeah, so there are a few things here:

benrick commented 4 years ago

Also, about a smoke test of this, I pulled it down and tried it. Things still appear to work in the application as expected. 👍 Still connects to Twitch and can send messages in response.

SimonGeering commented 4 years ago

So I have decided we should put this forward as a PR to get these changes in if you're happy with them @benrick . To work around the unit test issue for now I have commented out the UI extension.

benrick commented 4 years ago

Agreed. I think this is core enough of a change to get it merged in sooner rather than later.