public async Task Test1Callback(Event1 payload) { // Get the test var testId = FulcrumApplication.Context.CorrelationId; if (string.IsNullOrWhiteSpace(testId)) { Log.LogError($"There was no correlation id. Payload was {JsonSerializer.Serialize(payload)}."); return; } var test = await TestLogic.GetAsync(testId); if (test == null) { Log.LogError($"There was no test with id {testId}. Payload was {JsonSerializer.Serialize(payload)}."); return; } // Check with the Nexus Business Events test bench var md = payload.MetaData; var result = await _businessEventsClient.TestBenchPublish(md.EntityName, md.EventName, md.MajorVersion, md.MinorVersion, md.PublisherName, JToken.FromObject(payload)); if (result.Verified) { await TestLogic.SetStateAsync(test, StateEnum.Ok, "Event verified with BE Test bench"); } else { var message = string.Join(", ", result.Errors) + $" | Contract: {JsonConvert.SerializeObject(result.Contract)}" + $" | Payload: {JsonConvert.SerializeObject(result.Payload)}"; await TestLogic.SetStateAsync(test, StateEnum.Failed, message); } // Check translation if (payload.Person?.Gender != "male") { await TestLogic.SetStateAsync(test, StateEnum.Failed, $"Expected {nameof(Event1.Person.Gender)} to be 'male', but was '{payload.Person?.Gender}'"); } else { await TestLogic.SetStateAsync(test, StateEnum.Ok, $"Event subscribed by {Startup.ApiName}"); } }