Esempio n. 1
0
        public void SetUp()
        {
            var mockRepo = new Mock <ISqlRepository <SabNzbSettings> >();

            ExpectedLink = new SabNzbSettings
            {
                Id              = 1,
                Enabled         = true,
                IpAddress       = "192",
                Port            = 25,
                ShowOnDashboard = true,
                ApiKey          = "abc"
            };
            ExpectedGetLinks = new List <SabNzbSettings>
            {
                ExpectedLink,
            };


            mockRepo.Setup(x => x.GetAll()).Returns(ExpectedGetLinks).Verifiable();

            mockRepo.Setup(x => x.Get(1)).Returns(ExpectedLink).Verifiable();

            mockRepo.Setup(x => x.Update(It.IsAny <SabNzbSettings>())).Returns(true).Verifiable();
            mockRepo.Setup(x => x.Insert(It.IsAny <SabNzbSettings>())).Returns(1).Verifiable();


            MockRepo = mockRepo;
            Service  = new SabNzbSettingsService(MockRepo.Object);
        }
Esempio n. 2
0
        public bool SaveSettings(SabNzbdSettingsDto model)
        {
            var entity = Repo.Get(model.Id);

            if (entity == null)
            {
                var newEntity = new SabNzbSettings();
                newEntity.InjectFrom(model);

                var insertResult = Repo.Insert(newEntity);
                return(insertResult != long.MinValue);
            }

            entity.Enabled         = model.Enabled;
            entity.IpAddress       = model.IpAddress;
            entity.Port            = model.Port;
            entity.ApiKey          = model.ApiKey;
            entity.Id              = model.Id;
            entity.ShowOnDashboard = model.ShowOnDashboard;

            var result = Repo.Update(entity);

            return(result);
        }