コード例 #1
0
        public void SetUp()
        {
            var mockRepo = new Mock <ISqlRepository <PlexSettings> >();

            ExpectedLink = new PlexSettings
            {
                Id              = 1,
                Enabled         = true,
                IpAddress       = "192",
                Password        = "******",
                Port            = 25,
                Username        = "******",
                ShowOnDashboard = true
            };
            ExpectedGetLinks = new List <PlexSettings>
            {
                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 <PlexSettings>())).Returns(true).Verifiable();

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


            MockRepo = mockRepo;
            Service  = new PlexSettingsService(MockRepo.Object);
        }
コード例 #2
0
        public ActionResult PlexSettings(PlexSettingsViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(viewModel));
            }

            var dto = new PlexSettingsDto();

            dto.InjectFrom(viewModel);

            var result = PlexSettingsService.SaveSettings(dto);

            if (result)
            {
                return(RedirectToAction("PlexSettings"));
            }

            return(View("Error"));
        }