I'm running some unit tests (NUnit) on my DbContext
(to an Oracle database) in EF Core 2.2 and I'd like to see the SQL
queries it's constructing for each unit test, preferably
- in the Debug window and
- in the Test Explorer pane's detail view of each test.
I have a Unit Test similar to:
[SetUp]
public void Setup()
{
var options = new DbContextOptionsBuilder<MyContext>()
.UseOracle("some connection string")
.Options;
_context = new MyContext(options);
}
[Test]
public void We_can_count_all_the_things()
{
var count = _context.Things.Count();
Assert.That(count, Is.GreaterThan(0));
// something like this for Test output:
Assert.Pass($"SQL QUERY:{???}")
}
... or maybe I can use an ILogger
to direct output to the test result or some magic I'm unaware of.
Any assistance is appreciated.