public async Task CreateNewUser_Basic() { var userId = await service.CreateNewUser("hello", "short", "*****@*****.**"); var user = await searcher.GetById <UserView>(userId); AssertDateClose(user.createDate); Assert.True(user.id > 0); Assert.False(user.registered); Assert.Equal("hello", user.username); Assert.Equal(UserType.user, user.type); }
public async Task SubcommandArguments_User() { //The subcommands variable exists but is the wrong type, the module system shouldn't care var modview = new ContentView() { name = "test", text = @" subcommands = {[""wow""]={[""arguments""]={""first_user"",""second_user""}} } function command_wow(uid, user1, user2) return ""Id: "" .. uid .. "" User1: "" .. user1 .. "" User2: "" .. user2 end" }; //Fragile test, should inject a fake user service that always says the user is good. oh well var user1 = await searcher.GetById <UserView>(RequestType.user, (int)UserVariations.Super); var user2 = await searcher.GetById <UserView>(RequestType.user, 1 + (int)UserVariations.Super); //userService.WriteAsync(new UserViewFull() { username = "******"}, new Requester() { system = true }).Wait(); //userService.WriteAsync(new UserViewFull() { username = "******"}, new Requester() { system = true }).Wait(); var mod = service.UpdateModule(modview); var result = service.RunCommand("test", $"wow {user1.id} {user2.id}(lol_username!)", 8); Assert.Equal($"Id: 8 User1: {user1.id} User2: {user2.id}", result); }
[InlineData(5, 2)] //This one SHOULD have a parent public async Task GetSearchRequestForEvents_Activity(long contentId, int skip) { var content = await searcher.GetById <ContentView>(RequestType.content, contentId); var activities = await GetActivityForContentAsync(contentId); Assert.True(activities.Count > 1); //It should be greater than 1 for content 1, because of inverse activity amounts for (var i = 0; i < activities.Count; i += skip) { var activitySlice = activities.Skip(i).Take(skip); var events = activitySlice.Select(x => new LiveEvent(x.userId, UserAction.create, EventType.activity_event, x.id)); //The event user shouldn't matter but just in case... var request = queue.GetSearchRequestsForEvents(events); //new[] { new LiveEvent(a.userId, Db.UserAction.create, EventType.activity_event, a.id) }); var result = await searcher.SearchUnrestricted(request); foreach (var a in activitySlice) { AssertSimpleActivityListenResult(result.objects, content, a); } } }
public async Task UpdatedUserYesLogin() { var userId = await service.CreateNewUser("hello", Password, "*****@*****.**"); var token = await service.CompleteRegistration(userId, await service.GetRegistrationKeyAsync(userId)); var loginToken = await service.LoginUsernameAsync("hello", Password); Assert.False(string.IsNullOrWhiteSpace(token)); Assert.False(string.IsNullOrWhiteSpace(loginToken)); var user = await searcher.GetById <UserView>(userId); //Login worked, now update the user's special field or something and ensure nothing exploded. user.special = "seomthingNEWW"; var updateResult = await writer.WriteAsync(user, user.id); loginToken = await service.LoginUsernameAsync("hello", Password); Assert.False(string.IsNullOrWhiteSpace(loginToken)); //login should still work even though they changed something about them //You should also still be able to login with your email loginToken = await service.LoginEmailAsync("*****@*****.**", Password); Assert.False(string.IsNullOrWhiteSpace(loginToken)); //login should still work even though they changed something about them }
public async Task Regression_SearchValuesForPinned() { //Write a comment to a known content var comment = GetNewCommentView(AllAccessContentId); var writtenComment = await writer.WriteAsync(comment, NormalUserId); //Now update said content to have more values var content = await searcher.GetById <ContentView>(AllAccessContentId); content.values.Add("pinned", new List <long> { writtenComment.id }); var writtenContent = await writer.WriteAsync(content, NormalUserId); //Then construct a search for content and comments such that the comments are in the values var search = new SearchRequests() { values = new Dictionary <string, object> { }, requests = new List <SearchRequest>() { //This searches ALL content, many of which will NOT have the pinned new SearchRequest() { type = nameof(RequestType.content), fields = "*" }, new SearchRequest() { type = nameof(RequestType.message), fields = "*", query = "id in @content.values.pinned" } } }; var searchResult = await searcher.SearchUnrestricted(search); var searchMessages = searcher.ToStronglyTyped <MessageView>(searchResult.objects[nameof(RequestType.message)]); var searchContent = searcher.ToStronglyTyped <MessageView>(searchResult.objects[nameof(RequestType.content)]); Assert.Contains(writtenComment.id, searchMessages.Select(x => x.id)); Assert.Contains(AllAccessContentId, searchContent.Select(x => x.id)); }