fluent-assertions

Customize failure handling in FluentAssertions

落爺英雄遲暮 提交于 2021-01-28 04:51:23
问题 I'm trying to use FluentAssertions not only as testing assertions framework but also to check runtime contracts (like advanced Debug.Assert, and I have read this question). The desired behaviour is: In debug mode: throw exceptions (it does). In release mode: do not stop method execution (no exception is thrown) but execute custom action (write to log). Is there a way to customize failure handling behaviour? There is IAssertionStrategy interface which is exactly about failure handling. However

(When) would it be a good idea to use FluentAssertions? [closed]

天涯浪子 提交于 2021-01-04 02:42:28
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 1 year ago . Improve this question I am rewriting a C# .NET project and currently planning how I am going to do the testing. After everything I have read I will install the XUnit framework (for the first time -- I am more experienced with MSTest). Now I am wondering whether I should

(When) would it be a good idea to use FluentAssertions? [closed]

旧街凉风 提交于 2021-01-04 02:39:21
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 1 year ago . Improve this question I am rewriting a C# .NET project and currently planning how I am going to do the testing. After everything I have read I will install the XUnit framework (for the first time -- I am more experienced with MSTest). Now I am wondering whether I should

(When) would it be a good idea to use FluentAssertions? [closed]

谁说胖子不能爱 提交于 2021-01-04 02:36:56
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 1 year ago . Improve this question I am rewriting a C# .NET project and currently planning how I am going to do the testing. After everything I have read I will install the XUnit framework (for the first time -- I am more experienced with MSTest). Now I am wondering whether I should

(When) would it be a good idea to use FluentAssertions? [closed]

寵の児 提交于 2021-01-04 02:36:25
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 1 year ago . Improve this question I am rewriting a C# .NET project and currently planning how I am going to do the testing. After everything I have read I will install the XUnit framework (for the first time -- I am more experienced with MSTest). Now I am wondering whether I should

Fluent assertion for OR condition

做~自己de王妃 提交于 2020-12-29 09:13:14
问题 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 value Pending or Active services.Should().HaveCount(totalServices).And.BeOfType<Service>().Which.ServiceStatusKey.Should().Be(Status.Pending); I want something like, .Be(Status.Pending).Or().Be(Status.Active) Could someone please help me achieving this. FluentAsserstions Version : 4.1.1 (Latest from

How to replace Assert.Fail() with FluentAssertions

不想你离开。 提交于 2020-01-24 03:12:04
问题 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 value.Should().BeNull(). I'm stuck on a few tests using Assert.Fail() in some locations. What should I use to efficiently replace those, since we want to do away with every single "Assert.*", and I can't find an equivalent in FluentAssertions? Here is an example [TestMethod, TestCategory(

FluentAssertions ShouldNotThrow is not recognised for an async method/Func

爱⌒轻易说出口 提交于 2020-01-23 04:49:28
问题 I am trying to check an async method throws concrete exception. For that I am using MSTEST and FluentAssertions 2.0.1. I have checked this Discussion on Codeplex and to see how it works with async-exception methods this another one link about FluentAssertions async tests: After a while trying to work with my 'production' code I have switched off to the Fluentassertions fake aync class and my resulting code is like this (put this code inside a [TestClass] : [TestMethod] public void

How to combine collection and property assertions using fluent-assertions?

梦想与她 提交于 2020-01-12 14:29:28
问题 I would like to "combine" Fluent Assertion's collection assertions and property assertions, e.g. assert that two IEnumerable 's are pairwise-equal using property-by-property (possibly "nested") comparison (i.e. structural equality, in functional language parlance). Concrete example: var dic = new Dictionary<int, string>() { {1, "hi"}, {2, "bye" } }; var actual = dic.ToSelectListItems(0).OrderBy(si => si.Text); var expected = new List<SelectListItem>() { new SelectListItem() {Selected = false,

FluentAssertions: equivalence of sorted lists

烂漫一生 提交于 2020-01-01 04:06:52
问题 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 are equivalent, not equal) the order of the elements in the lists is important Is there no function in FluentAssertions (or even NUnit) that does this? Cheers! 回答1: By default, ShouldBeEquivalentTo() will ignore the order in the collections because in most cases two collections are equivalent if they