Ejemplo n.º 1
0
        public void GetSettings()
        {
            var result = Service.GetSettings();

            Assert.That(result, Is.Not.Null);
            MockRepo.Verify(x => x.Get(It.IsAny <string>()), Times.Once);
        }
Ejemplo n.º 2
0
        public void SaveNewSetting()
        {
            var model  = F.Create <Setting>();
            var result = Service.SaveSettings(model);

            Assert.That(result, Is.True);
            MockRepo.Verify(x => x.Get(It.IsAny <string>()), Times.Once);
            MockRepo.Verify(x => x.Update(It.IsAny <GlobalSettings>()), Times.Once);
            MockRepo.Verify(x => x.Insert(It.IsAny <GlobalSettings>()), Times.Never);
        }
        public void GetLinks()
        {
            var result = Service.GetLinks().ToList();

            Assert.That(result, Is.Not.Null);
            Assert.That(result[0].Id, Is.EqualTo(ExpectedGetLinks[0].Id));
            Assert.That(result[0].LinkEndpoint, Is.EqualTo(ExpectedGetLinks[0].LinkEndpoint));
            Assert.That(result[0].LinkName, Is.EqualTo(ExpectedGetLinks[0].LinkName));
            MockRepo.Verify(x => x.GetAll(), Times.Once);
        }
        public void UpdateLink()
        {
            var dto = new LinksConfigurationDto {
                Id = 1, LinkEndpoint = "www.microsoft.com", LinkName = "Microsoft"
            };
            var result = Service.UpdateLink(dto);

            Assert.That(result, Is.True);
            MockRepo.Verify(x => x.Get(1), Times.Once);
            MockRepo.Verify(x => x.Update(It.IsAny <LinksConfiguration>()), Times.Once);
        }
Ejemplo n.º 5
0
        public void ModifySettings()
        {
            var dto = new SabNzbdSettingsDto {
                Id = 1
            };
            var result = Service.SaveSettings(dto);

            Assert.That(result, Is.True);
            MockRepo.Verify(x => x.Get(1), Times.Once);
            MockRepo.Verify(x => x.Insert(It.IsAny <SabNzbSettings>()), Times.Never);
            MockRepo.Verify(x => x.Update(It.IsAny <SabNzbSettings>()), Times.Once);
        }
Ejemplo n.º 6
0
        public void GetSettings()
        {
            var result = Service.GetSettings();

            Assert.That(result, Is.Not.Null);
            Assert.That(result.Enabled, Is.EqualTo(ExpectedGetLinks[0].Enabled));
            Assert.That(result.ShowOnDashboard, Is.EqualTo(ExpectedGetLinks[0].ShowOnDashboard));
            Assert.That(result.Port, Is.EqualTo(ExpectedGetLinks[0].Port));
            Assert.That(result.ApiKey, Is.EqualTo(ExpectedGetLinks[0].ApiKey));
            Assert.That(result.IpAddress, Is.EqualTo(ExpectedGetLinks[0].IpAddress));
            MockRepo.Verify(x => x.GetAll(), Times.Once);
        }
Ejemplo n.º 7
0
        public void InsertSettings()
        {
            var dto = new PlexSettingsDto {
                Id = 2
            };
            var result = Service.SaveSettings(dto);

            Assert.That(result, Is.True);
            MockRepo.Verify(x => x.Get(2), Times.Once);
            MockRepo.Verify(x => x.Insert(It.IsAny <PlexSettings>()), Times.Once);
            MockRepo.Verify(x => x.Update(It.IsAny <PlexSettings>()), Times.Never);
        }
        public void AddLink()
        {
            var dto = new LinksConfigurationDto {
                Id = 1, LinkEndpoint = "google.com", LinkName = "Google"
            };
            var result = Service.AddLink(dto);

            Assert.That(result, Is.Not.Null);
            Assert.That(result.Id, Is.EqualTo(ExpectedLink.Id));
            Assert.That(result.LinkEndpoint, Is.EqualTo(ExpectedLink.LinkEndpoint));
            Assert.That(result.LinkName, Is.EqualTo(ExpectedLink.LinkName));
            MockRepo.Verify(x => x.Insert(It.IsAny <LinksConfiguration>()), Times.Once);
        }
Ejemplo n.º 9
0
        public void GetNullSettings()
        {
            var mockRepo = new Mock <ISettingsRepository>();

            mockRepo.Setup(x => x.Get("Test")).Returns(ExpectedLink).Verifiable();
            MockRepo = mockRepo;

            Service = new SettingsService <NzbDashSettings, Setting>(MockRepo.Object, logger.Object);

            var result = Service.GetSettings();

            Assert.That(result.Id, Is.EqualTo(0));
            MockRepo.Verify(x => x.Get(It.IsAny <string>()), Times.Once);
        }
Ejemplo n.º 10
0
        public void SaveExisitingSetting()
        {
            var mockRepo = new Mock <ISettingsRepository>();

            mockRepo.Setup(x => x.Get("Test")).Returns(ExpectedLink).Verifiable();
            MockRepo = mockRepo;

            Service = new SettingsService <NzbDashSettings, Setting>(MockRepo.Object, logger.Object);


            var model  = F.Create <Setting>();
            var result = Service.SaveSettings(model);

            Assert.That(result, Is.True);
            MockRepo.Verify(x => x.Get(It.IsAny <string>()), Times.Once);
            MockRepo.Verify(x => x.Update(It.IsAny <GlobalSettings>()), Times.Never);
            MockRepo.Verify(x => x.Insert(It.IsAny <GlobalSettings>()), Times.Once);
        }
Ejemplo n.º 11
0
        public void DeleteSettingThatDoesntExist()
        {
            var model    = F.Create <Setting>();
            var mockRepo = new Mock <ISettingsRepository>();

            mockRepo.Setup(x => x.Get("Test")).Returns((GlobalSettings)null).Verifiable();
            MockRepo = mockRepo;

            Service = new SettingsService <NzbDashSettings, Setting>(MockRepo.Object, logger.Object);

            var result = Service.Delete(model);

            Assert.That(result, Is.True);
            logger.Verify(x => x.Trace(It.IsAny <string>()), Times.Once);
            MockRepo.Verify(x => x.Get(It.IsAny <string>()), Times.Once);
            MockRepo.Verify(x => x.Update(It.IsAny <GlobalSettings>()), Times.Never);
            MockRepo.Verify(x => x.Insert(It.IsAny <GlobalSettings>()), Times.Never);
            MockRepo.Verify(x => x.Delete(It.IsAny <GlobalSettings>()), Times.Never); // Null so nothing to delete
        }
Ejemplo n.º 12
0
        public async Task SaveTest()
        {
            await PictureVM.Save();

            MockRepo.Verify(mock => mock.InsertAsync(Question), Times.Once);
        }
Ejemplo n.º 13
0
 public void RemoveIncorrectLink()
 {
     Service.RemoveLink(2);
     MockRepo.Verify(x => x.Delete(It.IsAny <LinksConfiguration>()), Times.Never);
 }
Ejemplo n.º 14
0
        public void RemoveLink()
        {
            Service.RemoveLink(1);

            MockRepo.Verify(x => x.Delete(It.IsAny <LinksConfiguration>()), Times.Once);
        }