public async Task CreateSet_Test() { var userName = "******"; var user = TestHelper.SetPrincipal(userName); var set = new Set() { Name = "HolyHell", Title = "Some Title", Type = SetType.Normal, UserName = userName }; var cmd = new UpdateSetCommand(set).SetUserContext(user); var result = await cmd.Execute(); VoatAssert.IsValid(result); Assert.AreNotEqual(0, result.Response.ID); var setID = result.Response.ID; VerifySubscriber(set, userName, 1); //Subscribe another user userName = "******"; user = TestHelper.SetPrincipal(userName); var subCmd = new SubscribeCommand(new DomainReference(DomainType.Set, set.Name, set.UserName), SubscriptionAction.Subscribe).SetUserContext(user); var subResult = await subCmd.Execute(); VoatAssert.IsValid(result); VerifySubscriber(set, userName, 2); //unsub user subCmd = new SubscribeCommand(new DomainReference(DomainType.Set, set.Name, set.UserName), SubscriptionAction.Unsubscribe).SetUserContext(user); subResult = await subCmd.Execute(); VoatAssert.IsValid(result); VerifySubscriber(set, userName, 1, false); }
public async Task CreateSet_Test_UnicodeName() { var userName = "******"; var user = TestHelper.SetPrincipal(userName); var set = new Set() { Name = "ÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ", Title = "Some Title", Type = SetType.Normal, UserName = userName }; var cmd = new UpdateSetCommand(set); var result = await cmd.Execute(); Assert.IsFalse(result.Success, result.Message); }
public async Task CreateSet_Test_ReservedName_SortAlgorithm() { var userName = "******"; var user = TestHelper.SetPrincipal(userName); var set = new Set() { Name = SortAlgorithm.Hot.ToString(), Title = "Some Title", Type = SetType.Normal, UserName = userName }; var cmd = new UpdateSetCommand(set); var result = await cmd.Execute(); Assert.IsFalse(result.Success, result.Message); }
public async Task <ActionResult> Update(Set set) { if (ModelState.IsValid) { var cmd = new UpdateSetCommand(set).SetUserContext(User); var result = await cmd.Execute(); return(JsonResult(result)); } else { return(JsonResult(CommandResponse.FromStatus(Status.Invalid, ModelState.GetFirstErrorMessage()))); } }