Ejemplo n.º 1
0
        public void PostNzbDashSettingsReturnsErrorWithBadModel()
        {
            var expectedDto = new NzbDashSettingsDto {
                Id = 2, Authenticate = true
            };
            var settingsMock = new Mock <ISettingsService <NzbDashSettingsDto> >();

            settingsMock.Setup(x => x.GetSettings()).Returns(expectedDto);
            settingsMock.Setup(x => x.SaveSettings(It.IsAny <NzbDashSettingsDto>())).Returns(true).Verifiable();

            _controller = new SettingsController(null, null, null, null, null, settingsMock.Object, null, null, null, Logger);

            var model = new NzbDashSettingsViewModel();

            _controller.WithModelErrors().WithCallTo(x => x.NzbDashSettings(model)).ShouldRenderDefaultView().WithModel(model);
        }
Ejemplo n.º 2
0
        public ActionResult NzbDashSettings(NzbDashSettingsViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var dto = new NzbDashSettingsDto();

            dto.InjectFrom(model);

            var result = NzbDashServiceSettings.SaveSettings(dto);

            if (result)
            {
                return(RedirectToAction("NzbDashSettings"));
            }

            return(View("Error"));
        }