public void SaveSettings(Settings settings)
 {
     if (settings != null)
     {
         _settingsRepository.Save(settings);
     }
 }
Exemplo n.º 2
0
 public SettingsTest()
 {
     _settings = new Settings
     {
         Id = 1,
         PostListPageSize = 5,
         PageSize = 7,
         AdminEmail = "*****@*****.**"
     };
 }
        public ActionResult Save(Settings settings)
        {
            if (ModelState.IsValid)
            {
                _settingsProvider.SaveSettings(settings);

                return RedirectToAction("Index", "Settings");
            }

            return View("Edit", settings);
        }
        public void Save(Settings settings)
        {
            Settings dbEntry = _db.Settings.Find(settings.Id);

            if (dbEntry != null)
            {
                dbEntry.PostListPageSize = settings.PostListPageSize;
                dbEntry.PageSize = settings.PageSize;
                dbEntry.AdminEmail = settings.AdminEmail;
                _db.SaveChanges();
            }
        }
Exemplo n.º 5
0
        public void Can_Save_Settings()
        {
            // Организация - создание имитированного поставщика
            Mock<ISettingsProvider> mock = new Mock<ISettingsProvider>();

            // Организация - создание контроллера
            SettingsController target = new SettingsController(mock.Object);

            Settings settings = new Settings { PostListPageSize = 7, PageSize = 5, AdminEmail = "*****@*****.**" };

            // Действие - сохраняем все настройки
            ActionResult result = target.Save(settings);

            // Утверждение - тип результата метода после успешного сохранения настроек равен RedirectToRouteResult
            Assert.IsInstanceOfType(result, typeof(RedirectToRouteResult));
        }
        public AdminCommentTests()
        {
            _comments = new List<Comment>
            {
                new Comment { Id = 1, Username = "******", Text = "Comment 1", CreateDate = DateTime.Now, IsApproved = false, PostId = 1 },
                new Comment { Id = 2, Username = "******", Text = "Comment 2", CreateDate = DateTime.Now.AddMinutes(1), IsApproved = false, PostId = 1 },
                new Comment { Id = 3, Username = "******", Text = "Comment 3", CreateDate = DateTime.Now.AddMinutes(2), IsApproved = false, PostId = 1 },
                new Comment { Id = 4, Username = "******", Text = "Comment 4", CreateDate = DateTime.Now.AddMinutes(3), IsApproved = true, PostId = 1 },
                new Comment { Id = 5, Username = "******", Text = "Comment 5", CreateDate = DateTime.Now.AddMinutes(4), IsApproved = true, PostId = 1 }
            };

            _settings = new Settings
            {
                Id = 1,
                PageSize = 5,
                PostListPageSize = 5,
                AdminEmail = "*****@*****.**"
            };
        }
Exemplo n.º 7
0
        public PostsTests()
        {
            _posts = new List<Post>
            {
                new Post { Id = 1, Title = "Title 1", IntroText = "Intro Text 1", MainText = "Main Text 1", CreateDate = DateTime.Now, IsPublished = true, Tags = null },
                new Post { Id = 2, Title = "Title 2", IntroText = "Intro Text 2", MainText = "Main Text 2", CreateDate = DateTime.Now, IsPublished = true, Tags = null },
                new Post { Id = 3, Title = "Title 3", IntroText = "Intro Text 3", MainText = "Main Text 3", CreateDate = DateTime.Now, IsPublished = false, Tags = null },
                new Post { Id = 4, Title = "Title 4", IntroText = "Intro Text 4", MainText = "Main Text 4", CreateDate = DateTime.Now, IsPublished = true, Tags = null },
                new Post { Id = 5, Title = "Title 5", IntroText = "Intro Text 5", MainText = "Main Text 5", CreateDate = DateTime.Now, IsPublished = true, Tags = null },
            };

            _settings = new Settings
            {
                Id = 1,
                PageSize = 5,
                PostListPageSize = 5,
                AdminEmail = "*****@*****.**"
            };

            // Организация - создание имитированного поставщика настроек
            _mockSettingsProvider = new Mock<ISettingsProvider>();
        }