public void Execute_WhenExecuteApiTesterWithMethodThatShowException_ShouldSeeExceptionInLog() { var myApi = new MyApi(); var memoryLogger = new MemoryTestValueLogger(); var apiTester = new BreakIt(memoryLogger); apiTester.Execute(myApi, nameof(myApi.CallApiWithException), new List <object> { 1, "someName" }); StringAssert.Contains("Something is wrong", memoryLogger.LogLines[0]); }
public void Execute_WhenExecuteApiTesterWithMethodThatShowException_ShouldSeeExceptionInResult() { var myApi = new MyApi(); var memoryLogger = new MemoryTestValueLogger(); var apiTester = new BreakIt(memoryLogger); var result = apiTester.Execute(myApi, nameof(myApi.CallApiWithException), new List <object> { 1, "someName" }); Assert.IsNotNull(result[0].Exception); Assert.AreEqual("Something is wrong", result[0].Exception.Message); }
public void Execute_WhenExecuteApiTesterWithMethodThatReturnValue_ShouldBeAbleToValidateAndHaveCorrectValueInResult() { var myApi = new MyApi(); var memoryLogger = new MemoryTestValueLogger(); var options = new BreakItOptions(); options.Validation = ((testValue, o1, exception) => (int)o1 == 1); var apiTester = new BreakIt(memoryLogger); var result = apiTester.Execute(myApi, nameof(myApi.CallApiWithValidation), new List <object> { 1, "someName" }, options); Assert.IsFalse(result[0].IsSuccess); Assert.IsTrue(result[1].IsSuccess); }
public void Execute_WhenExecuteApiTesterWithMethodThatReturnValue_ShouldBeAbleToValidateAndHaveCorrectValueInLog() { var myApi = new MyApi(); var memoryLogger = new MemoryTestValueLogger(); var options = new BreakItOptions(); options.Validation = (testValue, o1, exception) => (int)o1 == 1; var apiTester = new BreakIt(memoryLogger); apiTester.Execute(myApi, nameof(myApi.CallApiWithValidation), new List <object> { 1, "someName" }, options); StringAssert.Contains("NOT OK", memoryLogger.LogLines[0]); }