Esempio n. 1
0
        public async Task AddMessageShouldReturnTheRightMessage()
        {
            var service = new MessengerService(this.conversationRepository, this.messageRepository);
            var message = await service.AddMessage <TestMessageViewModel>("ccc", "ddd");

            Assert.Equal("ccc", message.UserId);
            Assert.Equal("ddd", message.Text);
        }
Esempio n. 2
0
        public async Task AddMessageShouldAddMessage()
        {
            var messages = new List <Message>();

            var repository = new Mock <IDeletableEntityRepository <Message> >();

            repository
            .Setup(r => r.AddAsync(It.IsAny <Message>()))
            .Callback((Message m) => messages.Add(m));

            var service = new MessengerService(this.conversationRepository, repository.Object);
            await service.AddMessage <TestMessageViewModel>("aaa", "bbb");

            Assert.Single(messages);
            Assert.Equal("aaa", messages[0].UserId);
            Assert.Equal("bbb", messages[0].Text);
        }