Exemplo n.º 1
0
        public async Task onAppearing()
        {
            //edw pera 8a koitaei thn vash kai 8a kanei load ta messages!!
            try
            {
                await Shell.Current.Navigation.PushPopupAsync(new LoadingPopup());

                await ChatHub.Init(CurrentGroup);

                await ChatHub.hubConnection.StartAsync();

                await ChatHub.JoinGroup(CurrentGroup);

                var list1 = await server.GetGroypMessages(CurrentGroup);

                RoomMessages = new ObservableCollection <GroupMessages>(list1);
                await Shell.Current.Navigation.PopPopupAsync();

                //await server.AddRoom(CurrentGroup);
            }
            catch (Exception ex)
            {
                await Shell.Current.Navigation.PopPopupAsync();

                await Shell.Current.Navigation.PushPopupAsync(new InfoPopup("Error", ex.Message));

                Console.WriteLine(ex.Message);
                Console.WriteLine(ex.Message);
            }
        }
Exemplo n.º 2
0
        public async Task JoinGroup_Success_NotifyCurrentAndAllConnection()
        {
            var testPayload = new UserWssPayload {
                GroupId = TestGroupId
            };
            var testGroup = new Group {
                Id = TestGroupId
            };

            _chatServiceMock
            .Setup(s => s.JoinGroupAsync(TestUserId, TestGroupId))
            .ReturnsAsync(true);
            _chatServiceMock
            .Setup(s => s.GetGroupAsync(testGroup.Id))
            .ReturnsAsync(testGroup);

            await _target.JoinGroup(testPayload);

            AssertMessageSentToCurrentConnection(ChatHub.JoinResultMessage,
                                                 content => ((JoinResponse)content).Group == testGroup);
            AssertMessageSentToAllConnections(ChatHub.NewMemberMessage,
                                              content => ((MemberChangeResponse)content).Group == testGroup);
        }
Exemplo n.º 3
0
        public void CallAddMethodOnce()
        {
            const string connectionId = "1";

            var mockGroupManager = new Mock <IGroupManager>();

            mockGroupManager.Setup(x => x.Add(It.IsAny <string>(), It.IsAny <string>()));

            var mockHubCallerContext = new Mock <HubCallerContext>();

            mockHubCallerContext.Setup(x => x.ConnectionId).Returns(connectionId);
            var hub = new ChatHub
            {
                Context = mockHubCallerContext.Object,
                Groups  = mockGroupManager.Object
            };

            hub.JoinGroup("gosho");

            mockGroupManager.Verify(x => x.Add(It.IsAny <string>(), It.IsAny <string>()), Times.Once);
        }