Ejemplo n.º 1
0
        public void Execute_WhenMessageIsNullOrWhiteSpace_ThrowArgumentException(string message)
        {
            var userServiceMock    = new Mock <IUserService>();
            var postMessageCommand = new PostMessageCommand(userServiceMock.Object);

            postMessageCommand.Execute("franta", message);
        }
        public void Execute_WhenMessageIsNullOrWhiteSpace_ThrowArgumentException(string message)
        {
            var userServiceMock = new Mock<IUserService>();
            var postMessageCommand = new PostMessageCommand(userServiceMock.Object);

            postMessageCommand.Execute("franta", message);
        }
        public void Execute_WhenUserDoesNotExist_RegisterNewUser()
        {
            var userServiceMock = new Mock<IUserService>();
            userServiceMock.SetupSequence(x => x.GetUserByUserName(It.IsAny<string>()))
                .Returns(null)
                .Returns(null)
                .Returns(new User { UserName = "******" });
            userServiceMock.Setup(x => x.RegisterNewUser(It.Is<string>(p => p == "franta")))
                .Verifiable();

            var postMessageCommand = new PostMessageCommand(userServiceMock.Object);

            postMessageCommand.Execute("franta", "message");

            userServiceMock.Verify();
        }
Ejemplo n.º 4
0
        public void Execute_WhenUserDoesNotExist_RegisterNewUser()
        {
            var userServiceMock = new Mock <IUserService>();

            userServiceMock.SetupSequence(x => x.GetUserByUserName(It.IsAny <string>()))
            .Returns(null)
            .Returns(null)
            .Returns(new User {
                UserName = "******"
            });
            userServiceMock.Setup(x => x.RegisterNewUser(It.Is <string>(p => p == "franta")))
            .Verifiable();

            var postMessageCommand = new PostMessageCommand(userServiceMock.Object);

            postMessageCommand.Execute("franta", "message");

            userServiceMock.Verify();
        }
Ejemplo n.º 5
0
        public async Task <Message> PostMessageAsync(string messageContent, int channelId)
        {
            try
            {
                var message = await Task.Run(async() =>
                {
                    var postMessagesCommand = new PostMessageCommand(_connection);
                    var result = await postMessagesCommand.ExecuteAsync(channelId, messageContent);
                    return(result);
                });

                return(message);
            }
            catch (GraphQLException graphQLException)
            {
                Debug.WriteLine(graphQLException);
                throw;
            }
        }