Quantcast
Channel: Fluent Assertions
Viewing all 1402 articles
Browse latest View live

Closed Issue: Fluent assertions v1.7.1 fails to compare nullable timespans [12462]

$
0
0
Not tested with latest version. It seems that an overload on SimpleTimeSpanAssertions which accepts a Nullable<TimeSpan> is missing. I was able to work around this by writing the next extension method:

public static class SimpleTimeSpanAssertionsExtensions
{
// The current version of Fluent Assertions (v1.7.1) seems unable to compare nullable timespans.
// Example: myObject.OptionalTime.Should().Be(expectedOptionalTime);
// This method implements a workaround for this problem.
public static void Be(this SimpleTimeSpanAssertions source, TimeSpan? expected)
{
if (expected == null)
{
source.Subject.As<object>().Should().BeNull();
}
else
{
source.Subject.Should().Be(expected.Value);
}
}
}

I am aware that the return type should not be void and that this method does not have parameters for describing the error. But for the moment it fixes my problem at hand.

Best regards,
Bart Koelman
Comments: Continued at https://github.com/dennisdoomen/fluentassertions/issues/5

Closed Issue: DateTimeOffset support [12464]

$
0
0
It would be great if FA supported DateTimeOffset in the same way it supported DateTime.
Comments: https://github.com/dennisdoomen/fluentassertions/issues/6

Edited Issue: Output text of a collection assertion should be more friendly [12466]

$
0
0
The output text of a collection assertion (Should().BeEquivalentTo()) should describe specific differences in objects like ShouldHave().AllProperties().EqualTo() does.

Closed Issue: Output text of a collection assertion should be more friendly [12466]

$
0
0
The output text of a collection assertion (Should().BeEquivalentTo()) should describe specific differences in objects like ShouldHave().AllProperties().EqualTo() does.

Closed Issue: AssertEquality - include property value [12480]

$
0
0
If properties are not equal and property types are the same - show expected and actual property values. This would greatly help debugging the issue.

I ran into the problem when using ShouldAllBeEquivalentTo
Comments: Behavior is as requested

Closed Unassigned: string.Should().NotBeNullOrWhitespace(); [12488]

$
0
0
Can a method for NullOrWhitespace be added to String assertions please? A NullOrEmpty already exists, but not one for whitespace.


Cheers
Comments: Continued through https://github.com/dennisdoomen/fluentassertions/issues/7

Closed Unassigned: BeEmpty() on a byte array [12491]

$
0
0
imho empty on a byte array means that all bytes is zero, not that the actual length is zero.

The method isn't very useful otherwise as it's quite easy to write Buffer.Count.Should.Be(0);
Comments: Won't fix

Closed Unassigned: Assembly not correctly loaded in Mono 3.2.0 [12496]

$
0
0
It seems that a project that references FluentAssertions.dll is not correctly loaded in Xamarin Studio 4.0 (on Mac OS X).

If I remove the reference and I'm also unable to install it with NuGet Package Mgr (the new one for X.Studio).

B.Regards,
Giacomo S.S.
Comments: Don't know how to reproduce this.

Updated Wiki: Home

New Post: Confusion with OnlyContain usage

$
0
0
I don't agree with this. It's still true that an empty collection only contains elements matching a given criterion.

An example:
I wrote a test to verify that a method that transformed a collection of elements did not add any elements. The assertion was along the lines of "result.Should().OnlyContain(item => originalItems.Contains(item))".

If you won't change the behaviour, I think you should at least reflect the behaviour in the method's documentation:
Asserts that the collection is not empty and only contains items that match a predicate.

New Post: Confusion with OnlyContain usage

$
0
0
Here's a work-around for anyone who wants the old behaviour:
public static AndConstraint<GenericCollectionAssertions<T>> ReallyOnlyContain<T>(this GenericCollectionAssertions<T> itemsAssertion, Expression<Func<T, bool>> expectedItem)
{
    var notExpectedItem = Expression.Lambda<Func<T, bool>>(Expression.Not(expectedItem.Body), expectedItem.Parameters);
    return itemsAssertion.NotContain(notExpectedItem);
}

New Post: I need the collection.Should().NotContainInOrder(new[] { 1, 5, 8 }) assertion.

$
0
0
How can I make an extension to have this assertion?
Thanks!

New Comment on "Documentation"

$
0
0
Thanks for having .Should().OnlyContain(x => x..., "Message"). Helped me avoid a lenghty construct!

Created Unassigned: Unit Testing with a DbScripts Project [12497]

$
0
0
I am using VS2013

I have added a UnitTest project that executes the following assertions: (Succesfull)
```
Assert.IsNotNull(drivers);
Assert.AreEqual(recordsExpected, drivers.Count);
```

When I add the FluentAssertions and replace my assertions: (fails because it tries to debug my dbScripts Project) See attached image.
```
![Image](http://example.com/logo.jpg)drivers.Should().NotBeNull();
drivers.Count.Should().Be(recordsExpected);

```

How do I configure FluentAssertions to ignore my dbScripts projects?


Regards,
Angel L. Bermudez, Jr.

Edited Unassigned: Unit Testing with a DbScripts Project [12497]

$
0
0
I am using VS2013

I have added a UnitTest project that executes the following assertions: (Succesfull)
```
Assert.IsNotNull(drivers);
Assert.AreEqual(recordsExpected, drivers.Count);
```

When I add the FluentAssertions and replace my assertions: (fails because it tries to debug my dbScripts Project) See attached image.
```
drivers.Should().NotBeNull();
drivers.Count.Should().Be(recordsExpected);

```

How do I configure FluentAssertions to ignore my dbScripts projects?


Regards,
Angel L. Bermudez, Jr.


Edited Unassigned: Unit Testing with a DbScripts Project [12497]

$
0
0
I am using VS2013

I have added a UnitTest project that executes the following assertions: (Succesfull)
```
Assert.IsNotNull(drivers);
Assert.AreEqual(recordsExpected, drivers.Count);
```

When I add the FluentAssertions and replace my assertions: (fails because it tries to debug my dbScripts Project) See attached image.
```
drivers.Should().NotBeNull();
drivers.Count.Should().Be(recordsExpected);

```

How do I configure FluentAssertions to ignore my dbScripts projects?


Regards,
Angel L. Bermudez, Jr.

New Post: Bug: Optional parameters in .NET 3.5 build

$
0
0
I have the same problem, I have to type in blank strings for every assert. I have Visual Studio 201X but I also have to use Visual Studio 2008 because I'm testing a library for the Compact Framework. Switching to VS2010 or later is not possible for that project.

While I understand that I'm an oddity, providing overloads would not necessarily be difficult. I don't really expect that you'll add them just because some people have to use VS2008, I just wanted to point out that some people cannot switch to VS201X just to use optional parameters.

New Post: Bug: Optional parameters in .NET 3.5 build

New Post: Test XElement child node

$
0
0
Hi, say we have a xml file "Book.xml".
<?xml version="1.0"?>
<catalog>
   <book id="bk101">
      <author>Gambardella, Matthew</author>
      <title>XML Developer's Guide</title>
      <genre>Computer</genre>
      <price>44.95</price>
      <publish_date>2000-10-01</publish_date>
      <description>An in-depth look at creating applications 
      with XML.</description>
   </book>
   <book id="bk102">
      <author>Ralls, Kim</author>
      <title>Midnight Rain</title>
      <genre>Fantasy</genre>
      <price>5.95</price>
      <publish_date>2000-12-16</publish_date>
      <description>A former architect battles corporate zombies, 
      an evil sorceress, and her own childhood to become queen 
      of the world.</description>
   </book>
</catalog>
Now I want to test the child attribute, how ?
        public XElement CheckBook()
        {
            XElement doc = XElement.Load(@"C:\Book.xml");
            return doc;
        }
In my xml unit testing code, we have
[TestMethod]
    public void TestBookXMLMethod()
    {
        BookXMLCheck bc = new BookXMLCheck();
        bc.CheckBook().Should().HaveAttribute("id","bk101")
            .And.HaveAttribute("id","bk102")
            .And.HaveElement("price")
            .And.HaveValue("44.95");
    }
Thank you

Created Unassigned: uint does not contain a definition for 'ShouldBeEquivalentTo' [12498]

$
0
0
In a .NET 3.5 solution, if you write something simple like the following:

```
uint test = uint.MaxValue;
test.ShouldBeEquivalentTo(uint.MaxValue);
```

Then you will get the following compilation error using FluentAssertions NuGet package version 3.0.107:

__Error 1 'uint' does not contain a definition for 'ShouldBeEquivalentTo' and no extension method 'ShouldBeEquivalentTo' accepting a first argument of type 'uint' could be found (are you missing a using directive or an assembly reference?)__

This also applies to ushort and ulong, but primitives such as; byte, sbyte, short, int and long, are all OK.
Viewing all 1402 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>