public static void DisplayItems(EventTypes eventTypes) { if (eventTypes != null && eventTypes.Any()) { foreach (var item in eventTypes) { DisplayItem(item); } } }
public void InvalidCredentials() { // List all the event types from Authorize.Net that you could subscribe to in a web hook var webHook = InitWebHook(); // ERROR TEST: Add an Invalid APILoginId webHook.ApiLoginID += "_INVALID"; EventTypes eventTypes = null; try { eventTypes = webHook.ListEventTypes(); } catch (Exception err) { common.DisplayError(err); common.DisplayResponse(webHook); Assert.Fail("Exception from WebHook; Please see the output window for more information."); } if (eventTypes != null && eventTypes.Any()) { // see if we got an error in any of the event types var errorEventType = eventTypes.FirstOrDefault(p => p.IsError == true); if (errorEventType != null) { // we got an error in at least one of the event types common.DisplayError(errorEventType.Exception); // this is a success because we are expecting an error Assert.IsTrue(true, "Received an error from Authorize.Net because of invalid credentials."); } else { // no errors, we are good: Display the eventTypes and set the test as successful. common.DisplayItems(eventTypes); Assert.IsFalse(false, "Expecting an error from Authorize.Net for invalid credentials."); } } else { Assert.Fail("Expecting multiple Event Types: Returned null/empty"); } common.DisplayResponse(webHook); }
public void ListEventTypes() { // List all the event types from Authorize.Net that you could subscribe to in a web hook var webHook = InitWebHook(); EventTypes eventTypes = null; try { eventTypes = webHook.ListEventTypes(); } catch (Exception err) { common.DisplayError(err); common.DisplayResponse(webHook); Assert.Fail("Exception from WebHook; Please see the output window for more information."); return; } if (eventTypes != null && eventTypes.Any()) { // see if we got any errors back from Authorize.Net that were not exceptions if (eventTypes.AnyError()) { foreach (var eventTypeEx in eventTypes.AllErrors()) { common.DisplayError(eventTypeEx.Exception); } } else { // no errors, we are good: Display the eventTypes and set the test as successful. common.DisplayItems(eventTypes); Assert.IsTrue(true); } } else { // We should have multiple event types Assert.Fail("Expecting multiple Event Types: Returned null/empty"); } common.DisplayResponse(webHook); }