<?xml version="1.0"?><?xml-stylesheet type="text/xsl" href="/rss.xsl"?><rss version="2.0"><channel><title>fluentassertions Discussions Rss Feed</title><link>http://fluentassertions.codeplex.com/Thread/List.aspx</link><description>fluentassertions Discussions Rss Description</description><item><title>New Post: Comparing object equivalence for dictionaries</title><link>http://fluentassertions.codeplex.com/discussions/443111</link><description>&lt;div style="line-height: normal;"&gt;Hi Sarah,&lt;br /&gt;
&lt;br /&gt;
Version 2.0 doesn't even really support dictionaries. It just compares the value pairs in order of appearance. In the upcoming version 2.1, I've added logic that tries to match the values with the same keys. However, what you ask is a bit more special. I don't think it should be core functionality, but in 2.1, you can add your own equivalency step that would do just that. &lt;br /&gt;
&lt;/div&gt;</description><author>dennisdoomen</author><pubDate>Fri, 10 May 2013 19:18:18 GMT</pubDate><guid isPermaLink="false">New Post: Comparing object equivalence for dictionaries 20130510071818P</guid></item><item><title>New Post: Comparing object equivalence for dictionaries</title><link>http://fluentassertions.codeplex.com/discussions/443111</link><description>&lt;div style="line-height: normal;"&gt;I've been using ShouldBeEquivalentTo() to compare 2 dictionaries, which works fine.&lt;br /&gt;
&lt;br /&gt;
What I want to be do is check that the keys are the same, while the values can be within a range (say within 1 %) through the assertion options.  Is this possible?&lt;br /&gt;
&lt;br /&gt;
At the moment I'm doing the following (both dictionaries are sorted by key):&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;foreach (var o in actual)
{
    expectedValues.Should().ContainKey(o.Key);
    o.Value.Should().BeInRange(oo.Value*0.99, oo.Value*1.01);
}&lt;/code&gt;&lt;/pre&gt;

Which works but doesn't look very elegant...&lt;br /&gt;
&lt;/div&gt;</description><author>sarah99</author><pubDate>Thu, 09 May 2013 13:00:38 GMT</pubDate><guid isPermaLink="false">New Post: Comparing object equivalence for dictionaries 20130509010038P</guid></item><item><title>New Post: Support for C# Dynamics</title><link>http://fluentassertions.codeplex.com/discussions/325863</link><description>&lt;div style="line-height: normal;"&gt;You could try delcaring your test item as an object, that worked for me :) e.g. ((object)queryResult.Single().Value2).Should().NotBeNull&lt;br /&gt;
&lt;/div&gt;</description><author>sarah99</author><pubDate>Wed, 01 May 2013 08:43:15 GMT</pubDate><guid isPermaLink="false">New Post: Support for C# Dynamics 20130501084315A</guid></item><item><title>New Post: Bug: Optional parameters in .NET 3.5 build</title><link>http://fluentassertions.codeplex.com/discussions/441301</link><description>&lt;div style="line-height: normal;"&gt;Actually, you need Visual Studio 2010. Named and optional arguments is just syntactical sugar provided by the compiler and has nothing to do with the .NET Framework version.&lt;br /&gt;
&lt;/div&gt;</description><author>dennisdoomen</author><pubDate>Tue, 23 Apr 2013 14:52:15 GMT</pubDate><guid isPermaLink="false">New Post: Bug: Optional parameters in .NET 3.5 build 20130423025215P</guid></item><item><title>New Post: Bug: Optional parameters in .NET 3.5 build</title><link>http://fluentassertions.codeplex.com/discussions/441301</link><description>&lt;div style="line-height: normal;"&gt;Hi,&lt;br /&gt;
&lt;br /&gt;
I'm working on a project that has target framework of .NET 3.5 and recently imported Fluent Assertions for that specific version.  It seems that this build version uses optional parameters that are not supported in earlier versions of .NET than 4.0 I think this should be changed to overloads instead.&lt;br /&gt;
&lt;br /&gt;
Anyone else that have been addressing this problem?&lt;br /&gt;
&lt;br /&gt;
Regards&lt;br /&gt;
Niklas&lt;br /&gt;
&lt;/div&gt;</description><author>nengberg</author><pubDate>Tue, 23 Apr 2013 14:44:42 GMT</pubDate><guid isPermaLink="false">New Post: Bug: Optional parameters in .NET 3.5 build 20130423024442P</guid></item><item><title>New Post: Adding a method to measure how many times some text repeats within a string</title><link>http://fluentassertions.codeplex.com/discussions/439782</link><description>&lt;div style="line-height: normal;"&gt;Well, overloading Contains seems like one way to do that or adding a new method such as Find? &lt;br /&gt;
&lt;br /&gt;
int times = 3;&lt;br /&gt;
string text = &amp;quot;textX textY textZ&amp;quot;;&lt;br /&gt;
text.Should().Find(&amp;quot;text&amp;quot;, times);&lt;br /&gt;
&lt;br /&gt;
In addition, I think that it would be a good idea to include an overload that supports StringComparison.&lt;br /&gt;
&lt;/div&gt;</description><author>EyalShilony</author><pubDate>Wed, 10 Apr 2013 15:01:18 GMT</pubDate><guid isPermaLink="false">New Post: Adding a method to measure how many times some text repeats within a string 20130410030118P</guid></item><item><title>New Post: Adding a method to measure how many times some text repeats within a string</title><link>http://fluentassertions.codeplex.com/discussions/439782</link><description>&lt;div style="line-height: normal;"&gt;Thanks for the suggestion.&lt;br /&gt;
&lt;br /&gt;
Could you provide us with the suggested syntax?&lt;br /&gt;
&lt;/div&gt;</description><author>dennisdoomen</author><pubDate>Wed, 10 Apr 2013 13:51:02 GMT</pubDate><guid isPermaLink="false">New Post: Adding a method to measure how many times some text repeats within a string 20130410015102P</guid></item><item><title>New Post: Adding a method to measure how many times some text repeats within a string</title><link>http://fluentassertions.codeplex.com/discussions/439782</link><description>&lt;div style="line-height: normal;"&gt;Hello,&lt;br /&gt;
&lt;br /&gt;
I want to measure how many times some text repeats within a string so I'd really love to have additional method that does that.&lt;br /&gt;
&lt;br /&gt;
Here is an example.&lt;br /&gt;
&lt;br /&gt;
int times  = 1;&lt;br /&gt;
string text = &amp;quot;Some text that should not contain repetitions&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
text.Should().Contains(&amp;quot;text&amp;quot;, times);&lt;br /&gt;
&lt;br /&gt;
Thank you for your hard work.&lt;br /&gt;
&lt;/div&gt;</description><author>EyalShilony</author><pubDate>Wed, 10 Apr 2013 13:36:15 GMT</pubDate><guid isPermaLink="false">New Post: Adding a method to measure how many times some text repeats within a string 20130410013615P</guid></item><item><title>New Post: Exception in Excluding from nested property.</title><link>http://fluentassertions.codeplex.com/discussions/438042</link><description>&lt;div style="line-height: normal;"&gt;&lt;strong&gt;dennisdoomen wrote:&lt;/strong&gt;&lt;br /&gt;
&lt;blockquote&gt;
Then you need the other overload and use the string-representation of the PropertyPath property on ISubjectInfo.&lt;br /&gt;
&lt;/blockquote&gt;
You can a sample please?&lt;br /&gt;
Thanks.&lt;br /&gt;
&lt;/div&gt;</description><author>d3nver</author><pubDate>Wed, 27 Mar 2013 11:12:26 GMT</pubDate><guid isPermaLink="false">New Post: Exception in Excluding from nested property. 20130327111226A</guid></item><item><title>New Post: Exception in Excluding from nested property.</title><link>http://fluentassertions.codeplex.com/discussions/438042</link><description>&lt;div style="line-height: normal;"&gt;Then you need the other overload and use the string-representation of the PropertyPath property on ISubjectInfo.&lt;br /&gt;
&lt;/div&gt;</description><author>dennisdoomen</author><pubDate>Wed, 27 Mar 2013 10:34:06 GMT</pubDate><guid isPermaLink="false">New Post: Exception in Excluding from nested property. 20130327103406A</guid></item><item><title>New Post: Exception in Excluding from nested property.</title><link>http://fluentassertions.codeplex.com/discussions/438042</link><description>&lt;div style="line-height: normal;"&gt;&lt;strong&gt;dennisdoomen wrote:&lt;/strong&gt;&lt;br /&gt;
&lt;blockquote&gt;
I think using an Expression with an indexer only works if the collection is an array. You should use the overload that takes a Func&amp;lt;ISubjectInfo, bool&amp;gt;() to compare the property path against &amp;quot;Products[0].Status&amp;quot;.&lt;br /&gt;
&lt;/blockquote&gt;
Big Thanks!!!&lt;br /&gt;
&lt;br /&gt;
Yes&lt;br /&gt;
I wrote:&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;public class Order
    {
        public Int32 Id { get; set; }
        public Product[] Products { get; set; }
    }

~~~~~~~
[Test]
~~~
order2.ShouldBeEquivalentTo(order1, options =&amp;gt; options.Excluding(o =&amp;gt; o.Products[0].Status).Excluding(o =&amp;gt; o.Products[1].Status));&lt;/code&gt;&lt;/pre&gt;

And test is success.&lt;br /&gt;
With List&amp;lt;Product&amp;gt; don't working :( May can used List&amp;lt;T&amp;gt; ?&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;private List&amp;lt;Product&amp;gt; _product;
public Product[] Products 
{
   get{ return _product.ToArray(); }
}&lt;/code&gt;&lt;/pre&gt;

is bad option.&lt;br /&gt;
&lt;br /&gt;
And second question:&lt;br /&gt;
How can exclude property Status from class Product for all elements of array?&lt;br /&gt;
Thanks.&lt;br /&gt;
&lt;/div&gt;</description><author>d3nver</author><pubDate>Wed, 27 Mar 2013 09:14:26 GMT</pubDate><guid isPermaLink="false">New Post: Exception in Excluding from nested property. 20130327091426A</guid></item><item><title>New Post: Exception in Excluding from nested property.</title><link>http://fluentassertions.codeplex.com/discussions/438042</link><description>&lt;div style="line-height: normal;"&gt;I think using an Expression with an indexer only works if the collection is an array. You should use the overload that takes a Func&amp;lt;ISubjectInfo, bool&amp;gt;() to compare the property path against &amp;quot;Products[0].Status&amp;quot;.&lt;br /&gt;
&lt;/div&gt;</description><author>dennisdoomen</author><pubDate>Tue, 26 Mar 2013 19:53:11 GMT</pubDate><guid isPermaLink="false">New Post: Exception in Excluding from nested property. 20130326075311P</guid></item><item><title>New Post: Exception in Excluding from nested property.</title><link>http://fluentassertions.codeplex.com/discussions/438042</link><description>&lt;div style="line-height: normal;"&gt;hi&lt;br /&gt;
I tried exclude from test one property how writing in Docs:&lt;br /&gt;
&lt;blockquote&gt;
orderDto.ShouldBeEquivalentTo(order, options =&amp;gt; options.Excluding(o =&amp;gt; o.Products[1].Status)); &lt;br /&gt;
&lt;/blockquote&gt;
My classes:&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;public class Product
    {
        public String name { get; set; }
        public Int32 Status { get; set; }
    }
public class Order
    {
        public Int32 Id { get; set; }
        public List&amp;lt;Product&amp;gt; Products { get; set; }
    }&lt;/code&gt;&lt;/pre&gt;

My test:&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;[Test]
        public void test()
        {
            Order order1 = new Order();
            order1.Products = new List&amp;lt;Product&amp;gt;();
            order1.Products.Add(new Product());
            order1.Products.Add(new Product());

            Order order2 = new Order();
            order2.Products = new List&amp;lt;Product&amp;gt;();
            order2.Products.Add(new Product());
            order2.Products.Add(new Product());

            order2.ShouldBeEquivalentTo(order1, options =&amp;gt;options.Excluding(o =&amp;gt; o.Products[0].Status)); 
        }&lt;/code&gt;&lt;/pre&gt;

But Test Failed with:&lt;br /&gt;
System.ArgumentException : Expression {Convert(o.Products.get_Item(0).Status)} is not a valid property expression&lt;br /&gt;
if i write:&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;order2.ShouldBeEquivalentTo(order1, options =&amp;gt;options.Excluding(o =&amp;gt; o.Products[0]));&lt;/code&gt;&lt;/pre&gt;

Test failed with:&lt;br /&gt;
System.ArgumentException : Expression {o.Products.get_Item(0)} is not a valid property expression&lt;br /&gt;
&lt;br /&gt;
When i write:&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;order2.ShouldBeEquivalentTo(order1, options =&amp;gt;options.Excluding(o =&amp;gt; o.Products));&lt;/code&gt;&lt;/pre&gt;

Test is success.&lt;br /&gt;
&lt;br /&gt;
What am I doing wrong?&lt;br /&gt;
Thanks.&lt;br /&gt;
&lt;/div&gt;</description><author>d3nver</author><pubDate>Tue, 26 Mar 2013 15:48:33 GMT</pubDate><guid isPermaLink="false">New Post: Exception in Excluding from nested property. 20130326034833P</guid></item><item><title>New Post: Why so many negation methods? </title><link>http://fluentassertions.codeplex.com/discussions/391928</link><description>&lt;div style="line-height: normal;"&gt;Yeah you can either do it.Should().Not().BeWhatever() or it.ShouldNot().BeWhatever(), obviously there are few options here but instead of introducing a breaking change, I'd imagine you can create the functionality without breaking anything and let people the time they need to adapt it.&lt;br /&gt;
&lt;br /&gt;
Well, it might not save you time but it will streamline the APIs and make it easier to work with because ShouldNot() (or Should().Not()) and Should() will look exactly the same and it may simplify a thing or two in the design itself.&lt;br /&gt;
&lt;/div&gt;</description><author>EyalShilony</author><pubDate>Sun, 24 Mar 2013 05:24:05 GMT</pubDate><guid isPermaLink="false">New Post: Why so many negation methods?  20130324052405A</guid></item><item><title>New Post: Mappings in object graph comparisons</title><link>http://fluentassertions.codeplex.com/discussions/407183</link><description>&lt;div style="line-height: normal;"&gt;Cool!&lt;br /&gt;
&lt;/div&gt;</description><author>dennisdoomen</author><pubDate>Fri, 15 Mar 2013 14:24:00 GMT</pubDate><guid isPermaLink="false">New Post: Mappings in object graph comparisons 20130315022400P</guid></item><item><title>New Post: Mappings in object graph comparisons</title><link>http://fluentassertions.codeplex.com/discussions/407183</link><description>&lt;div style="line-height: normal;"&gt;Hi&lt;br /&gt;
&lt;br /&gt;
I have written an extension for property mapping that can be used like this:&lt;br /&gt;
&lt;div style="color:Black;background-color:White;"&gt;&lt;pre&gt;
result.ShouldBeEquivalentTo(expected, opt =&amp;gt; opt.Mapping&amp;lt;YType&amp;gt;(x =&amp;gt; x.Foo, y =&amp;gt; y.Bar));
&lt;/pre&gt;&lt;/div&gt;&lt;div style="color:Black;background-color:White;"&gt;&lt;pre&gt;
    &lt;span style="color:Blue;"&gt;public&lt;/span&gt; &lt;span style="color:Blue;"&gt;class&lt;/span&gt; EquivalencyAssertionOptions&amp;lt;TSubject&amp;gt;
    {
        &lt;span style="color:Blue;"&gt;public&lt;/span&gt; EquivalencyAssertionOptions&amp;lt;TSubject&amp;gt; Mapping&amp;lt;TMatch&amp;gt;(
            Expression&amp;lt;Func&amp;lt;TSubject, &lt;span style="color:Blue;"&gt;object&lt;/span&gt;&amp;gt;&amp;gt; propertyFromExpression, Expression&amp;lt;Func&amp;lt;TMatch, &lt;span style="color:Blue;"&gt;object&lt;/span&gt;&amp;gt;&amp;gt; propertyToExpression)
        {
            &lt;span style="color:Blue;"&gt;this&lt;/span&gt;.Using(&lt;span style="color:Blue;"&gt;new&lt;/span&gt; MatchByMappingRule(ExpressionExtensions.GetPropertyPath(propertyFromExpression), ExpressionExtensions.GetPropertyPath(propertyToExpression)));
            &lt;span style="color:Blue;"&gt;return&lt;/span&gt; &lt;span style="color:Blue;"&gt;this&lt;/span&gt;;
        }
    }
    
    &lt;span style="color:Blue;"&gt;public&lt;/span&gt; &lt;span style="color:Blue;"&gt;class&lt;/span&gt; MatchByMappingRule : IMatchingRule
    {
        &lt;span style="color:Blue;"&gt;private&lt;/span&gt; &lt;span style="color:Blue;"&gt;readonly&lt;/span&gt; &lt;span style="color:Blue;"&gt;string&lt;/span&gt; _propertyPathSubject;

        &lt;span style="color:Blue;"&gt;private&lt;/span&gt; &lt;span style="color:Blue;"&gt;readonly&lt;/span&gt; &lt;span style="color:Blue;"&gt;string&lt;/span&gt; _propertyPathExpectation;

        &lt;span style="color:Blue;"&gt;public&lt;/span&gt; MatchByMappingRule(&lt;span style="color:Blue;"&gt;string&lt;/span&gt; propertyPathSubject, &lt;span style="color:Blue;"&gt;string&lt;/span&gt; propertyPathExpectation)
        {
            _propertyPathSubject = propertyPathSubject;
            _propertyPathExpectation = propertyPathExpectation;
        }

        &lt;span style="color:Blue;"&gt;public&lt;/span&gt; PropertyInfo Match(PropertyInfo subjectProperty, &lt;span style="color:Blue;"&gt;object&lt;/span&gt; expectation, &lt;span style="color:Blue;"&gt;string&lt;/span&gt; propertyPath)
        {
            &lt;span style="color:Blue;"&gt;if&lt;/span&gt; (subjectProperty.Name.Equals(_propertyPathSubject))
            {
                &lt;span style="color:Blue;"&gt;return&lt;/span&gt; expectation.GetType().GetProperty(_propertyPathExpectation);
            }

            &lt;span style="color:Blue;"&gt;return&lt;/span&gt; &lt;span style="color:Blue;"&gt;null&lt;/span&gt;;
        }

        &lt;span style="color:Blue;"&gt;public&lt;/span&gt; &lt;span style="color:Blue;"&gt;override&lt;/span&gt; &lt;span style="color:Blue;"&gt;string&lt;/span&gt; ToString()
        {
            &lt;span style="color:Blue;"&gt;return&lt;/span&gt; &lt;span style="color:Blue;"&gt;string&lt;/span&gt;.Format(&lt;span style="color:#A31515;"&gt;&amp;quot;Mapping property {0} to {1}&amp;quot;&lt;/span&gt;, _propertyPathSubject, _propertyPathExpectation);
        }
    }
&lt;/pre&gt;&lt;/div&gt;But I like the proposed syntax more :)&lt;br /&gt;
.Where(dto =&amp;gt; dto.Product.ManufacturerName).ShouldMapTo(o =&amp;gt; o.Product.Manufacturer.Name)&lt;br /&gt;
&lt;/div&gt;</description><author>reitzmichnicht</author><pubDate>Fri, 15 Mar 2013 14:21:13 GMT</pubDate><guid isPermaLink="false">New Post: Mappings in object graph comparisons 20130315022113P</guid></item><item><title>New Post: Why does Should().ContainSingle() accept predicate mandatory</title><link>http://fluentassertions.codeplex.com/discussions/436413</link><description>&lt;div style="line-height: normal;"&gt;I'm not sure. We started with the idea of chaining. But since then we've run in so many compiler limitations that we're not sure anymore if the entire .And. construct is still useful.&lt;br /&gt;
&lt;/div&gt;</description><author>dennisdoomen</author><pubDate>Wed, 13 Mar 2013 19:33:41 GMT</pubDate><guid isPermaLink="false">New Post: Why does Should().ContainSingle() accept predicate mandatory 20130313073341P</guid></item><item><title>New Post: Why does Should().ContainSingle() accept predicate mandatory</title><link>http://fluentassertions.codeplex.com/discussions/436413</link><description>&lt;div style="line-height: normal;"&gt;Would you agree to add an overload to mimic LINQ behavior?&lt;br /&gt;
&lt;br /&gt;
And don't you have any plans in addition to&lt;code&gt;And&lt;/code&gt; add something like &lt;code&gt;AndSubject&lt;/code&gt; to switch from original target under assertion to underlying/new? Like in my 2nd question.&lt;br /&gt;
&lt;br /&gt;
Thanks.&lt;br /&gt;
&lt;/div&gt;</description><author>abatishchev</author><pubDate>Wed, 13 Mar 2013 19:31:10 GMT</pubDate><guid isPermaLink="false">New Post: Why does Should().ContainSingle() accept predicate mandatory 20130313073110P</guid></item><item><title>New Post: Why doesn't NotBeSameAs() work with GenericCollectionAssertions?</title><link>http://fluentassertions.codeplex.com/discussions/436477</link><description>&lt;div style="line-height: normal;"&gt;Ah, I understand now. Since your subject-under-test is an IEnumerable&amp;lt;T&amp;gt;, it will use the GenericCollectionAssertions rather than the ObjectAssertions. And that is missing the (Not)BeSameAs(). You can work around that by casting your collection object first. &lt;br /&gt;
&lt;/div&gt;</description><author>dennisdoomen</author><pubDate>Wed, 13 Mar 2013 18:50:00 GMT</pubDate><guid isPermaLink="false">New Post: Why doesn't NotBeSameAs() work with GenericCollectionAssertions? 20130313065000P</guid></item><item><title>New Post: Why does Should().ContainSingle() accept predicate mandatory</title><link>http://fluentassertions.codeplex.com/discussions/436413</link><description>&lt;div style="line-height: normal;"&gt;Regarding your first question, you're correct. HaveCount() is the only option right now. &lt;br /&gt;
&lt;br /&gt;
Regarding your 2nd question, that's by design. Chaining essentially applies to the original type of the subject.&lt;br /&gt;
&lt;/div&gt;</description><author>dennisdoomen</author><pubDate>Wed, 13 Mar 2013 18:45:30 GMT</pubDate><guid isPermaLink="false">New Post: Why does Should().ContainSingle() accept predicate mandatory 20130313064530P</guid></item></channel></rss>