Exemple #1
0
        public async Task AddAsync_GroupOperation_WithoutParametersThrowException()
        {
            var signalRSenderMock = new Mock <IAzureSignalRSender>();
            var collector         = new SignalRAsyncCollector <SignalRGroupAction>(signalRSenderMock.Object);

            var item = new SignalRGroupAction
            {
                GroupName = "group1",
                Action    = GroupAction.Add
            };

            await Assert.ThrowsAsync <ArgumentException>(() => collector.AddAsync(item));
        }
        public void OutputConverter_SignalRGroupAction_TypeReturnsValid()
        {
            var converter = new SignalROutputConverter();

            var input = new SignalRGroupAction()
            {
                UserId    = "user1",
                GroupName = "group1",
                Action    = GroupAction.Add
            };

            var converted = converter.ConvertToSignalROutput(input);

            Assert.Equal(typeof(SignalRGroupAction), converted.GetType());
        }
        public async Task AddAsync_WithUserId_CallsRemoveUserFromAllGroups()
        {
            var signalRSenderMock = new Mock <IAzureSignalRSender>();
            var collector         = new SignalRAsyncCollector <SignalRGroupAction>(signalRSenderMock.Object);

            var action = new SignalRGroupAction
            {
                UserId = "userId1",
                Action = GroupAction.RemoveAll
            };
            await collector.AddAsync(action);

            signalRSenderMock.Verify(
                c => c.RemoveUserFromAllGroups(action),
                Times.Once);
            signalRSenderMock.VerifyNoOtherCalls();
            var actualData = signalRSenderMock.Invocations[0].Arguments[0];

            Assert.Equal(action, actualData);
        }
        public async Task AddAsync_WithConnectionId_CallsRemoveConnectionFromGroup()
        {
            var signalRSenderMock = new Mock <IAzureSignalRSender>();
            var collector         = new SignalRAsyncCollector <SignalRGroupAction>(signalRSenderMock.Object);

            var action = new SignalRGroupAction
            {
                ConnectionId = "connection1",
                GroupName    = "group1",
                Action       = GroupAction.Remove
            };
            await collector.AddAsync(action);

            signalRSenderMock.Verify(
                c => c.RemoveConnectionFromGroup(action),
                Times.Once);
            signalRSenderMock.VerifyNoOtherCalls();
            var actualData = signalRSenderMock.Invocations[0].Arguments[0];

            Assert.Equal(action, actualData);
        }
        public async Task AddAsync_WithUserId_CallsAddUserToGroup(ServiceEndpoint[] endpoints)
        {
            var signalRSenderMock = new Mock <IAzureSignalRSender>();
            var collector         = new SignalRAsyncCollector <SignalRGroupAction>(signalRSenderMock.Object);

            var action = new SignalRGroupAction
            {
                UserId    = "userId1",
                GroupName = "group1",
                Action    = GroupAction.Add,
                Endpoints = endpoints
            };
            await collector.AddAsync(action);

            signalRSenderMock.Verify(
                c => c.AddUserToGroup(action),
                Times.Once);
            signalRSenderMock.VerifyNoOtherCalls();
            var actualData = signalRSenderMock.Invocations[0].Arguments[0];

            Assert.Equal(action, actualData);
        }