meziantou / Meziantou.FluentAssertionsAnalyzers

MIT License
11 stars 5 forks source link

Bug: Assert.That(groups[0].NullableBoolean, Is.True); does not convert #6

Closed inyutin-maxim closed 2 years ago

inyutin-maxim commented 2 years ago

I have assertion:

Assert.That(groups[0].IsMember, Is.True);

Where the property IsMember is declared as nullable boolean

can be convert to:

groups[0].IsMember.Should().BeTrue();

but convertion does not work

meziantou commented 2 years ago

Can you provide a repro? What is the error message?

A simple repro works on my side:

// Nunit
var groups = new[] { new { IsMember = true } };
Assert.That(groups[0].IsMember, Is.True);
// FluentAssertions
var groups = new[] { new { IsMember = true } };
groups[0].IsMember.Should().BeTrue();
inyutin-maxim commented 2 years ago

Can you provide a repro? What is the error message?

A simple repro works on my side:

// Nunit
var groups = new[] { new { IsMember = true } };
Assert.That(groups[0].IsMember, Is.True);
// FluentAssertions
var groups = new[] { new { IsMember = true } };
groups[0].IsMember.Should().BeTrue();

Hi @meziantou Your example works correctly because you have a Boolean field defined as non nullable, in my example the IsMember property is defined as nullable

meziantou commented 2 years ago

Fixed by f4b6bc8fdca90e8fa57bf0f0f2801450e2760fb9