public async Task TestWriteTaskCancelledException() { // ARRANGE HttpClient Client = new HttpClient() { Timeout = TimeSpan.FromMilliseconds(500) }; TestLambdaLogger TestLogger = new TestLambdaLogger(); TestClientContext ClientContext = new TestClientContext(); ILambdaContext Context = new TestLambdaContext() { FunctionName = "Common", FunctionVersion = "1", Logger = TestLogger, ClientContext = ClientContext }; // ACT try { HttpRequestMessage Request = new HttpRequestMessage(HttpMethod.Head, "http://github.com"); HttpResponseMessage Res = await Client.SendAsync(Request); } catch (TaskCanceledException ex) { Context.LogError(ex); } // ASSERT Assert.True(true); }
public void TestWriteException() { // ARRANGE TestLambdaLogger TestLogger = new TestLambdaLogger(); TestClientContext ClientContext = new TestClientContext(); ILambdaContext Context = new TestLambdaContext() { FunctionName = "Common", FunctionVersion = "1", Logger = TestLogger, ClientContext = ClientContext }; // ACT try { int Num = 0; int Result = 100 / Num; } catch (Exception ex) { Context.LogError(ex); } // ASSERT Assert.True(true); }
public void TestWriteAggregateException() { // ARRANGE TestLambdaLogger TestLogger = new TestLambdaLogger(); TestClientContext ClientContext = new TestClientContext(); ILambdaContext Context = new TestLambdaContext() { FunctionName = "Common", FunctionVersion = "1", Logger = TestLogger, ClientContext = ClientContext }; // ACT try { Task T = Task.Factory.StartNew(() => { int Num = 0; int Result = 100 / Num; }); T.Wait(); } catch (AggregateException ex) { Context.LogError(ex); } // ASSERT Assert.True(true); }
public void TestWriteError() { // ARRANGE TestLambdaLogger TestLogger = new TestLambdaLogger(); TestClientContext ClientContext = new TestClientContext(); ILambdaContext Context = new TestLambdaContext() { FunctionName = "Common", FunctionVersion = "1", Logger = TestLogger, ClientContext = ClientContext }; // ACT Context.LogError("This is an error message"); // ASSERT Assert.True(true); }
public void TestWriteErrorAndException() { // ARRANGE TestLambdaLogger TestLogger = new TestLambdaLogger(); TestClientContext ClientContext = new TestClientContext(); ILambdaContext Context = new TestLambdaContext() { FunctionName = "Common", FunctionVersion = "1", Logger = TestLogger, ClientContext = ClientContext }; // ACT Context.LogError("This is an error message", new Exception("This is bad", new FormatException("Poorly formatted", new IndexOutOfRangeException("Not in range")))); // ASSERT Assert.True(true); }