コード例 #1
0
        public void GivenAConnectedUserWithManyConnections_WhenTheUserDisconnectFromAllConnections_ThenTheUserShouldLeaveChat()
        {
            var chat = new ChatRoom();
            chat.Connect("username", DummyDateTime, "connection1");
            chat.Connect("username", DummyDateTime, "connection2");

            chat.Disconnect("connection1", DummyDateTime);
            ChatEvent chatEvent = chat.Disconnect("connection2", Now);

            chatEvent.Should().Be(ChatEvent.UserLeavesChat("username", Now));
        }
コード例 #2
0
        private async Task Disconnect()
        {
            if (ChatRoom == null)
            {
                DisplayError("You are not connected to a server.");
            }

            await ChatRoom.Disconnect();
        }
コード例 #3
0
        public void GivenAConnectedUserWithManyConnections_WhenTheUserDisconnectFromOneConnection_ThenNothingHappens()
        {
            var chat = new ChatRoom();
            chat.Connect("username", DummyDateTime, "connection1");
            chat.Connect("username", DummyDateTime, "connection2");

            ChatEvent chatEvent = chat.Disconnect("connection1", Now);

            chatEvent.Should().Be(ChatEvent.NothingHappens(Now));
        }
コード例 #4
0
        public void GivenAConnectedUser_WhenTheUserDisconnect_ThenTheUserShouldLeaveChat()
        {
            var chat = new ChatRoom();
            chat.Connect("username", DummyDateTime, "connection");

            ChatEvent chatEvent = chat.Disconnect("connection", Now);

            chatEvent.Should().Be(
                ChatEvent.UserLeavesChat("username", Now));
        }
コード例 #5
0
        public void GivenSomeConnectedUsers_WhenANotConnectedUserDisconnect_ThenNothingHappens()
        {
            var chat = new ChatRoom();
            chat.Connect("dummyUser1", DummyDateTime, DummyConnectionId());
            chat.Connect("dummyUser2", DummyDateTime, DummyConnectionId());

            ChatEvent chatEvent = chat.Disconnect("newConnection", Now);

            chatEvent.Should().Be(
               ChatEvent.NothingHappens(Now));
        }
コード例 #6
0
        public void GivenAnEmptyChatRoom_WhenANewUserDisconnect_ThenNothingHappens()
        {
            var chat = new ChatRoom();

            ChatEvent chatEvent = chat.Disconnect("dummyConnection", Now);

            chatEvent.Should().Be(
                ChatEvent.NothingHappens(Now));
        }