Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

抽象型のプロパティを持つオブジェクトのアサート #25

Open
in-async opened this issue Jan 28, 2021 · 1 comment
Open
Assignees
Labels
enhancement New feature or request

Comments

@in-async
Copy link
Owner

素直に書けないので、サポートしたい。

@in-async in-async added the enhancement New feature or request label Jan 28, 2021
@in-async in-async self-assigned this Jan 28, 2021
@in-async
Copy link
Owner Author

ここで member.DataType が抽象型だとどうしようもなくなるので、ここでランタイム型を選べるようなオプションを追加する?

// 各データ メンバーの比較
var actualMemberMap = actualType.GetDataMembers().ToDictionary(x => x.Name);
var expectedMemberMap = expectedType.GetDataMembers().ToDictionary(x => x.Name);
foreach (var member in targetDataMembers) {
if (!actualMemberMap.TryRemove(member.Name, out var actualMember)) { throw new PrimitiveAssertFailedException(node, $"actual にデータ メンバー {member.Name} が見つかりません。", _message); }
if (!expectedMemberMap.TryRemove(member.Name, out var expectedMember)) { throw new PrimitiveAssertFailedException(node, $"expected にデータ メンバー {member.Name} が見つかりません。", _message); }
var actualMemberValue = actualMember.GetValue(actual);
var expectedMemberValue = expectedMember.GetValue(expected);
AssertIs(new AssertNode(member.Name, member.DataType, actualMemberValue, expectedMemberValue, node));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant