Exemplo n.º 1
0
        public void PostCouchPotatoSettingsReturnsDefaultView()
        {
            var expectedDto = new CouchPotatoSettingsDto
            {
                Enabled = true,
                Id = 2,
                IpAddress = "192",
                ApiKey = "pass",
                Port = 2,
                ShowOnDashboard = true,
                Password = "******",
                Username = "******"
            };
            var settingsMock = new Mock<ISettingsService<CouchPotatoSettingsDto>>();

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

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

            var model = new CouchPotatoSettingsViewModel();
            _controller.WithCallTo(x => x.CouchPotatoSettings(model)).ShouldRedirectTo(c => c.CouchPotatoSettings);
            settingsMock.Verify(x => x.SaveSettings(It.IsAny<CouchPotatoSettingsDto>()), Times.Once);
        }
Exemplo n.º 2
0
        public void GetCouchPotatoSettings()
        {
            var expectedDto = new CouchPotatoSettingsDto
            {
                Enabled = true,
                Id = 2,
                IpAddress = "192",
                ApiKey = "pass",
                Port = 2,
                ShowOnDashboard = true,
                Password = "******",
                Username = "******"
            };
            var settingsMock = new Mock<ISettingsService<CouchPotatoSettingsDto>>();

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

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

            var result = (ViewResult)_controller.CouchPotatoSettings();
            var model = (CouchPotatoSettingsViewModel)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));
            Assert.That(model.Username, Is.EqualTo(expectedDto.Username));
            Assert.That(model.Password, Is.EqualTo(expectedDto.Password));
        }
Exemplo n.º 3
0
        public void PostCouchPotatoSettingsCouldNotSaveToDb()
        {
            var expectedDto = new CouchPotatoSettingsDto { Enabled = true, Id = 2, IpAddress = "192", ApiKey = "pass", Port = 2, ShowOnDashboard = true };
            var settingsMock = new Mock<ISettingsService<CouchPotatoSettingsDto>>();

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

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

            var model = new CouchPotatoSettingsViewModel();
            _controller.WithCallTo(x => x.CouchPotatoSettings(model)).ShouldRenderView("Error");
            settingsMock.Verify(x => x.SaveSettings(It.IsAny<CouchPotatoSettingsDto>()), Times.Once);
        }