Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 06:57
    jnyrup commented #1719
  • 06:38
    dennisdoomen commented #1719
  • Oct 22 20:10
    jnyrup commented #1719
  • Oct 22 20:09
    jnyrup commented #1708
  • Oct 22 12:21
    dennisdoomen opened #1719
  • Oct 22 07:28
    FFranz93 commented #1716
  • Oct 22 07:24
    FFranz93 commented #1716
  • Oct 22 05:22
    dennisdoomen commented #1716
  • Oct 22 02:38
    lonix1 commented #1716
  • Oct 21 19:18
    jnyrup commented #1718
  • Oct 21 19:05
    jnyrup commented #1716
  • Oct 21 18:36
    jnyrup labeled #1718
  • Oct 21 18:03
    dswisher opened #1718
  • Oct 21 07:44
    dennisdoomen commented #1716
  • Oct 21 07:03
    dennisdoomen commented #1708
  • Oct 21 07:03
    dennisdoomen commented #1708
  • Oct 21 06:26
    jnyrup commented #535
  • Oct 21 06:23
    jnyrup closed #845
  • Oct 21 06:23
    jnyrup commented #845
  • Oct 21 06:17
    dennisdoomen commented #845
Dennis Doomen
@ddoomen_twitter
@somewhatabstract You're using R# to run the unit tests
Anders Abel
@AndersAbel
Good, I'll look into that. (It's a bit embarassing, but I'm actually listed as a contributor to that file so I should know about it...)
Dennis Doomen
@dennisdoomen
Don't worry. These days, for every question on Twitter, Gitter and StackOverflow, I have to look up the code to answer. There's so much in it these days.
Jeff Yates
@somewhatabstract
I admit getting lost in the equivalency stuff
@ddoomen_twitter Yes, I am using R#. Is that the issue? I would not be surprised.
Dennis Doomen
@dennisdoomen
What can I do to help?
Jeff Yates
@somewhatabstract
I am not sure. I'm going to take another look tonight. Perhaps I will cut a PR for you to look at. If you can take a look at running the tests yourself or at least looking over the changes, you might see something I am missing
If you have time to do so, of course
(don't want to be volunteering your time; have enough trouble managing my own!)
Dennis Doomen
@dennisdoomen
I can try. Didn't bring my developer laptop to the US, so I might be missing some SDK.
Jeff Yates
@somewhatabstract
I am sure it can wait, if necessary. I took a break from it as I was getting frustrated. :D
I might see the issue myself tonight. I'm going to try running the tests outside of R# and see if that at least works
I hope you're enjoying your trip over here
I was mentally back in Europe this morning as I watched England and Wales
Liashenko Vladymyr
@LVladymyr
hi guys.
I've move fluentassertion to dotnetstandard but it looks like a sh.t. It`s no way to use dotnet core project with "shared" project together.
and this dotnet core compiler work not very well with define variables (or it is only in my environment)
if you have interest to prove it, you can find it here https://github.com/LVladymyr/FluentAssertions
Dennis Doomen
@ddoomen_twitter
@LVladymyr I'm not sure I understand what you're trying to say.
Liashenko Vladymyr
@LVladymyr
Sorry for my english.
I try to adaptate fluentassertion work with dotnet core, but my implemetation is not good enough.
New xproj can not work with "shared project"
Marcel Körtgen
@mkoertgen
Hi @dennisdoomen, i just created a PR that should resolve the json issues. Please have a look
Pavel Vostretsov
@fakefeik

Hi
I wanted to use FluentAssertions for object comparison with some properties left out. I have TMessage actual, TMessage expected, Expression<Func<TMessage, object>>[] leftOutProperties.
I've written such code:

actualMessage.ShouldBeEquivalentTo(expectedMessage, o => 
{
    foreach(var expression in leftOutProperties)
        o.Excluding(expression);
    return o;
});

and it works like a charm. But there is a problem: instead of an exception, I want to get List<ComparisonResult> from this method, where ComparisonResult contains object Expected, object Actual and Expression PathToProperty. Is there any simple way I could accomplish this? I've read documentation and I couldn't find one.

Dennis Doomen
@dennisdoomen
@fakefeik what do you mean with these comparison results? To evaluate the differences?
Pavel Vostretsov
@fakefeik

I mean that now I use it like this:

public string Compare<TMessage>(TMessage expectedMessage, TMessage actualMessage)
{
    try
    {
        actualMessage.ShouldBeEquivalentTo(expectedMessage, o =>
        {
            foreach (var expression in leftOutProperties)
                o.Excluding(expression);
            return o;
        });
        return null;
    }
    catch (AssertionException e)
    {
        return e.Message;
    }
}

What I want to be able to do is get rid of the try and return not a string, but some list of comparison results for pretty-printing it later, like this

public IEnumerable<ComparisonResult> Compare<TMessage>(TMessage expectedMessage, TMessage actualMessage)
{
    return actualMessage.ShouldBeEquivalentTo(expectedMessage, o =>
    {
        foreach (var expression in anyValuePaths)
            o.Excluding(expression);
        return o;
    });
}
I've looked through the code and it seems the easiest way is to write an extension method that would behave similar to ShouldBeEquivalentTo, but would use different AssertionStrategy
Although it seems to be quite difficult because there is no public constructor that takes AssertionStrategy as a parameter
Pavel Vostretsov
@fakefeik
Perhaps, there's something I'm missing?
Dennis Doomen
@dennisdoomen
No, not out of the box. What that requires is that the [AssertionScope] (https://github.com/dennisdoomen/FluentAssertions/blob/master/Src/Core/Execution/AssertionScope.cs) constructor supports an ambient assertion scope. I would welcome a PR ;-)
Pavel Vostretsov
@fakefeik
I don't quite get it what is an ambient assertion scope
though I think it is enough to make Dispose() virtual and assertionStrategy and contextData protected in AssertionScope
So I could create my own MyAssertionScope that inherits AssertionScope, override Dispose() and use it
Dennis Doomen
@dennisdoomen
The AssertionScope class uses a thread-static field to track the currently executing assertion to collect and throw them as one assertion exception. By creating an instance of that class, it assigns a new CollectingAssertionStrategy to that field. So we have two options to accomplish what you're asking for:
  1. Allow multiple assertion scopes on the current thread to share the collection strategy, but this would require some kind of reference counting
  2. Extend the ShouldBeEquivalentTo API to allow you to pass an alternative impleemntating of the IAssertionStrategy.
Dennis Doomen
@ddoomen_twitter
@onovotny @smudge202 I'm planning the work for Fluent Assertions 5.0. Any thoughts should go dennisdoomen/FluentAssertions#463
Saro Taşciyan
@SaroTasciyan
Heya Dennis, I was planning to take some time on up for grab issues on the following weeks. If you think there is anything I can help you with v5 please let me know
Dennis Doomen
@dennisdoomen
@SaroTasciyan don't let my plans for v5 hold you back. I won't be starting this before the end of September anyway. So if you find the time to pick up any of the up-for-grabs items, that would be awesome.
Saro Taşciyan
@SaroTasciyan
Good morning Dennis, it's great that we have plenty of time to improve stuff before the major release. Just wanted to let you know I would love to get involved in v5 as well ;)
Dennis Doomen
@dennisdoomen
Sure. By the time I'm going to start with that, I'll probably create a task list in the issue and a branch on the repo.
cmellongoempyrean
@cmellongoempyrean
As far as I can tell ExcludeNestedObjects() just plain doesn't work, am I crazy?
cmellongoempyrean
@cmellongoempyrean
cmellongoempyrean
@cmellongoempyrean
amusingly, dotnetfiddle is failing to escape things properly and FluentAssertions NuGet description breaks loading from an external link. https://gist.github.com/cmellongoempyrean/bdb3c63a3755d7f27c0751919cbc93ea
Dennis Doomen
@ddoomen_twitter
@cmellongoempyrean the truth is somewhere in the middle. The only thing ExcludingNestedObjects does it to prevent traversing into your Nested property. It will still try to compare the property values as-is. And since they are not the same objects, it'll report a difference
If you just want to exclude the property, use Excluding(x => x.Nested)
cmellongoempyrean
@cmellongoempyrean
that seems deceptively named then :\
Dennis Doomen
@ddoomen_twitter
Agreed.
Christian Palmstierna
@cpx86
Question: has the idea of support for soft assertions in FluentAssertions come up before?
Dennis Doomen
@dennisdoomen
soft assertions?? Please elaborate
Christian Palmstierna
@cpx86
It's when you have multiple assertions and if one fails, the rest are still evaluated.
I know some people argue that a test should always have just a single assertion but I'd argue that isn't always feasible, e.g. when writing integration tests.
Saro Taşciyan
@SaroTasciyan
Added IsAssignableFrom to RelectionExtensions, quite confused tho. @dennisdoomen looking forward for your review (:
Dennis Doomen
@ddoomen_twitter
@cpx You can achieve the same with the AssertionScope. See the EquivalencyValidator class or the AssertionScopeSpecs for examples