Exemplo n.º 1
0
        public void Post_Error()
        {
            // Arrange
            var context = new TestCaseContext();
            var sut     = new LocaleController(
                context.Logger,
                context.SessionManager);

            var locale = "ru-ru";

            Mock.Get(context.Session.LocaleManager).Setup(
                m => m.GetLocale())
            .Throws(new Exception("message"));

            var request = ApiRequest <SetLocaleRequest> .Make(new SetLocaleRequest { Locale = locale });

            // Act
            var actionResult = sut.Post(context.Session.Id, request);

            // Assert
            Assert.NotNull(actionResult);
            var objectResult = actionResult.Result as ObjectResult;

            Assert.NotNull(objectResult);
            Assert.Equal(500, objectResult.StatusCode);
            var result = objectResult.Value as ApiResponse <GetLocaleResponse>;

            Assert.NotNull(result);
            Assert.False(result.Success);
            Assert.NotNull(result.Error);
            Assert.Null(result.Payload);
        }