public async Task GetOldMessagesAsync_Test()
        {
            //Arrage:
            await InitDictDataAsync();

            var service = new ConversationMsgAppService(statefulServiceContext, stateManager);
            var msg2    = DefaultConversationMsg2.DeepCopy();
            var msg1    = DefaultConversationMsg.DeepCopy();

            //Act:
            var oldMeesage = await service.GetOldMessagesAsync(new GetOldMessagesInput()
            {
                Id          = msg2.ConversationId,
                OldestMsgId = msg2.Id,
            });

            //Assert:
            Assert.AreEqual(1, oldMeesage.Count);
        }
Ejemplo n.º 2
0
        protected async Task InitDictDataAsync()
        {
            await InitDictAsync();

            var conversation = DefaultConversation.DeepCopy(); //need deep copy
            var message1     = DefaultConversationMsg.DeepCopy();
            var message2     = DefaultConversationMsg2.DeepCopy();

            using (var tx = stateManager.CreateTransaction())
            {
                await dictKeyToId.AddOrUpdateAsync(tx, conversation.Key, conversation.Id, (k, v) => conversation.Id);

                await dictIdToEntity.AddOrUpdateAsync(tx, conversation.Id, conversation, (k, v) => conversation);

                await MessageIndexDict.SetAsync(tx, message1.ConversationId, new List <Guid>() { message1.Id, message2.Id });

                await MessageListDict.SetAsync(tx, message1.Id, message1);

                await MessageListDict.SetAsync(tx, message2.Id, message2);

                await tx.CommitAsync();
            }
        }