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); }
public ActionResult SabNzbSettings(SabNzbSettingsViewModel viewModel) { if (!ModelState.IsValid) { return(View(viewModel)); } var dto = new SabNzbdSettingsDto(); dto.InjectFrom(viewModel); var result = SabNzbSettingsService.SaveSettings(dto); if (result) { return(RedirectToAction("SabNzbSettings")); } return(View("Error")); }