fluent-assertions Questions

2

Solved

I have two objects of the same type, the type has a string field, in the first object the value is null, in the second one the value is "", how can I force fluent assesrtions to assume that this is...
Yand asked 4/6, 2014 at 9:35

4

Solved

We are currently converting some code that was using Assert.IsTrue(), Assert.AreEqual(), Assert.IsNotNull(), etc. The basic unit test assert Library for C# We want to use FluentAssertions, like va...
Len asked 11/7, 2017 at 13:13

3

Solved

I'm trying to write a unit test for a greater than overridden operator using Fluent Assertions in C#. The greater than operator in this class is supposed to throw an exception if either of the obje...
Mariande asked 26/1, 2016 at 3:10

4

Solved

It seems that Fluent Assertions doesn't work within NUnit's Assert.Multiple block: Assert.Multiple(() => { 1.Should().Be(2); 3.Should().Be(4); }); When this code is run, the test fails imme...
Own asked 30/8, 2017 at 0:0

5

When I use Fluent assertions to test if a property is not null, the analysers still complain about subsequent lines which dereference that line as possibly null. Is there any way to get the compile...
Pansie asked 22/9, 2021 at 11:15

3

Solved

Say I want to test a method returning a bunch of items of the following type using fluent-assertions to ensure that all items have their IsActive-flag set to true: public class Item { public bool...
Bertold asked 19/9, 2013 at 16:8

7

Solved

I have two Json objects as below need to be compared. I am using Newtonsoft libraries for Json parsing. string InstanceExpected = jsonExpected; string InstanceActual = jsonActual; var InstanceObjE...
Dobbins asked 4/10, 2018 at 11:30

2

Solved

I want to compare a list of objects, ignoring the order of the objects in the list and only comparing some of the properties in the objects, currently I'm using the following code to perform this c...
Kanpur asked 20/3, 2013 at 0:20

5

Solved

I'm a bit stuck with this code (this is a sample): public async Task Fail() { await Task.Run(() => { throw new Exception(); }); } [Test] public async Task TestFail() { Action a = async () =&...
Killifish asked 14/3, 2017 at 15:26

3

I am writing unit tests and I have something that looks like this: [Fact] public void GetFoos_only_gets_foo1() { _foo1.included = true; //Foo object _foo2.included = false; //Foo object _sut.Get...
Footed asked 20/7, 2015 at 20:8

2

Solved

I have a class: public class TestClass { public int Id { get; set; } public int CampusId { get; set; } public int CurrentStudentCount { get; set; } public int MaxStudentCount { get; set; ...
Libidinous asked 8/12, 2021 at 22:34

11

Solved

I have two classes: public class ClassA { public int? ID {get; set;} public IEnumerable<ClassB> Children {get; set;} } public class ClassB { public int? ID {get; set;} public string Nam...
Archi asked 3/3, 2014 at 9:9

4

Solved

When I do the following test var contentRes = res as OkNegotiatedContentResult<List<MachineHealthTableDTO>>; contentRes.Should().NotBeNull(); I get the error The call is ambiguous betw...
Natch asked 24/8, 2021 at 16:42

1

I have a number of nested complex objects that I'm attempting to compare with Fluent Assertions with the following code: restResponse.Should().BeEquivalentTo(mappedSoapResponse, options => { o...
Asthenopia asked 30/7, 2020 at 9:22

4

Solved

I am trying to set up the fluent assertion for the below condition. But couldnt find a method with expression or an ObjectAssertion with Or(). I got to check the status of my service is of enum v...
Clyve asked 7/1, 2016 at 11:45

3

Solved

I am trying to find the most fluent manner to assert that a certain string is a valid Guid. iterTags.GUID is a string. My first attempt ended in error because stringdoes not implement Guid. Okay,...
Colley asked 23/1, 2014 at 12:0

1

Solved

I have the following situation: class A { } class B : A { } I want to assert that variables of typeof(B) are assignable to typeof(A) variables. How to do that with fluent assertions?
Mantling asked 17/6, 2021 at 9:52

3

Solved

Normally you test, if an exception gets thrown in a certain method, as follows. I use FluentAssertions: [Fact] public void Exception_gets_thrown() { // Arrange var foo = new Foo("validArgument"...
Fireman asked 5/6, 2012 at 15:37

1

Solved

Because I have some angles, I would like to check for an angle modulus 360°: double angle = 0; double expectedAngle = 360; angle.Should().BeApproximatelyModulus360(expectedAngle, 0.01); I have ...
Plainspoken asked 24/2, 2021 at 21:3

2

Solved

I started to use FluentAssertions recently, which supposed to have this powerful object graph comparison feature. I'm trying to do the simplest thing imaginable: compare the properties of an Addres...
Giule asked 2/2, 2021 at 10:2

2

Solved

I have a simple class with two properties and the Equals method overridden: public class Person : IEquatable<Person> { public Guid Id { get; set; } public string Name { get; set; } publ...
Vendor asked 16/7, 2019 at 7:56

4

Solved

Is there a way to do something like this using FluentAssertions response.Satisfy(r => r.Property1== "something" && r.Property2== "anotherthing")); I am trying to avoid writing multi...
Approver asked 21/4, 2017 at 13:36

2

I've been messing around with some of c#9's new features, and I've run into something that's less than fun. If I try to use Should().BeEquivalentTo() on a record with a DateTimeOffset, setting the ...
Rudie asked 16/10, 2020 at 22:46

8

Solved

I'm trying to establish equivalence of two lists using FluentAssertions in C#, where two things are of importance: the elements are compared by the values they hold, not by reference (i.e. they a...
Methodology asked 10/10, 2014 at 9:8

4

Solved

I want to verify (assert) that certain properties on my DTO object are set. I was trying to do it with Fluent Assertions, but the following code does not seem to work: mapped.ShouldHave().Properti...
Universally asked 28/12, 2013 at 14:17

© 2022 - 2024 — McMap. All rights reserved.