probably a simple one, but cant get it to work;
i've changed the signature one on the methods to Task
On my unit tests i am using fluent assertions.
but cant get this to work:
_catalogVehicleMapper
.Invoking(m => m.MapToCatalogVehiclesAsync(searchResult, filtersInfo, request, default(CancellationToken)))
.Should().Throw<ArgumentException>()
.WithMessage("One of passed arguments has null value in mapping path and can not be mapped");
the MapToCatalogVehiclesAsync
is the async method, but i need to await it, but awaiting and asyncing the invocation, doesnt seem to do it..
someone..?
Although Fabio's answer is correct as well, you can also do this:
_catalogVehicleMapper
.Awaiting(m => m.MapToCatalogVehiclesAsync(searchResult, filtersInfo, request, default(CancellationToken)))
.Should().Throw<ArgumentException>()
.WithMessage("One of passed arguments has null value in mapping path and can not be mapped");
And as a side-note, I suggest to always use wildcards in WithMessage
. See point 10 from this blog post.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With