This project is read-only.

[Suggestion] Expose Diagnostic Services for unit testing

Jun 6, 2014 at 7:43 AM
I think it's a good idea to expose Diagnostic Services to be used in unit testing. Currently the only unit test (more like integration test) I write for DI root is to call full DI root register and then call Verify. This kind of test serves me well and allows to spot problems with missed registration before I run app (most importantly - it can fail automatic build and prevent broken app from deploying to server).

But I would really love to have feature to write unit tests that fails if for example there is some particular type of error present in Diagnostic Services errors list.
Jun 6, 2014 at 7:56 AM
Edited Jun 6, 2014 at 7:57 AM
Hi @FuriCuri the diagnostic services are exposed for writing tests against, through the diagnostics API. This is taken from the documentation:
public void Container_Always_ContainsNoDiagnosticWarnings()
    // Arrange
    var container = Bootstrapper.GetInitializedContainer();


    // Assert
    var results = Analyzer.Analyze(container);

    Assert.IsFalse(results.Any(), Environment.NewLine +
            from result in results
            select result.Description));
Does this provide the features you are enquiring about?
Marked as answer by dot_NET_Junkie on 6/6/2014 at 1:01 AM
Jun 6, 2014 at 7:59 AM
Ah, silly me - I was under impression that it only accessible in debug.