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

Improve message when invoking function variables in DoesNotThrow #36

Open
michael-sterling opened this issue Oct 28, 2021 · 1 comment

Comments

@michael-sterling
Copy link
Contributor

michael-sterling commented Oct 28, 2021

Example message:

Expected:
	Invoke(fnAcceptResponse, value)

Actual:
	fnAcceptResponse = {
		"method": {
			"Name": "<ValidateMembership>b__1",
			"AssemblyName": "Logos.AccountServices.Tests.IntegrationTests, Version=4.8.0.0, Culture=neutral, PublicKeyToken=null",
			"ClassName": "Logos.AccountServices.Tests.IntegrationTests.Accounts.V1.ElasticSearchTests+<>c__DisplayClass32_0",
			"Signature": "Void <ValidateMembership>b__1(ElasticSearchAccountDocument)",
			"Signature2": "System.Void <ValidateMembership>b__1(Logos.AccountServices.Tests.IntegrationTests.Accounts.V1.ElasticSearchTests+ElasticSearchAccountDocument)",
			"MemberType": 8,
			"GenericArguments": null
		},
		"target": { "accountId": 10564946, "oldVersion": 6, "unexpectedMembershipId": 10564949 }
	}
	value = {
		"_source": {
			"accountKindId": 1,
			"alias": "elasticsearchtests-542ef093675b4aeab6804f7520961bb2",
			"groupKind": 0,
			"location": "",
			"token": "elasticsearchtests-542ef093675b4aeab6804f7520961bb2",
			"memberships": [10564949, -2]
		},
		"_id": 10564946,
		"_index": "accounts-internal",
		"_version": 6
	}

Context:
	timeoutSeconds = 30
	totalRetries = 11

NUnit.Framework.AssertionException:   expected version to update for Index: accounts-internal Id: 10564946
  Expected: greater than 6
  But was:  6

Example calling code:

		private static async Task<long> ValidateMembership(long oldVersion, int? accountId, int? expectedMembershipId, int? unexpectedMembershipId)
		{
			return await WaitForResponse(() => GetElasticSearchAccount(accountId), userDocument =>
			{
				Assert.Greater(document.Version, oldVersion, "expected version to update for Index: {0} Id: {1}".FormatInvariant(document.Index, document.Id));
			}));
		}

		private static async Task<T> WaitForResponse<T>(Func<T> fnGetResponse, Action<T> fnAcceptResponse)
			where T : class
		{
			return await AssertEx.WaitUntil(fnGetResponse)
				.DoesNotThrow(t => fnAcceptResponse(t));
		}
@michael-sterling michael-sterling changed the title Improve message when invoking anonymous methods in DoesNotThrow Improve message when invoking function variables in DoesNotThrow Oct 28, 2021
@michael-sterling
Copy link
Contributor Author

Suggested better output:

Expected:
	fnAcceptResponse(value)

Actual:
	fnAcceptResponse = {
		"method": "System.Void <ValidateMembership>b__1(Logos.AccountServices.Tests.IntegrationTests.Accounts.V1.ElasticSearchTests+ElasticSearchAccountDocument)",
		"target": { "accountId": 10564946, "oldVersion": 6, "unexpectedMembershipId": 10564949 }
	}
	value = {
		"_source": {
			"accountKindId": 1,
			"alias": "elasticsearchtests-542ef093675b4aeab6804f7520961bb2",
			"groupKind": 0,
			"location": "",
			"token": "elasticsearchtests-542ef093675b4aeab6804f7520961bb2",
			"memberships": [10564949, -2]
		},
		"_id": 10564946,
		"_index": "accounts-internal",
		"_version": 6
	}

Context:
	timeoutSeconds = 30
	totalRetries = 11

NUnit.Framework.AssertionException:   expected version to update for Index: accounts-internal Id: 10564946
  Expected: greater than 6
  But was:  6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant