최근에 FluentAssertions에서 내부 개체 상태 유효성 검사를 피하기 위해을 설명하는 SO question이라고 대답했습니다. 이제는 동일한 문제에 직면하여 FluentAssertions가 내부 속성 OOTB의 유효성을 검사하는 이유는 무엇입니까?FluentAssertions가 내부적으로 유효성을 검사하는 데 왜 동일해야합니까?
public class Class1
{
[Fact]
public void CompareCultureInternalFields()
{
var foo1 = new Foo();
var foo2 = new Foo();
foo1.ShouldBeEquivalentTo(foo2); // fails
}
public object Culture { get; set; }
}
public class Foo
{
public Foo()
{
InternalProp = Guid.NewGuid();
}
internal Guid InternalProp { get; }
}
예외 정보 :
Xunit.Sdk.XunitException: Expected member InternalProp to be {61625b04-c4e6-4e08-a45a-5ff8bb7d53e7}, but found {df589d73-e382-4104-8157-a41da2ca17f5}.
With configuration:
- Use declared types and members
- Compare enums by value
- Match member by name (or throw)
- Be strict about the order of items in byte arrays
가 foo1
및 foo2
개체가 공개 API를 다루는 소비자 동등한 있어야하지 않나요?
클래스가 다른 어셈블리/프로젝트에있는 경우 내부 속성에 액세스 할 수 없어야합니다. 클래스가 같은 어셈블리에 있으면 좋은 예가 아닙니다 – Nkosi
좋은 지적입니다. 일부 자동 생성 된 내부 입력란으로 샘플을 다시 작성하면 어떻게됩니까? –
이제는 무슨 뜻인지 이해합니다. – Nkosi