Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Add ShouldBeLike #103

Closed
lanwin opened this Issue · 8 comments

3 participants

@lanwin

Simple example

foo.ShouldBeLike(new{
Id=123,
Name="foobar"
});

This does not use Equals for check. Instead it checks each property with reflection. This way its very easy to check multiple properties of an object without having an instance of that object before and without having to impl Equals for each object.

@rho24

rho24@49e4858

I've had a go at an implementation. Couldn't figure out how to link to the commit properly so any tips would be handy!

@lanwin

Nice! Ive totally overlooked your comment.

I have build some prototype code to make a comparison of a complete object graph instead of only the local properties.

https://gist.github.com/2841822

What do you think?

@rho24

Looks good, i'll try and get round to merging it with my bits this weekend. Or if you want feel free to fork my branch and do it yourself.
Looking at this i'm wondering if it would be useful to test multiple depths e.g.
new{
Id=123,
Name="Bob",
Address = new{
Line1 = "123 Fake Street",
Country = "UK"
}
}

But maybe that's over complicating things...

@lanwin

Hmm I dont think it will be over complicated and I want it exactly for this scenarios like this.

@rho24

Updated implementation which now checks fields, arrays, and nested objects.
rho24@aadce82

@lanwin

Interesting. Did you send it as pull request?

@rho24 rho24 referenced this issue from a commit in rho24/machine.specifications
@rho24 rho24 Merge branch 'master' into ShouldBeLike
Implements issue #103
c988f51
@rho24 rho24 referenced this issue
Closed

Should be like #108

@rho24

Pull request attached. Any feedback welcome!

@agross
Owner

See #108

@agross agross closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.