Exemple #1
0
        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);
        }
Exemple #2
0
        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);
        }
Exemple #3
0
        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);
        }
Exemple #4
0
        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);
        }
Exemple #5
0
        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);
        }