예제 #1
0
        public async Task UserLeft_UserNull()
        {
            //assemble
            var queryContext        = AssembleMocks.GetQueryContext();
            var commandContext      = AssembleMocks.GetCommandContext();
            var userSummaryRepo     = new UserSummaryRepository(queryContext.Object);
            var conversationRepo    = new ConversationRepository(queryContext.Object, commandContext.Object);
            var messageRepo         = new MessageRepository(queryContext.Object, commandContext.Object);
            var conversationContext = new ConversationBoundedContext(conversationRepo, userSummaryRepo, messageRepo);
            var conversation        = await conversationContext.GetById(4);

            var userSummary = await userSummaryRepo.GetById(1);

            var userSummaryTest = await userSummaryRepo.GetById(5);

            conversation.UserJoined(userSummary); //workaround since can't seem to mock a working Include()
            Assert.IsTrue(conversation.ActiveUsers.Count() == 1);

            //act
            conversation.UserLeft(userSummaryTest);

            //assert
            Assert.IsNull(userSummaryTest);
            Assert.IsTrue(conversation.ActiveUsers.Count() == 1);
        }
예제 #2
0
        public async Task Create_NotNullTopic()
        {
            //assemble
            var queryContext     = AssembleMocks.GetQueryContext();
            var commandContext   = AssembleMocks.GetCommandContext();
            var conversationRepo = new ConversationRepository(queryContext.Object, commandContext.Object);

            //act
            var conversation = await conversationRepo.Create("New Topic");

            //assert
            Assert.IsNotNull(conversation);
        }
예제 #3
0
        public async Task GetBySignalRConnectionIdWithActiveUser_NotFound()
        {
            //assemble
            var queryContext     = AssembleMocks.GetQueryContext(true);
            var commandContext   = AssembleMocks.GetCommandContext(true);
            var conversationRepo = new ConversationRepository(queryContext.Object, commandContext.Object);

            //act
            var conversationId = await conversationRepo.GetConversationIdBySignalRId("bc0444a5-c967-4d9f-86eb-0d9359d1bda3");

            //assert
            Assert.IsTrue(conversationId == 0);
        }
예제 #4
0
        public async Task GetById_NotFound()
        {
            //assemble
            var queryContext     = AssembleMocks.GetQueryContext();
            var commandContext   = AssembleMocks.GetCommandContext();
            var conversationRepo = new ConversationRepository(queryContext.Object, commandContext.Object);

            //act
            var conversation = await conversationRepo.GetById(15, null);

            //assert
            Assert.IsNull(conversation);
        }
예제 #5
0
        public async Task GetAllActive()
        {
            //assemble
            var queryContext     = AssembleMocks.GetQueryContext();
            var commandContext   = AssembleMocks.GetCommandContext();
            var conversationRepo = AssembleMocks.GetConversationRepo(queryContext, commandContext);

            //act
            var conversations = await conversationRepo.Object.GetAllActive();

            //assert
            Assert.IsNotNull(conversations);
            Assert.IsTrue(conversations.Count() == 3);
        }
예제 #6
0
        public async Task Persist()
        {
            //assemble
            var queryContext     = AssembleMocks.GetQueryContext();
            var commandContext   = AssembleMocks.GetCommandContext();
            var conversationRepo = new ConversationRepository(queryContext.Object, commandContext.Object);
            var conversation     = await conversationRepo.GetById(1, null);

            string newTopic = Guid.NewGuid().ToString();

            //act
            conversation.Topic = newTopic;
            var response = await conversationRepo.Persist(conversation);

            //assert
            Assert.IsTrue(response.Topic == newTopic);
        }
예제 #7
0
        public async Task UserJoined_UserNull()
        {
            //assemble
            var queryContext        = AssembleMocks.GetQueryContext();
            var commandContext      = AssembleMocks.GetCommandContext();
            var userSummaryRepo     = new UserSummaryRepository(queryContext.Object);
            var conversationRepo    = new ConversationRepository(queryContext.Object, commandContext.Object);
            var messageRepo         = new MessageRepository(queryContext.Object, commandContext.Object);
            var conversationContext = new ConversationBoundedContext(conversationRepo, userSummaryRepo, messageRepo);
            var conversation        = await conversationContext.GetById(5);

            var userSummary = await userSummaryRepo.GetById(5);

            //act
            conversation.UserJoined(userSummary);

            //assert
            Assert.IsNull(userSummary);
            Assert.IsTrue(conversation.ActiveUsers.Count() == 0);
        }