Пример #1
0
        public void ShouldReturnErrorCodeInCaseOfException()
        {
            IErraticService  erraticServiceTest  = new ErraticServiceImpl();
            ExceptionService stubService         = new ExceptionService();
            RandomError      randomError         = erraticServiceTest.Execute(stubService);
            RandomException  lastExceptionThrown = stubService.GetLastExceptionThrown();

            Assert.Equals(lastExceptionThrown.GetError().GetCode(), randomError.GetCode());
        }
Пример #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);
        }