roslyn-analyzers icon indicating copy to clipboard operation
roslyn-analyzers copied to clipboard

Analyze unit test asserts

Open angularsen opened this issue 4 years ago • 0 comments

Relates to #2 .

It would be helpful to get a compile error if a particular property is not accessed in an assert section of a unit test. This helps keep tests up to date when new properties are added.

Syntax proposal

Use // AccessAll {identifier list} to list all variables that should have their properties read or written. Use :read or :write to specify type of access. Defaults to any of them.

// AccessAll slot:read
// The above comment will enable analyzer for the 'slot' variable and its properties.
// If any of its properties are not read, a compile error is generated.
slot.Price.Should().NotBeNull();
slot.Duration.Should().Be(TimeSpan.FromHours(2));
slot.Price.Currency.Should().Be("NOK");
slot.Price.AppliedDiscounts.Should().BeEmpty();

angularsen avatar Oct 06 '20 13:10 angularsen