예제 #1
0
        public async Task TestIfConnectionAlreadyEstablishedReturnsTrue(string connectionId, string subject, string email, string technicianName)
        {
            var context = PCHUBDbContextInMemoryInitializer.InitializeContext();

            var chatRequests = new RequestChatServices(context);

            await chatRequests.EstablishConnectionAsync(connectionId, subject, email, technicianName);

            Assert.True(await chatRequests.ConnectionAlreadyEstablishedAsync(connectionId, "StoreUser"));
        }
예제 #2
0
        public async Task TestIfEstablishedConnectionDetailsWorksAccordingly(string connectionId, string subject,
                                                                             string email,
                                                                             string technicianName)
        {
            var context = PCHUBDbContextInMemoryInitializer.InitializeContext();

            var chatRequests = new RequestChatServices(context);

            await chatRequests.EstablishConnectionAsync(connectionId, subject, email, technicianName);

            Assert.NotNull(await chatRequests.EstablishedConnectionDetailsAsync(connectionId, "StoreUser"));

            Assert.NotNull(await chatRequests.EstablishedConnectionDetailsAsync(technicianName, "Admin"));
        }
예제 #3
0
        public async Task TestIfDisconnectFromChatWorksAccordingly(string connectionId, string subject, string email, string technicianName)
        {
            var context = PCHUBDbContextInMemoryInitializer.InitializeContext();

            var chatRequests = new RequestChatServices(context);

            await chatRequests.EstablishConnectionAsync(connectionId, subject, email, technicianName);

            await chatRequests.DisconnectFromChat(technicianName, connectionId);

            var chat = await context.Chats.FirstOrDefaultAsync(x => x.TechnicianName == technicianName && x.ConnectionId == connectionId && x.ConnectionTerminated == true);

            Assert.NotNull(chat);

            Assert.True(chat.ConnectionTerminated);
        }
예제 #4
0
        public async Task TestIfEstablishConnectionWorksAccordingly(string connectionId, string subject, string email,
                                                                    string technicianName)
        {
            var context = PCHUBDbContextInMemoryInitializer.InitializeContext();

            var chatRequests = new RequestChatServices(context);

            await chatRequests.EstablishConnectionAsync(connectionId, subject, email, technicianName);


            var result = await context.Chats.FirstOrDefaultAsync(x => x.ConnectionId == connectionId);

            Assert.NotNull(result);

            Assert.Equal(subject, result.Subject);
            Assert.Equal(technicianName, result.TechnicianName);
        }
예제 #5
0
        public async Task TestIfInsertChatWorksAccordingly(string connectionId, string subject, string email, string technicianName)
        {
            var context = PCHUBDbContextInMemoryInitializer.InitializeContext();

            var chatRequests = new RequestChatServices(context);

            await chatRequests.EstablishConnectionAsync(connectionId, subject, email, technicianName);

            await chatRequests.InsertChatAsync(technicianName, connectionId, "User",
                                               "Please help me make the best choice!");


            var result = await context.Chats.FirstOrDefaultAsync(x => x.ConnectionId == connectionId);

            Assert.NotNull(result);

            Assert.NotNull(result.Messages);
        }