public void CreateNewCategory() { var category = new NewCategory { Name = "API Test " + Guid.NewGuid(), Color = "FFA500", TextColor = "FFFFFF", }; var response = _api.CreateCategory(category); Assert.IsNotNull(response); }
public void TestCategory() { var category = new NewCategory { AllowBadges = true, AutoCloseBasedOnLastPost = true, AutoCloseHours = 3, Color = "FFFFFF", Name = "test", TextColor = "ffff" }; category.AddOrUpdatePermission("everyone", Permission.CreateReplySee); category.AddOrUpdatePermission("trust_level_0", Permission.See); var actual = JsonConvert.SerializeObject(category); var expected = "{\"name\":\"test\",\"color\":\"FFFFFF\",\"text_color\":\"ffff\",\"permissions\":{\"everyone\":1,\"trust_level_0\":3},\"auto_close_hours\":3,\"auto_close_based_on_last_post\":true,\"allow_badges\":true}"; Assert.AreEqual(expected, actual); }
private Category CreateCategory(int? parentId, string name = "API Test Category") { var category = new NewCategory { Name = name + Guid.NewGuid().ToString().Substring(0, 25), Color = "FFA500", TextColor = "FFFFFF", ParentCategoryID = parentId }; return _api.CreateCategory(category); }
public static Category CreateCategory(this DiscourseApi api, NewCategory newCategory, string username = DefaultUsername) { var response = api.ExecuteRequest<CreatedCategory>("/categories", Method.POST, true, username, null, newCategory); return response == null ? null : response.Category; }