public async Task UndeleteCallFiresRecalcs() { var forum = new Forum { ForumID = 5 }; var topic = new Topic { TopicID = 4, ForumID = forum.ForumID }; var service = GetService(); var user = new User { UserID = 123, Roles = new List <string> { PermanentRoles.Moderator } }; var post = new Post { PostID = 67, TopicID = topic.TopicID }; _topicService.Setup(t => t.Get(topic.TopicID)).ReturnsAsync(topic); _forumService.Setup(f => f.Get(forum.ForumID)).ReturnsAsync(forum); var payload = new SearchIndexPayload(); _searchIndexQueue.Setup(x => x.Enqueue(It.IsAny <SearchIndexPayload>())).Callback <SearchIndexPayload>(p => payload = p); await service.Undelete(post, user); _topicService.Verify(t => t.RecalculateReplyCount(topic), Times.Exactly(1)); _topicService.Verify(t => t.UpdateLast(topic), Times.Once()); _forumService.Verify(f => f.UpdateCounts(forum), Times.Exactly(1)); _forumService.Verify(f => f.UpdateLast(forum), Times.Exactly(1)); _searchIndexQueue.Verify(x => x.Enqueue(payload), Times.Once); Assert.Equal(topic.TopicID, payload.TopicID); }
public void Enqueue(SearchIndexPayload payload) { var serializedPayload = JsonConvert.SerializeObject(payload); _sqlObjectFactory.GetConnection().Using(connection => connection.Execute("INSERT INTO pf_SearchQueue (Payload) VALUES (@Payload)", new { Payload = serializedPayload })); }
public async Task UndeleteQueuesReindex() { var topic = new Topic { TopicID = 1, ForumID = 123 }; var user = GetUser(); user.Roles.Add(PermanentRoles.Moderator); var topicService = GetTopicService(); var forum = new Forum { ForumID = topic.ForumID }; _forumService.Setup(f => f.Get(topic.ForumID)).ReturnsAsync(forum); SearchIndexPayload payload = null; _searchIndexQueueRepo.Setup(x => x.Enqueue(It.IsAny <SearchIndexPayload>())).Callback <SearchIndexPayload>(x => payload = x); _tenantService.Setup(x => x.GetTenant()).Returns("t"); await topicService.UndeleteTopic(topic, user); Assert.Equal(topic.TopicID, payload.TopicID); Assert.Equal("t", payload.TenantID); Assert.False(payload.IsForRemoval); }
public void Enqueue(SearchIndexPayload payload) { var serializedPayload = JsonConvert.SerializeObject(payload); var message = new CloudQueueMessage(serializedPayload); var queue = GetQueue().Result; queue.AddMessageAsync(message); }
public async Task Enqueue(SearchIndexPayload payload) { var serializedPayload = JsonConvert.SerializeObject(payload); var message = new CloudQueueMessage(serializedPayload); var queue = await GetQueue(); await queue.AddMessageAsync(message); }
public async Task HardDeleteCallsSearchIndexRepo() { var user = new User { UserID = 123, Roles = new List <string> { "Admin" } }; var topic = new Topic { TopicID = 45 }; var service = GetTopicService(); SearchIndexPayload payload = null; _searchIndexQueueRepo.Setup(x => x.Enqueue(It.IsAny <SearchIndexPayload>())).Callback <SearchIndexPayload>(x => payload = x); _tenantService.Setup(x => x.GetTenant()).Returns("t"); await service.HardDeleteTopic(topic, user); _searchIndexQueueRepo.Verify(x => x.Enqueue(It.IsAny <SearchIndexPayload>()), Times.Once); Assert.Equal(topic.TopicID, payload.TopicID); Assert.Equal("t", payload.TenantID); Assert.True(payload.IsForRemoval); }
public async Task Enqueue(SearchIndexPayload payload) { var serializedPayload = JsonSerializer.Serialize(payload); await _sqlObjectFactory.GetConnection().UsingAsync(connection => connection.ExecuteAsync("INSERT INTO pf_SearchQueue (Payload) VALUES (@Payload)", new { Payload = serializedPayload })); }