public async Task ExecuteContructor(DefaultExecutionSetup sut) { // Arrange MethodData methodData = GetMethodData( typeof(DefaultExecutionSetupShould).GetConstructor(Type.EmptyTypes), sut, new DefaultExecutionSetupShould()); // Act await methodData.ExecuteAction().ConfigureAwait(false); }
public async Task ExecuteSynchronousMethod(DefaultExecutionSetup sut) { // Arrange bool executed = false; Action action = () => { executed = true; }; MethodData methodData = GetMethodData(action.GetMethodInfo(), sut, action.Target); // Act await methodData.ExecuteAction().ConfigureAwait(false); Assert.True(executed); }
private async Task AssertExecutionThrows <T>(MethodData methodData) where T : Exception { // Act // This should never throw but always return a task, either completed or faulted. Task executeAction = methodData.ExecuteAction(); // Assert try { await executeAction.ConfigureAwait(false); } catch (T) { return; } Assert.Throws <T>(() => { }); }