Read this blog post for all the details
↧
Updated Release: Release 2.0.0 (Oct 07, 2012)
↧
Released: Release 2.0.0 (Oct 07, 2012)
Read
this blog post for all the details
↧
↧
Edited Issue: Issue with normal Should Be call [12478]
Hi
I receive an exception when i make a call like this:
```
etuResponse.Header.RspCode.Should().Be(0);
```
Thats all. I am doing nothing else.
RspCode has the value 234.
I am using MSTest, Visual Studio 2012, .Net 4.5
FluentAssertion Version: 2.0.0.0
```
System.NotSupportedException occurred
HResult=-2146233067
Message=The invoked member is not supported in a dynamic assembly.
Source=mscorlib
StackTrace:
at System.Reflection.Emit.InternalAssemblyBuilder.GetExportedTypes()
at FluentAssertions.Formatting.AttributeBasedFormatter.GetExportedTypes(Assembly assembly) in c:\Workspaces\codeplex\fluentassertions\Main\FluentAssertions.Net35\Formatting\AttributeBasedFormatter.cs:line 126
InnerException:
```
I receive an exception when i make a call like this:
```
etuResponse.Header.RspCode.Should().Be(0);
```
Thats all. I am doing nothing else.
RspCode has the value 234.
I am using MSTest, Visual Studio 2012, .Net 4.5
FluentAssertion Version: 2.0.0.0
```
System.NotSupportedException occurred
HResult=-2146233067
Message=The invoked member is not supported in a dynamic assembly.
Source=mscorlib
StackTrace:
at System.Reflection.Emit.InternalAssemblyBuilder.GetExportedTypes()
at FluentAssertions.Formatting.AttributeBasedFormatter.GetExportedTypes(Assembly assembly) in c:\Workspaces\codeplex\fluentassertions\Main\FluentAssertions.Net35\Formatting\AttributeBasedFormatter.cs:line 126
InnerException:
```
↧
Edited Issue: System.IO.FileLoadException in AttributeBasedFormatter.AllTypes [12476]
I don't know how to reproduce this in simple project, but I am getting this exception on a test project that uses StackExchange's MiniProfiler
```
Test(s) failed. System.IO.FileLoadException : Could not load file or assembly 'System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
at System.Reflection.RuntimeAssembly.GetExportedTypes(RuntimeAssembly assembly, ObjectHandleOnStack retTypes)
at System.Reflection.RuntimeAssembly.GetExportedTypes()
at FluentAssertions.Formatting.AttributeBasedFormatter.GetExportedTypes(Assembly assembly) in c:\Workspaces\codeplex\fluentassertions\Main\FluentAssertions.Net35\Formatting\AttributeBasedFormatter.cs:line 126
at System.Linq.Enumerable.<SelectManyIterator>d__14`2.MoveNext()
at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
at FluentAssertions.Formatting.AttributeBasedFormatter.get_AllTypes() in c:\Workspaces\codeplex\fluentassertions\Main\FluentAssertions.Net35\Formatting\AttributeBasedFormatter.cs:line 119
at FluentAssertions.Formatting.AttributeBasedFormatter.FindCustomFormatters() in c:\Workspaces\codeplex\fluentassertions\Main\FluentAssertions.Net35\Formatting\AttributeBasedFormatter.cs:line 63
at FluentAssertions.Formatting.AttributeBasedFormatter.get_Formatters() in c:\Workspaces\codeplex\fluentassertions\Main\FluentAssertions.Net35\Formatting\AttributeBasedFormatter.cs:line 58
at FluentAssertions.Formatting.AttributeBasedFormatter.GetFormatter(Object value) in c:\Workspaces\codeplex\fluentassertions\Main\FluentAssertions.Net35\Formatting\AttributeBasedFormatter.cs:line 0
at FluentAssertions.Formatting.AttributeBasedFormatter.CanHandle(Object value) in c:\Workspaces\codeplex\fluentassertions\Main\FluentAssertions.Net35\Formatting\AttributeBasedFormatter.cs:line 27
at FluentAssertions.Formatting.Formatter.<>c__DisplayClass1.<ToString>b__0(IValueFormatter f) in c:\Workspaces\codeplex\fluentassertions\Main\FluentAssertions.Net35\Formatting\Formatter.cs:line 54
at System.Linq.Enumerable.First[TSource](IEnumerable`1 source, Func`2 predicate)
at FluentAssertions.Formatting.Formatter.ToString(Object value, Boolean useLineBreaks, IList`1 processedObjects, Int32 nestedPropertyLevel) in c:\Workspaces\codeplex\fluentassertions\Main\FluentAssertions.Net35\Formatting\Formatter.cs:line 54
at FluentAssertions.Execution.Verification.<BuildExceptionMessage>b__3(Object a) in c:\Workspaces\codeplex\fluentassertions\Main\FluentAssertions.Net35\Execution\Verification.cs:line 217
at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
at System.Collections.Generic.List`1.InsertRange(Int32 index, IEnumerable`1 collection)
at FluentAssertions.Execution.Verification.BuildExceptionMessage(String failureMessage, Object[] failureArgs) in c:\Workspaces\codeplex\fluentassertions\Main\FluentAssertions.Net35\Execution\Verification.cs:line 217
at FluentAssertions.Execution.Verification.FailWith(String failureMessage, Object[] failureArgs) in c:\Workspaces\codeplex\fluentassertions\Main\FluentAssertions.Net35\Execution\Verification.cs:line 158
at FluentAssertions.Numeric.NumericAssertions`1.Be(T expected, String reason, Object[] reasonArgs) in c:\Workspaces\codeplex\fluentassertions\Main\FluentAssertions.Net35\Numeric\NumericAssertions.cs:line 44
```
IMHO, it would be Ok to handle FileLoadException the same way other exceptions are handled in GetExportedTypes.
Thanks.
```
Test(s) failed. System.IO.FileLoadException : Could not load file or assembly 'System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
at System.Reflection.RuntimeAssembly.GetExportedTypes(RuntimeAssembly assembly, ObjectHandleOnStack retTypes)
at System.Reflection.RuntimeAssembly.GetExportedTypes()
at FluentAssertions.Formatting.AttributeBasedFormatter.GetExportedTypes(Assembly assembly) in c:\Workspaces\codeplex\fluentassertions\Main\FluentAssertions.Net35\Formatting\AttributeBasedFormatter.cs:line 126
at System.Linq.Enumerable.<SelectManyIterator>d__14`2.MoveNext()
at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
at FluentAssertions.Formatting.AttributeBasedFormatter.get_AllTypes() in c:\Workspaces\codeplex\fluentassertions\Main\FluentAssertions.Net35\Formatting\AttributeBasedFormatter.cs:line 119
at FluentAssertions.Formatting.AttributeBasedFormatter.FindCustomFormatters() in c:\Workspaces\codeplex\fluentassertions\Main\FluentAssertions.Net35\Formatting\AttributeBasedFormatter.cs:line 63
at FluentAssertions.Formatting.AttributeBasedFormatter.get_Formatters() in c:\Workspaces\codeplex\fluentassertions\Main\FluentAssertions.Net35\Formatting\AttributeBasedFormatter.cs:line 58
at FluentAssertions.Formatting.AttributeBasedFormatter.GetFormatter(Object value) in c:\Workspaces\codeplex\fluentassertions\Main\FluentAssertions.Net35\Formatting\AttributeBasedFormatter.cs:line 0
at FluentAssertions.Formatting.AttributeBasedFormatter.CanHandle(Object value) in c:\Workspaces\codeplex\fluentassertions\Main\FluentAssertions.Net35\Formatting\AttributeBasedFormatter.cs:line 27
at FluentAssertions.Formatting.Formatter.<>c__DisplayClass1.<ToString>b__0(IValueFormatter f) in c:\Workspaces\codeplex\fluentassertions\Main\FluentAssertions.Net35\Formatting\Formatter.cs:line 54
at System.Linq.Enumerable.First[TSource](IEnumerable`1 source, Func`2 predicate)
at FluentAssertions.Formatting.Formatter.ToString(Object value, Boolean useLineBreaks, IList`1 processedObjects, Int32 nestedPropertyLevel) in c:\Workspaces\codeplex\fluentassertions\Main\FluentAssertions.Net35\Formatting\Formatter.cs:line 54
at FluentAssertions.Execution.Verification.<BuildExceptionMessage>b__3(Object a) in c:\Workspaces\codeplex\fluentassertions\Main\FluentAssertions.Net35\Execution\Verification.cs:line 217
at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
at System.Collections.Generic.List`1.InsertRange(Int32 index, IEnumerable`1 collection)
at FluentAssertions.Execution.Verification.BuildExceptionMessage(String failureMessage, Object[] failureArgs) in c:\Workspaces\codeplex\fluentassertions\Main\FluentAssertions.Net35\Execution\Verification.cs:line 217
at FluentAssertions.Execution.Verification.FailWith(String failureMessage, Object[] failureArgs) in c:\Workspaces\codeplex\fluentassertions\Main\FluentAssertions.Net35\Execution\Verification.cs:line 158
at FluentAssertions.Numeric.NumericAssertions`1.Be(T expected, String reason, Object[] reasonArgs) in c:\Workspaces\codeplex\fluentassertions\Main\FluentAssertions.Net35\Numeric\NumericAssertions.cs:line 44
```
IMHO, it would be Ok to handle FileLoadException the same way other exceptions are handled in GetExportedTypes.
Thanks.
↧
Closed Issue: silverlight 5 test projects throwing wrong exceptions [12474]
When used against a sl 5 assembly, a fileNotFoundException is thrown when a test fails.
I tried recompiling to SL5, and there's an errror in the GenerateHandler method of the EventHandlerFactory. the DynamicMethod constructor that is being used is not supported in SL5. I removed the module from this, and all the tests are running correctly.
The problem is that I am not sure if I broke something, as I don;t understand the code I touched.
Comments: No response from the submitter and seems to be a user issue.
I tried recompiling to SL5, and there's an errror in the GenerateHandler method of the EventHandlerFactory. the DynamicMethod constructor that is being used is not supported in SL5. I removed the module from this, and all the tests are running correctly.
The problem is that I am not sure if I broke something, as I don;t understand the code I touched.
Comments: No response from the submitter and seems to be a user issue.
↧
↧
Source code checked in, #38c666e78f4a
Small bug-fix to better intercept and/or prevent exceptions while scanning for methods annotated with [ValueFormatter].
Updated version number to 2.0.1
↧
Updated Release: Release 2.0.1 (Mar 03, 2013)
Read this blog post for all the details
↧
Released: Release 2.0.1 (Mar 03, 2013)
Read
this blog post for all the details
Release 2.0.1 adds a small bug-fix to better intercept and/or prevent exceptions while scanning for methods annotated withValueFormatter
Release 2.0.1 adds a small bug-fix to better intercept and/or prevent exceptions while scanning for methods annotated withValueFormatter
↧
Updated Release: Release 2.0.1 (Mar 03, 2013)
Read this blog post for all the details
Release 2.0.1 adds a small bug-fix to better intercept and/or prevent exceptions while scanning for methods annotated with ValueFormatter
Release 2.0.1 adds a small bug-fix to better intercept and/or prevent exceptions while scanning for methods annotated with ValueFormatter
↧
↧
Closed Issue: StartWith on an empty string throws ArgumentOutOfRangeException instead of giving a useful message [12458]
"".Should().StartWith("foo");
throws the following exception instead of giving a useful message about "" not starting with "foo":
System.ArgumentOutOfRangeException : StartIndex cannot be less than zero.
Parameter name: startIndex
at System.String.InternalSubStringWithChecks(Int32 startIndex, Int32 length, Boolean fAlwaysCopy)
at FluentAssertions.Common.Extensions.IndexedSegmentAt(String value, Int32 index) in c:\Workspaces\FluentAssertions\Releases\1.7.0\FluentAssertions.Net35\Common\Extensions.cs:line 89#0
at FluentAssertions.Assertions.StringStartValidator.ValidateAgainstMismatch() in c:\Workspaces\FluentAssertions\Releases\1.7.0\FluentAssertions.Net35\Assertions\StringStartValidator.cs:line 44#1
at FluentAssertions.Assertions.StringValidator.Validate() in c:\Workspaces\FluentAssertions\Releases\1.7.0\FluentAssertions.Net35\Assertions\StringValidator.cs:line 42#2
at FluentAssertions.Assertions.StringAssertions.StartWith(String expected, String reason, Object[] reasonArgs) in c:\Workspaces\FluentAssertions\Releases\1.7.0\FluentAssertions.Net35\Assertions\StringAssertions.cs:line 295#3
at FluentAssertions.Assertions.StringAssertions.StartWith(String expected) in c:\Workspaces\FluentAssertions\Releases\1.7.0\FluentAssertions.Net35\Assertions\StringAssertions.cs:line 268#4
Comments: Was already fixed in 2.0.0
throws the following exception instead of giving a useful message about "" not starting with "foo":
System.ArgumentOutOfRangeException : StartIndex cannot be less than zero.
Parameter name: startIndex
at System.String.InternalSubStringWithChecks(Int32 startIndex, Int32 length, Boolean fAlwaysCopy)
at FluentAssertions.Common.Extensions.IndexedSegmentAt(String value, Int32 index) in c:\Workspaces\FluentAssertions\Releases\1.7.0\FluentAssertions.Net35\Common\Extensions.cs:line 89#0
at FluentAssertions.Assertions.StringStartValidator.ValidateAgainstMismatch() in c:\Workspaces\FluentAssertions\Releases\1.7.0\FluentAssertions.Net35\Assertions\StringStartValidator.cs:line 44#1
at FluentAssertions.Assertions.StringValidator.Validate() in c:\Workspaces\FluentAssertions\Releases\1.7.0\FluentAssertions.Net35\Assertions\StringValidator.cs:line 42#2
at FluentAssertions.Assertions.StringAssertions.StartWith(String expected, String reason, Object[] reasonArgs) in c:\Workspaces\FluentAssertions\Releases\1.7.0\FluentAssertions.Net35\Assertions\StringAssertions.cs:line 295#3
at FluentAssertions.Assertions.StringAssertions.StartWith(String expected) in c:\Workspaces\FluentAssertions\Releases\1.7.0\FluentAssertions.Net35\Assertions\StringAssertions.cs:line 268#4
Comments: Was already fixed in 2.0.0
↧
Closed Issue: BeNull and NotBeNull have the same condition for comparable types [12456]
I have a reference type implementing IComparable<T> that I assert to be null:
value.Should().BeNull();
The test unexpectedly fails when the value is indeed null (verified in the debugger). When I change the assertion to explicitly check for null, the test passes:
value.Should().Be(null);
I determined that the assertion is of type ComparableTypeAssertions<> and found the implementation of BeNull here:
http://fluentassertions.codeplex.com/SourceControl/changeset/view/9808ede8793e#Main%2fFluentAssertions.Net35%2fNumeric%2fComparableTypeAssertions.cs
I am not versed in the Execute.Verification syntax, but I did notice that both the BeNull and NotBeNull methods have the same condition:
.ForCondition(!ReferenceEquals(Subject, null))
As those two conditions are the inverse of each other, this seems incorrect and a possible culprit for the expected outcome of BeNull.
Comments: Was already fixed in 2.0.0
value.Should().BeNull();
The test unexpectedly fails when the value is indeed null (verified in the debugger). When I change the assertion to explicitly check for null, the test passes:
value.Should().Be(null);
I determined that the assertion is of type ComparableTypeAssertions<> and found the implementation of BeNull here:
http://fluentassertions.codeplex.com/SourceControl/changeset/view/9808ede8793e#Main%2fFluentAssertions.Net35%2fNumeric%2fComparableTypeAssertions.cs
I am not versed in the Execute.Verification syntax, but I did notice that both the BeNull and NotBeNull methods have the same condition:
.ForCondition(!ReferenceEquals(Subject, null))
As those two conditions are the inverse of each other, this seems incorrect and a possible culprit for the expected outcome of BeNull.
Comments: Was already fixed in 2.0.0
↧
Closed Issue: TypeAssertions throws NullReferenceException when checking Should().Be(null) [12460]
FluentAssertions 1.7.1, net35 version.
Type type = GetNullType();
type.Should().Be(null);
throws NullReferenceException if type is null:
System.NullReferenceException : Object reference not set to an instance of an object.
Stack Trace:
TypeAssertions.GetFailureMessageIfTypesAreDifferent(Type actual, Type expected)
TypeAssertions.Be(Type expected, String reason, Object[] reasonArgs)
TypeAssertions.Be(Type expected)
...
A valid workaround:
Object type = GetNullType();
type.Should().Be(null); // or type.Should().BeNull();
Asides from the unexpected exception, I think TypeAssertions should provide a BeNull method also.
Comments: Was already fixed in 2.0.0
Type type = GetNullType();
type.Should().Be(null);
throws NullReferenceException if type is null:
System.NullReferenceException : Object reference not set to an instance of an object.
Stack Trace:
TypeAssertions.GetFailureMessageIfTypesAreDifferent(Type actual, Type expected)
TypeAssertions.Be(Type expected, String reason, Object[] reasonArgs)
TypeAssertions.Be(Type expected)
...
A valid workaround:
Object type = GetNullType();
type.Should().Be(null); // or type.Should().BeNull();
Asides from the unexpected exception, I think TypeAssertions should provide a BeNull method also.
Comments: Was already fixed in 2.0.0
↧
Closed Issue: Issue with normal Should Be call [12478]
Hi
I receive an exception when i make a call like this:
```
etuResponse.Header.RspCode.Should().Be(0);
```
Thats all. I am doing nothing else.
RspCode has the value 234.
I am using MSTest, Visual Studio 2012, .Net 4.5
FluentAssertion Version: 2.0.0.0
```
System.NotSupportedException occurred
HResult=-2146233067
Message=The invoked member is not supported in a dynamic assembly.
Source=mscorlib
StackTrace:
at System.Reflection.Emit.InternalAssemblyBuilder.GetExportedTypes()
at FluentAssertions.Formatting.AttributeBasedFormatter.GetExportedTypes(Assembly assembly) in c:\Workspaces\codeplex\fluentassertions\Main\FluentAssertions.Net35\Formatting\AttributeBasedFormatter.cs:line 126
InnerException:
```
Comments: Fixed in the latest NuGet package
I receive an exception when i make a call like this:
```
etuResponse.Header.RspCode.Should().Be(0);
```
Thats all. I am doing nothing else.
RspCode has the value 234.
I am using MSTest, Visual Studio 2012, .Net 4.5
FluentAssertion Version: 2.0.0.0
```
System.NotSupportedException occurred
HResult=-2146233067
Message=The invoked member is not supported in a dynamic assembly.
Source=mscorlib
StackTrace:
at System.Reflection.Emit.InternalAssemblyBuilder.GetExportedTypes()
at FluentAssertions.Formatting.AttributeBasedFormatter.GetExportedTypes(Assembly assembly) in c:\Workspaces\codeplex\fluentassertions\Main\FluentAssertions.Net35\Formatting\AttributeBasedFormatter.cs:line 126
InnerException:
```
Comments: Fixed in the latest NuGet package
↧
↧
Closed Issue: System.IO.FileLoadException in AttributeBasedFormatter.AllTypes [12476]
I don't know how to reproduce this in simple project, but I am getting this exception on a test project that uses StackExchange's MiniProfiler
```
Test(s) failed. System.IO.FileLoadException : Could not load file or assembly 'System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
at System.Reflection.RuntimeAssembly.GetExportedTypes(RuntimeAssembly assembly, ObjectHandleOnStack retTypes)
at System.Reflection.RuntimeAssembly.GetExportedTypes()
at FluentAssertions.Formatting.AttributeBasedFormatter.GetExportedTypes(Assembly assembly) in c:\Workspaces\codeplex\fluentassertions\Main\FluentAssertions.Net35\Formatting\AttributeBasedFormatter.cs:line 126
at System.Linq.Enumerable.<SelectManyIterator>d__14`2.MoveNext()
at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
at FluentAssertions.Formatting.AttributeBasedFormatter.get_AllTypes() in c:\Workspaces\codeplex\fluentassertions\Main\FluentAssertions.Net35\Formatting\AttributeBasedFormatter.cs:line 119
at FluentAssertions.Formatting.AttributeBasedFormatter.FindCustomFormatters() in c:\Workspaces\codeplex\fluentassertions\Main\FluentAssertions.Net35\Formatting\AttributeBasedFormatter.cs:line 63
at FluentAssertions.Formatting.AttributeBasedFormatter.get_Formatters() in c:\Workspaces\codeplex\fluentassertions\Main\FluentAssertions.Net35\Formatting\AttributeBasedFormatter.cs:line 58
at FluentAssertions.Formatting.AttributeBasedFormatter.GetFormatter(Object value) in c:\Workspaces\codeplex\fluentassertions\Main\FluentAssertions.Net35\Formatting\AttributeBasedFormatter.cs:line 0
at FluentAssertions.Formatting.AttributeBasedFormatter.CanHandle(Object value) in c:\Workspaces\codeplex\fluentassertions\Main\FluentAssertions.Net35\Formatting\AttributeBasedFormatter.cs:line 27
at FluentAssertions.Formatting.Formatter.<>c__DisplayClass1.<ToString>b__0(IValueFormatter f) in c:\Workspaces\codeplex\fluentassertions\Main\FluentAssertions.Net35\Formatting\Formatter.cs:line 54
at System.Linq.Enumerable.First[TSource](IEnumerable`1 source, Func`2 predicate)
at FluentAssertions.Formatting.Formatter.ToString(Object value, Boolean useLineBreaks, IList`1 processedObjects, Int32 nestedPropertyLevel) in c:\Workspaces\codeplex\fluentassertions\Main\FluentAssertions.Net35\Formatting\Formatter.cs:line 54
at FluentAssertions.Execution.Verification.<BuildExceptionMessage>b__3(Object a) in c:\Workspaces\codeplex\fluentassertions\Main\FluentAssertions.Net35\Execution\Verification.cs:line 217
at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
at System.Collections.Generic.List`1.InsertRange(Int32 index, IEnumerable`1 collection)
at FluentAssertions.Execution.Verification.BuildExceptionMessage(String failureMessage, Object[] failureArgs) in c:\Workspaces\codeplex\fluentassertions\Main\FluentAssertions.Net35\Execution\Verification.cs:line 217
at FluentAssertions.Execution.Verification.FailWith(String failureMessage, Object[] failureArgs) in c:\Workspaces\codeplex\fluentassertions\Main\FluentAssertions.Net35\Execution\Verification.cs:line 158
at FluentAssertions.Numeric.NumericAssertions`1.Be(T expected, String reason, Object[] reasonArgs) in c:\Workspaces\codeplex\fluentassertions\Main\FluentAssertions.Net35\Numeric\NumericAssertions.cs:line 44
```
IMHO, it would be Ok to handle FileLoadException the same way other exceptions are handled in GetExportedTypes.
Thanks.
Comments: Fixed in the latest NuGet package
```
Test(s) failed. System.IO.FileLoadException : Could not load file or assembly 'System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
at System.Reflection.RuntimeAssembly.GetExportedTypes(RuntimeAssembly assembly, ObjectHandleOnStack retTypes)
at System.Reflection.RuntimeAssembly.GetExportedTypes()
at FluentAssertions.Formatting.AttributeBasedFormatter.GetExportedTypes(Assembly assembly) in c:\Workspaces\codeplex\fluentassertions\Main\FluentAssertions.Net35\Formatting\AttributeBasedFormatter.cs:line 126
at System.Linq.Enumerable.<SelectManyIterator>d__14`2.MoveNext()
at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
at FluentAssertions.Formatting.AttributeBasedFormatter.get_AllTypes() in c:\Workspaces\codeplex\fluentassertions\Main\FluentAssertions.Net35\Formatting\AttributeBasedFormatter.cs:line 119
at FluentAssertions.Formatting.AttributeBasedFormatter.FindCustomFormatters() in c:\Workspaces\codeplex\fluentassertions\Main\FluentAssertions.Net35\Formatting\AttributeBasedFormatter.cs:line 63
at FluentAssertions.Formatting.AttributeBasedFormatter.get_Formatters() in c:\Workspaces\codeplex\fluentassertions\Main\FluentAssertions.Net35\Formatting\AttributeBasedFormatter.cs:line 58
at FluentAssertions.Formatting.AttributeBasedFormatter.GetFormatter(Object value) in c:\Workspaces\codeplex\fluentassertions\Main\FluentAssertions.Net35\Formatting\AttributeBasedFormatter.cs:line 0
at FluentAssertions.Formatting.AttributeBasedFormatter.CanHandle(Object value) in c:\Workspaces\codeplex\fluentassertions\Main\FluentAssertions.Net35\Formatting\AttributeBasedFormatter.cs:line 27
at FluentAssertions.Formatting.Formatter.<>c__DisplayClass1.<ToString>b__0(IValueFormatter f) in c:\Workspaces\codeplex\fluentassertions\Main\FluentAssertions.Net35\Formatting\Formatter.cs:line 54
at System.Linq.Enumerable.First[TSource](IEnumerable`1 source, Func`2 predicate)
at FluentAssertions.Formatting.Formatter.ToString(Object value, Boolean useLineBreaks, IList`1 processedObjects, Int32 nestedPropertyLevel) in c:\Workspaces\codeplex\fluentassertions\Main\FluentAssertions.Net35\Formatting\Formatter.cs:line 54
at FluentAssertions.Execution.Verification.<BuildExceptionMessage>b__3(Object a) in c:\Workspaces\codeplex\fluentassertions\Main\FluentAssertions.Net35\Execution\Verification.cs:line 217
at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
at System.Collections.Generic.List`1.InsertRange(Int32 index, IEnumerable`1 collection)
at FluentAssertions.Execution.Verification.BuildExceptionMessage(String failureMessage, Object[] failureArgs) in c:\Workspaces\codeplex\fluentassertions\Main\FluentAssertions.Net35\Execution\Verification.cs:line 217
at FluentAssertions.Execution.Verification.FailWith(String failureMessage, Object[] failureArgs) in c:\Workspaces\codeplex\fluentassertions\Main\FluentAssertions.Net35\Execution\Verification.cs:line 158
at FluentAssertions.Numeric.NumericAssertions`1.Be(T expected, String reason, Object[] reasonArgs) in c:\Workspaces\codeplex\fluentassertions\Main\FluentAssertions.Net35\Numeric\NumericAssertions.cs:line 44
```
IMHO, it would be Ok to handle FileLoadException the same way other exceptions are handled in GetExportedTypes.
Thanks.
Comments: Fixed in the latest NuGet package
↧
Created Feature: Should details about an AggregateException in ShouldNotThrow [12482]
When an AggregateException is thrown it would be nice if ShouldNotThrow shows the details about the inner exception. Now you only see that an AggregateException is thrown, but is is more interesting to know what the inner exceptions are.
↧
Edited Feature: Show details about an AggregateException in ShouldNotThrow [12482]
When an AggregateException is thrown it would be nice if ShouldNotThrow shows the details about the inner exception. Now you only see that an AggregateException is thrown, but is is more interesting to know what the inner exceptions are.
↧
Commented Issue: ShouldBeEquivalentTo crashes on signature hiding properties [12481]
Take this example. Foo is overriden with new. This crashes TypeExtensions.FindProperty because it will see object Foo and string Foo
```c#
[TestMethod]
public void FluentAssertionsTest()
{
var a1 = new B<string> { Foo = "test" };
var a2 = new E<string> { Foo = "test" };
a1.ShouldBeEquivalentTo(a2);
//a1.ShouldBeEquivalentTo(a2, ex => ex.Using(new MustMatchByNameAndTypeRule()));
}
public class A
{
public object Foo { get; set; }
}
public class B<T> : A
{
public new T Foo
{
get
{
return (T)base.Foo;
}
set
{
base.Foo = value;
}
}
}
public class D
{
public object Foo { get; set; }
}
public class E<T> : D
{
public new T Foo
{
get
{
return (T)base.Foo;
}
set
{
base.Foo = value;
}
}
}
```
My suggestion is to add 2 new matchers:
```c#
public class MustMatchByNameAndTypeRule : IMatchingRule
{
public PropertyInfo Match(PropertyInfo subjectProperty, object expectation, string propertyPath)
{
PropertyInfo compareeProperty = expectation.GetType()
.GetProperties(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)
.SingleOrDefault(pi => pi.Name == subjectProperty.Name && pi.PropertyType == subjectProperty.PropertyType);
if (compareeProperty == null)
{
string path = (propertyPath.Length > 0) ? propertyPath + "." : "property ";
Execute.Verification.FailWith(
"Subject has " + path + subjectProperty.Name + " that the other object does not have.");
}
return compareeProperty;
}
public override string ToString()
{
return "Match property by name and type (or throw)";
}
}
public class TryMatchByNameAndTypeRule : IMatchingRule
{
public PropertyInfo Match(PropertyInfo subjectProperty, object expectation, string propertyPath)
{
PropertyInfo compareeProperty = expectation.GetType()
.GetProperties(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)
.SingleOrDefault(pi => pi.Name == subjectProperty.Name && pi.PropertyType == subjectProperty.PropertyType);
return compareeProperty;
}
public override string ToString()
{
return "Try to match property by name and type";
}
}
```
Comments: This is another approach to fix the problem. I think it's the better one: Just change the MustMatchByNameRule to: ```c# var compareeProperties = expectation.GetType() .GetProperties(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance) .Where(pi => pi.Name == subjectProperty.Name).ToList(); PropertyInfo compareeProperty = compareeProperties.Count > 1 ? compareeProperties.SingleOrDefault(pi => pi.PropertyType == subjectProperty.PropertyType) : compareeProperties.FirstOrDefault(); ```
```c#
[TestMethod]
public void FluentAssertionsTest()
{
var a1 = new B<string> { Foo = "test" };
var a2 = new E<string> { Foo = "test" };
a1.ShouldBeEquivalentTo(a2);
//a1.ShouldBeEquivalentTo(a2, ex => ex.Using(new MustMatchByNameAndTypeRule()));
}
public class A
{
public object Foo { get; set; }
}
public class B<T> : A
{
public new T Foo
{
get
{
return (T)base.Foo;
}
set
{
base.Foo = value;
}
}
}
public class D
{
public object Foo { get; set; }
}
public class E<T> : D
{
public new T Foo
{
get
{
return (T)base.Foo;
}
set
{
base.Foo = value;
}
}
}
```
My suggestion is to add 2 new matchers:
```c#
public class MustMatchByNameAndTypeRule : IMatchingRule
{
public PropertyInfo Match(PropertyInfo subjectProperty, object expectation, string propertyPath)
{
PropertyInfo compareeProperty = expectation.GetType()
.GetProperties(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)
.SingleOrDefault(pi => pi.Name == subjectProperty.Name && pi.PropertyType == subjectProperty.PropertyType);
if (compareeProperty == null)
{
string path = (propertyPath.Length > 0) ? propertyPath + "." : "property ";
Execute.Verification.FailWith(
"Subject has " + path + subjectProperty.Name + " that the other object does not have.");
}
return compareeProperty;
}
public override string ToString()
{
return "Match property by name and type (or throw)";
}
}
public class TryMatchByNameAndTypeRule : IMatchingRule
{
public PropertyInfo Match(PropertyInfo subjectProperty, object expectation, string propertyPath)
{
PropertyInfo compareeProperty = expectation.GetType()
.GetProperties(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)
.SingleOrDefault(pi => pi.Name == subjectProperty.Name && pi.PropertyType == subjectProperty.PropertyType);
return compareeProperty;
}
public override string ToString()
{
return "Try to match property by name and type";
}
}
```
Comments: This is another approach to fix the problem. I think it's the better one: Just change the MustMatchByNameRule to: ```c# var compareeProperties = expectation.GetType() .GetProperties(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance) .Where(pi => pi.Name == subjectProperty.Name).ToList(); PropertyInfo compareeProperty = compareeProperties.Count > 1 ? compareeProperties.SingleOrDefault(pi => pi.PropertyType == subjectProperty.PropertyType) : compareeProperties.FirstOrDefault(); ```
↧
↧
Commented Issue: ShouldBeEquivalentTo crashes on signature hiding properties [12481]
Take this example. Foo is overriden with new. This crashes TypeExtensions.FindProperty because it will see object Foo and string Foo
```c#
[TestMethod]
public void FluentAssertionsTest()
{
var a1 = new B<string> { Foo = "test" };
var a2 = new E<string> { Foo = "test" };
a1.ShouldBeEquivalentTo(a2);
//a1.ShouldBeEquivalentTo(a2, ex => ex.Using(new MustMatchByNameAndTypeRule()));
}
public class A
{
public object Foo { get; set; }
}
public class B<T> : A
{
public new T Foo
{
get
{
return (T)base.Foo;
}
set
{
base.Foo = value;
}
}
}
public class D
{
public object Foo { get; set; }
}
public class E<T> : D
{
public new T Foo
{
get
{
return (T)base.Foo;
}
set
{
base.Foo = value;
}
}
}
```
My suggestion is to add 2 new matchers:
```c#
public class MustMatchByNameAndTypeRule : IMatchingRule
{
public PropertyInfo Match(PropertyInfo subjectProperty, object expectation, string propertyPath)
{
PropertyInfo compareeProperty = expectation.GetType()
.GetProperties(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)
.SingleOrDefault(pi => pi.Name == subjectProperty.Name && pi.PropertyType == subjectProperty.PropertyType);
if (compareeProperty == null)
{
string path = (propertyPath.Length > 0) ? propertyPath + "." : "property ";
Execute.Verification.FailWith(
"Subject has " + path + subjectProperty.Name + " that the other object does not have.");
}
return compareeProperty;
}
public override string ToString()
{
return "Match property by name and type (or throw)";
}
}
public class TryMatchByNameAndTypeRule : IMatchingRule
{
public PropertyInfo Match(PropertyInfo subjectProperty, object expectation, string propertyPath)
{
PropertyInfo compareeProperty = expectation.GetType()
.GetProperties(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)
.SingleOrDefault(pi => pi.Name == subjectProperty.Name && pi.PropertyType == subjectProperty.PropertyType);
return compareeProperty;
}
public override string ToString()
{
return "Try to match property by name and type";
}
}
```
Comments: Thanks. I'll incorporate your changes in 2.1.
```c#
[TestMethod]
public void FluentAssertionsTest()
{
var a1 = new B<string> { Foo = "test" };
var a2 = new E<string> { Foo = "test" };
a1.ShouldBeEquivalentTo(a2);
//a1.ShouldBeEquivalentTo(a2, ex => ex.Using(new MustMatchByNameAndTypeRule()));
}
public class A
{
public object Foo { get; set; }
}
public class B<T> : A
{
public new T Foo
{
get
{
return (T)base.Foo;
}
set
{
base.Foo = value;
}
}
}
public class D
{
public object Foo { get; set; }
}
public class E<T> : D
{
public new T Foo
{
get
{
return (T)base.Foo;
}
set
{
base.Foo = value;
}
}
}
```
My suggestion is to add 2 new matchers:
```c#
public class MustMatchByNameAndTypeRule : IMatchingRule
{
public PropertyInfo Match(PropertyInfo subjectProperty, object expectation, string propertyPath)
{
PropertyInfo compareeProperty = expectation.GetType()
.GetProperties(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)
.SingleOrDefault(pi => pi.Name == subjectProperty.Name && pi.PropertyType == subjectProperty.PropertyType);
if (compareeProperty == null)
{
string path = (propertyPath.Length > 0) ? propertyPath + "." : "property ";
Execute.Verification.FailWith(
"Subject has " + path + subjectProperty.Name + " that the other object does not have.");
}
return compareeProperty;
}
public override string ToString()
{
return "Match property by name and type (or throw)";
}
}
public class TryMatchByNameAndTypeRule : IMatchingRule
{
public PropertyInfo Match(PropertyInfo subjectProperty, object expectation, string propertyPath)
{
PropertyInfo compareeProperty = expectation.GetType()
.GetProperties(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)
.SingleOrDefault(pi => pi.Name == subjectProperty.Name && pi.PropertyType == subjectProperty.PropertyType);
return compareeProperty;
}
public override string ToString()
{
return "Try to match property by name and type";
}
}
```
Comments: Thanks. I'll incorporate your changes in 2.1.
↧
New Post: Why does Should().ContainSingle() accept predicate mandatory
Comparing to LINQ having both Single() and Single(predicate), I want ContainSingle() overload accepting no parameters.
What analog does exist so far? HaveCount(1)?
Also even I specify predicate, I want ContainSingle().And. to return assertion against this single T but not initial IEnumerable<T>. Doesn't it make sense?
What analog does exist so far? HaveCount(1)?
Also even I specify predicate, I want ContainSingle().And. to return assertion against this single T but not initial IEnumerable<T>. Doesn't it make sense?
↧
New Post: Why doesn't NotBeSameAs() work with GenericCollectionAssertions?
I'm implementing a special case of an immutable dictionary, which for convenience implements
I would think this is just a hole in the implementation, but I ran into the same problem with the Should framework, which, since I'm relatively new to C#, makes me wonder if I'm missing something conceptual about .NET collections.
IEnumerable<KeyValuePair<Foo, Bar>>
. Operations that would ordinarily modify the dictionary should instead return a new instance. But if I try to use NotBeSameAs
to check that these new instances are in fact new instances, I can't.I would think this is just a hole in the implementation, but I ran into the same problem with the Should framework, which, since I'm relatively new to C#, makes me wonder if I'm missing something conceptual about .NET collections.
↧