-
Notifications
You must be signed in to change notification settings - Fork 731
Closed
Description
Description
[Description of the issue]
I try to exclude o.Excluding(x => x.CreatedDate) on OrganizationalUnit class
public class OrganizationalUnit
{
public Guid Id { get; set; }
public OrganizationalUnitTypes Type { get; set; }
public string Name { get; set; }
public Guid? ParentId { get; set; }
public string Region { get; set; }
public string Currency { get; set; }
public string LogoUrl { get; set; }
public string FeaturePlanId { get; set; }
public string LogoBase64 { get; set; }
public string[] EnabledModules { get; set; }
public DateTime? CreatedDate { get; set; }
public OrganizationalUnit()
{
EnabledModules = new string[] { };
}
}Settings:
AssertionOptions.AssertEquivalencyUsing(options =>
options.Using<OrganizationalUnit>(ctx =>
ctx.Subject.Should()
.BeEquivalentTo(ctx.Expectation, o => o.Excluding(x => x.CreatedDate)))
.WhenTypeIs<OrganizationalUnit>()Assert:
new[]{ actual }.Should().BeEquivalentTo(ou);
new[]{ actual }.Should().BeEquivalentTo(new[] { ou });
actual.Should().BeEquivalentTo<OrganizationalUnit>(ou);Last one fails.
Why array of OrganizationalUnit is treated differently from just OrganizationalUnit assertion.
From test output: Treating member CreatedDate as a value type because Equals must be used.
not sure if it is relevant, but I expect to ignore CreatedDate field
Output:
Treating member CreatedDate as a value type because Equals must be used.??
Expected member CreatedDate to be <2019-10-30 17:38:36.078881>, but found <2019-04-18 12:43:34.0566667>.
With configuration:
- Use declared types and members
- Compare enums by value
- Match member by name (or throw)
- Invoke Action<OrganizationalUnit> when info.RuntimeType.IsSameOrInherits(_3manager.Opportunities.Api.Models.OrganizationalUnit)
- Invoke Action<OrganizationalUnit> when info.RuntimeType.IsSameOrInherits(_3manager.Opportunities.Api.Models.OrganizationalUnit)
- Without automatic conversion.
- Be strict about the order of items in byte arrays
With trace:
Structurally comparing System.Object[] and expectation System.Object[] at root
{
Finding the best match of _3manager.Opportunities.Api.Models.OrganizationalUnit within all items in System.Object[] at root[0]
{
Comparing subject at root[0] with the expectation at root[0]
{
Treating member Id as a value type because Equals must be used.
Structurally comparing System.Object[] and expectation System.String[] at member EnabledModules
{
Finding the best match of f7e56c6e-acc0-416b-949e-91b37ce90272 within all items in System.Object[] at member EnabledModules[0]
{
Comparing subject at member EnabledModules[0] with the expectation at member EnabledModules[0]
{
It's a match
}
}
Finding the best match of 2b541eb6-5c70-4e15-8193-6973234306e3 within all items in System.Object[] at member EnabledModules[1]
{
Comparing subject at member EnabledModules[1] with the expectation at member EnabledModules[1]
{
It's a match
}
}
Finding the best match of 75b8df7c-1def-4b74-9c0a-e28a27941c4b within all items in System.Object[] at member EnabledModules[2]
{
Comparing subject at member EnabledModules[2] with the expectation at member EnabledModules[2]
{
It's a match
}
}
}
It's a match
}
}
}
Structurally comparing System.Object[] and expectation System.Object[] at root
{
Finding the best match of _3manager.Opportunities.Api.Models.OrganizationalUnit within all items in System.Object[] at root[0]
{
Comparing subject at root[0] with the expectation at root[0]
{
Treating member Id as a value type because Equals must be used.
Structurally comparing System.Object[] and expectation System.String[] at member EnabledModules
{
Finding the best match of f7e56c6e-acc0-416b-949e-91b37ce90272 within all items in System.Object[] at member EnabledModules[0]
{
Comparing subject at member EnabledModules[0] with the expectation at member EnabledModules[0]
{
It's a match
}
}
Finding the best match of 2b541eb6-5c70-4e15-8193-6973234306e3 within all items in System.Object[] at member EnabledModules[1]
{
Comparing subject at member EnabledModules[1] with the expectation at member EnabledModules[1]
{
It's a match
}
}
Finding the best match of 75b8df7c-1def-4b74-9c0a-e28a27941c4b within all items in System.Object[] at member EnabledModules[2]
{
Comparing subject at member EnabledModules[2] with the expectation at member EnabledModules[2]
{
It's a match
}
}
}
It's a match
}
}
}
Treating member Id as a value type because Equals must be used.
Structurally comparing System.Object[] and expectation System.String[] at member EnabledModules
{
Finding the best match of f7e56c6e-acc0-416b-949e-91b37ce90272 within all items in System.Object[] at member EnabledModules[0]
{
Comparing subject at member EnabledModules[0] with the expectation at member EnabledModules[0]
{
It's a match
}
}
Finding the best match of 2b541eb6-5c70-4e15-8193-6973234306e3 within all items in System.Object[] at member EnabledModules[1]
{
Comparing subject at member EnabledModules[1] with the expectation at member EnabledModules[1]
{
It's a match
}
}
Finding the best match of 75b8df7c-1def-4b74-9c0a-e28a27941c4b within all items in System.Object[] at member EnabledModules[2]
{
Comparing subject at member EnabledModules[2] with the expectation at member EnabledModules[2]
{
It's a match
}
}
}
Treating member CreatedDate as a value type because Equals must be used.
at FluentAssertions.Execution.GallioTestFramework.Throw(String message)
at FluentAssertions.Execution.TestFrameworkProvider.Throw(String message)
at FluentAssertions.Execution.CollectingAssertionStrategy.ThrowIfAny(IDictionary`2 context)
at FluentAssertions.Execution.AssertionScope.Dispose()
at FluentAssertions.Equivalency.EquivalencyValidator.AssertEquality(EquivalencyValidationContext context)
at FluentAssertions.Primitives.ObjectAssertions.BeEquivalentTo[TExpectation](TExpectation expectation, Func`2 config, String because, Object[] becauseArgs)
at FluentAssertions.Primitives.ObjectAssertions.BeEquivalentTo[TExpectation](TExpectation expectation, String because, Object[] becauseArgs)
at _3manager.Opportunities.Api.IntegrationTests.SqlOrganizationalUnitsRepositoryTests.<SavesNewOrganizationalUnitToDatabase>d__10.MoveNext() in
Metadata
Metadata
Assignees
Labels
No labels