Inheritance: BaseSettingsDto
Esempio n. 1
0
        public void PostSabNzbdSettingsReturnsDefaultView()
        {
            var expectedDto = new SabNzbdSettingsDto { Enabled = true, Id = 2, IpAddress = "192", ApiKey = "pass", Port = 2, ShowOnDashboard = true };
            var settingsMock = new Mock<ISettingsService<SabNzbdSettingsDto>>();

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

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

            var model = new SabNzbSettingsViewModel();
            _controller.WithCallTo(x => x.SabNzbSettings(model)).ShouldRedirectTo(c => c.SabNzbSettings);
            settingsMock.Verify(x => x.SaveSettings(It.IsAny<SabNzbdSettingsDto>()), Times.Once);
        }
Esempio n. 2
0
        public void GetSabNzbdSettings()
        {
            var expectedDto = new SabNzbdSettingsDto { Enabled = true, Id = 2, IpAddress = "192", ApiKey = "pass", Port = 2, ShowOnDashboard = true };
            var settingsMock = new Mock<ISettingsService<SabNzbdSettingsDto>>();

            settingsMock.Setup(x => x.GetSettings()).Returns(expectedDto).Verifiable();

            _controller = new SettingsController(null, settingsMock.Object, null, null, null, null, null, null, null, Logger);
            _controller.WithCallTo(x => x.SabNzbSettings()).ShouldRenderDefaultView();

            var result = (ViewResult)_controller.SabNzbSettings();
            var model = (SabNzbSettingsViewModel)result.Model;

            Assert.That(model.Enabled, Is.EqualTo(expectedDto.Enabled));
            Assert.That(model.Id, Is.EqualTo(expectedDto.Id));
            Assert.That(model.IpAddress, Is.EqualTo(expectedDto.IpAddress));
            Assert.That(model.ApiKey, Is.EqualTo(expectedDto.ApiKey));
            Assert.That(model.Port, Is.EqualTo(expectedDto.Port));
            Assert.That(model.ShowOnDashboard, Is.EqualTo(expectedDto.ShowOnDashboard));
        }