public async Task Process_MethodThrows_ReturnsTestResult() { await RunDependencyInjectedTestAsync ( async (serviceProvider) => { // Arrange var exampleTestClass = new ExampleTestClass(); var expectedMethodInfos = exampleTestClass .GetType() .GetMethods(BindingFlags.Public | BindingFlags.Instance) .Where(e => e.DeclaringType.Name == exampleTestClass.GetType().Name); var test = new Models.TestAutomation.Test() { MethodInfo = expectedMethodInfos.Last(), TestClass = exampleTestClass }; var uut = serviceProvider.GetRequiredService <IIntegrationTestService>(); var uutConcrete = (IntegrationTestService)uut; // Act var observed = await uutConcrete.Process(test.TestClass, test).ConfigureAwait(false); // Assert Assert.IsNotNull(observed); Assert.AreEqual(test.MethodInfo.ReflectedType.Name, observed.ClassName); Assert.IsNotNull(observed.CorrelationId); Assert.IsNotNull(observed.Duration); Assert.IsNotNull(observed.EndTime); Assert.IsNotNull(observed.Exception); Assert.IsNotNull(observed.ExecutionId); Assert.IsFalse(observed.Pass); Assert.IsNotNull(observed.StartTime); Assert.AreEqual(1, observed.SuccessLog.Count()); Assert.IsNotNull(observed.TestId); Assert.IsNotNull(test.MethodInfo.Name, observed.TestName); Assert.IsNotNull(observed.TestType); }, serviceCollection => ConfigureServices(serviceCollection) ); }
public async Task Process_MethodRuns_ReturnsTestResult() { await RunDependencyInjectedTestAsync ( async (serviceProvider) => { // Arrange var exampleTestClass = new ExampleTestClass(); var expectedMethodInfos = exampleTestClass .GetType() .GetMethods(BindingFlags.Public | BindingFlags.Instance) .Where ( methodInfo => methodInfo.GetParameters().Length == 1 && methodInfo.GetParameters()[0].Name == IntegrationTestService.SUCCESSLOG_PRAM_NAME && methodInfo.GetParameters()[0].ParameterType == typeof(List <string>) && methodInfo.ReturnType == typeof(Task) ); var test = new Models.TestAutomation.Test() { MethodInfo = expectedMethodInfos.First(), TestClass = exampleTestClass }; var uut = serviceProvider.GetRequiredService <IIntegrationTestService>(); var uutConcrete = (IntegrationTestService)uut; // Act var observed = await uutConcrete.Process(test.TestClass, test).ConfigureAwait(false); // Assert Assert.IsNotNull(observed); Assert.IsNull(observed.TestGroup); Assert.AreEqual(test.MethodInfo.ReflectedType.Name, observed.ClassName); Assert.IsNotNull(observed.CorrelationId); Assert.IsNotNull(observed.Duration); Assert.IsNotNull(observed.EndTime); Assert.IsNull(observed.Exception); Assert.IsNotNull(observed.ExecutionId); Assert.IsTrue(observed.Pass); Assert.IsNotNull(observed.StartTime); Assert.AreEqual(1, observed.SuccessLog.Count()); Assert.IsNotNull(observed.TestId); Assert.IsNotNull(test.MethodInfo.Name, observed.TestName); Assert.IsNotNull(observed.TestType); }, serviceCollection => ConfigureServices(serviceCollection) ); }