Questions tagged [fluent-assertions]

Fluent Assertions is a set of .NET extension methods that allow you to more naturally specify the expected outcome of a TDD or BDD-style test and which tries to keep you out of the debugger hell. Targets .NET Framework 4.5 and 4.7, as well as .NET Core 2.0, .NET Core 3.0, .NET Standard 1.3, 1.6 and 2.0. Supports the unit test frameworks MSTest, MSTest2, Gallio, NUnit, XUnit, MBUnit, MSpec, and NSpec.

Fluent Assertions is a library with extension methods to be used for assertions in your unit tests. The main goals of Fluent Assertions are to keep your unit tests readable, and to give descriptive error messages in case of failing tests.

Resources

394 questions
0
votes
1 answer

Proper use of reasons

My test code has the following assert: testSubscriber.Called.Should().BeTrue("the handler was not called"); When it fails I get the following error message: Expected True because the handler was not called, but found False. English is not my…
Calin
  • 6,661
  • 7
  • 49
  • 80
0
votes
1 answer

ShouldBeEquivalentTo causing object reference not set exception / definition of ExcludeMissingProperties

Summary: While writing unit tests using Fluent Assertions, I've run into a couple of issues which I've described in detail below. Please let me know if you need any additional info from me, but I'm not sure if this is indeed expected behavior or…
m27
  • 79
  • 1
  • 9
0
votes
1 answer

Is there a testing technique to verify all properties have been tested

I have the following situation and any help would be appreciated. public class Poco { public string SomeData { get;set; } public string SomeMoreData { get;set; } } public class Worker { public Poco DoWork() { // do stuff …
SkeetJon
  • 1,491
  • 1
  • 19
  • 40
0
votes
1 answer

FluentAssertions AllProperties().NotEqualTo()?

Guess I miss something obvious, or could it be that I use and old version (1.7.1.1)? I write a test for my updateMyDto method. I want my assert to look like => updatedDto.ShouldHave().AllProperties().NotEqualTo(originalDto); So I could verify that…
Slampen
  • 790
  • 9
  • 21
0
votes
3 answers

How to test properties atomically in nunit

Given an object with several properties, say System.Drawing.Rectangle, I wanted to assert the values of ALL the properties (not stopping when ONE property didn't match) and report ALL the properties. I tried this code, hoping it would do what I…
enorl76
  • 2,562
  • 1
  • 25
  • 38
0
votes
1 answer

FluentAssertions Should Contain failing when it shouldn't

I'm getting some odd behavior in a test I'm writing using FluentAssertions. I have the following class: public class Die { Random rand; public Die() { rand = new Random(); } public Symbol Roll() { …
jtheis
  • 916
  • 3
  • 12
  • 28
0
votes
1 answer

FluentAssertions: comparing shared properties of list members

I have to compare two collections taking into account only the shared properties. If I understand Dennis' comment on How to combine collection and property assertions using fluent-assertions? this should work as of version 2.0. I am using this…
paulroho
  • 1,234
  • 1
  • 11
  • 27
0
votes
2 answers

Is there a "should" minitest gem?

I would like to use fluent assertions type of syntax with minitest result.should_be "my result" result.should_be_true result.should_contain "foo" Is there some gem that adds this functionality? My request come from a similar idea in C#.
David MZ
  • 3,648
  • 6
  • 33
  • 50
0
votes
2 answers

String Date Compare

In an BDD test I am comparing dates. When Comparing the dates are in strings. Even thought both the dates are same I get this message and the test fails Expected object to be "01/20/2012 12:00:00 AM", but found "1/20/2012 12:00:00 AM". One more…
katie77
  • 1,797
  • 4
  • 25
  • 43
0
votes
2 answers

How to test XELement and its child elements?

I have a sample Xml code snippet Changed name The xml is loaded to my XElement, and I used XElement xml = ...to…
hardywang
  • 4,864
  • 11
  • 65
  • 101
-1
votes
1 answer

NUnit tests failed with FLuentValidation in ONion Architecture

Im trying to implement nunit tests with fluentvalidations, but it shows me a failed test and the message: FluentValidation.AsyncValidatorInvokedSynchronouslyException : Validator "AddVehicleCommandValidator" contains asynchronous rules but was…
-1
votes
1 answer

I am using MStest (.net core) for my test project, Is there a way to continue the test execution on failure?

I want my test to proceed next line after the assert fails. I tried "try catch block" but tests are not failing. Do we have anything that can fix this issue in fluent assertion [https://fluentassertions.com/] or anyways to handle this in code?
-1
votes
1 answer

Enhance default .NET LINQ poor exceptions with Fluent Asserts on production?

My question title brings general problems when standard .NET exceptions are mostly meaningless with stacktrace or extra information like Sequence contains more than one matching element I am too lazy to write if-else statements every time before…
svonidze
  • 151
  • 8
-2
votes
2 answers

C# unit testing MassTransit handler with MSTest, Moq and FluentAssertions. Can't verify method called exactly once

I have this class called Handler, which is a MassTransit IConsumer: public class Handler : IConsumer { private readonly IOrderRepository _orderRepository; public Handler(IOrderRepository orderRepository) { …
benjamin
  • 1,364
  • 1
  • 14
  • 26
-2
votes
1 answer

Failed an interview due to unit test - I need to learn why

I went for an interview and was given a NUnit test, which failed and asked why it failed, and I couldnt find a reason. During debug the values were all the same except the ID, which was 1 and 0 respectively. I am not strong in testing, but want to…
Adesuwa
  • 25
  • 4
1 2 3
26
27