public async Task <Test> AuthenticatePlatformClient(Test parent) { var test = await TestLogic.CreateAsync("AuthenticatePlatformClient", parent); try { FulcrumApplication.Context.CorrelationId = test.Id; var result = await _apiRestClient.CreateToken(_platformSettings.ClientId, _platformSettings.ClientSecret); if (string.IsNullOrWhiteSpace(result?.AccessToken)) { await TestLogic.SetStateAsync(test, StateEnum.Failed, $"Could not authenticate client '{_platformSettings.ClientId}"); } else { await TestLogic.SetStateAsync(test, StateEnum.Ok, "Ok"); } } catch (Exception e) { await TestLogic.SetStateAsync(test, StateEnum.Failed, e.Message); } return(test); }
public async Task <Test> OrderCreatedEvent(Test parent) { var test = await TestLogic.CreateAsync("OrderCreatedEvent", parent); var createTest = await TestLogic.CreateAsync("Create", test); var eventTest = await TestLogic.CreateAsync("Event", test); try { FulcrumApplication.Context.CorrelationId = eventTest.Id; var order = await _restclient.CreateOrder(new MockOrder { Id = "1", Items = 3 }); if (order?.Id == null) { throw new Exception("No Order was created"); } createTest.Properties = new Dictionary <string, object> { { "Order", order } }; await TestLogic.UpdateAsync(createTest); await TestLogic.SetStateAsync(createTest, StateEnum.Ok, "Order created"); } catch (Exception e) { await TestLogic.SetStateAsync(test, StateEnum.Failed, e.Message); } // Note! We leave the state as Waiting and set to Ok once the event is intercepted in IntegrationApiController return(test); }
public async Task <Test> Test2(Test parent) { var test = await TestLogic.CreateAsync("Capability Y Test 2", parent); // TODO: Do test and update state await TestLogic.SetStateAsync(test, StateEnum.Ok, "Done"); return(test); }
public async Task <Test> RunAllAsync(Test parent = null) { var container = await TestLogic.CreateAsync("Platform translations configuration tests", parent); await RunTestablesSkippingRunAllAsync(container, new List <ControllerBase> { this }); return(container); }
public async Task <Test> RunAllAsync(Test parent = null) { var container = await TestLogic.CreateAsync("Capability 2 contract tests", parent); await RunTestablesSkippingRunAllAsync(container, new List <ControllerBase> { this }); return(container); }
public async Task <Test> EnumTranslation(Test parent) { var test = await TestLogic.CreateAsync("EnumTranslation", parent); var cap1Test = await TestLogic.CreateAsync("Capability 1", test); var cap2Test = await TestLogic.CreateAsync("Capability 2", test); try { // Create order as capability 1 client var createdOrder = await _bapiClientAsCapability1Client.CreateOrder(3, "Created"); cap1Test.Properties = new Dictionary <string, object> { { "Order", createdOrder } }; await TestLogic.UpdateAsync(cap1Test); if (createdOrder.Status != "Created") { await TestLogic.SetStateAsync(cap1Test, StateEnum.Failed, "Expected Order.Status to be 'Created'"); } else { await TestLogic.SetStateAsync(cap1Test, StateEnum.Ok, "Ok"); } // Fetch order as capability 2 client var order = await _bapiClientAsCapability2Client.GetOrder(createdOrder.Id); cap2Test.Properties = new Dictionary <string, object> { { "Order", order } }; await TestLogic.UpdateAsync(cap2Test); if (order.Status != "New") { await TestLogic.SetStateAsync(cap2Test, StateEnum.Failed, "Expected Order.Status to be 'New'"); } else { await TestLogic.SetStateAsync(cap2Test, StateEnum.Ok, "Ok"); } } catch (Exception e) { await TestLogic.SetStateAsync(test, StateEnum.Failed, e.Message); } return(test); }
public async Task <Test> CreatePerson(Test parent) { var test = await TestLogic.CreateAsync("CrudPerson", parent); try { // Create var person = await _restclient.CreatePerson(new MockPerson { Name = "Raginaharjar" }); if (person?.Id == null) { throw new Exception("No Person was created"); } var personId = person.Id; test.Properties = new Dictionary <string, object> { { "Person", person } }; await TestLogic.UpdateAsync(test); // Read person = await _restclient.GetPerson(personId); if (person?.Id == null) { throw new Exception($"Person {personId} could not be found"); } // TODO: Update // Delete await _restclient.DeletePerson(personId); person = await _restclient.GetPerson(personId); if (person != null) { throw new Exception($"Person {personId} should be deleted"); } // All ok! await TestLogic.SetStateAsync(test, StateEnum.Ok, "ok"); } catch (Exception e) { await TestLogic.SetStateAsync(test, StateEnum.Failed, e.Message); } return(test); }
private async Task <Test> RunTopLevelTestAsync(Test parent, string group) { var container = await TestLogic.CreateAsync(group, parent); try { var testables = FindTestables(group); await RunTestablesOnlyRunAllAsync(container, testables); } catch (Exception e) { await TestLogic.SetStateAsync(container, StateEnum.Failed, e.Message); } return(container); }