Esempio n. 1
0
        public void Error_ReturnsNonFatal_OnServiceException()
        {
            var target     = new LaunchPad();
            var mockLogger = new MockLogger();
            var output     = new ServiceOperationException(ServiceOperationError.BadParameter, "Yuba bears");
            var result     = LaunchPad.Error(output, mockLogger);

            AssertEx.AreEqual(HttpStatusCode.BadRequest, result.StatusCode);
            AssertEx.AreEqual(1, mockLogger.Logs.Count);

            var stuff = JsonConvert.DeserializeObject <TestResponse>(
                result.Content.ReadAsStringAsync().Result);

            AssertEx.AreEqual(0, stuff.Count);
            AssertEx.AreEqual(new string[0], stuff.Values);
            AssertEx.AreEqual(ServiceOperationError.BadParameter.ToString(), stuff.ErrorCode);
            AssertEx.StartsWith("Yuba bears\r\nThe Log Key for this error is", stuff.ErrorMessage);
        }
Esempio n. 2
0
        public void Error_ReturnsFatal_OnNormalException()
        {
            var target     = new LaunchPad();
            var mockLogger = new MockLogger();
            var output     = new RandomException("Bumper Boats", "Abba\\Dabba\\foobar:line 232\r\nShoe\\Lollipop\\gumby:line 444");
            var result     = LaunchPad.Error(output, mockLogger);

            AssertEx.AreEqual(HttpStatusCode.InternalServerError, result.StatusCode);
            AssertEx.AreEqual(1, mockLogger.Logs.Count);

            var stuff = JsonConvert.DeserializeObject <TestResponse>(
                result.Content.ReadAsStringAsync().Result);

            AssertEx.AreEqual(0, stuff.Count);
            AssertEx.AreEqual(new string[0], stuff.Values);
            AssertEx.AreEqual(ServiceOperationError.FatalError.ToString(), stuff.ErrorCode);
            AssertEx.StartsWith("There was a fatal service error.\r\nThe Log Key for this error is", stuff.ErrorMessage);
            AssertEx.EndsWith("Debug hint: Bumper Boats (foobar:line 232)", stuff.ErrorMessage);
        }