public async Task AddMessageAsync() { var mockRepo = new Mock <IDeletableEntityRepository <Message> >(); mockRepo.Setup(x => x.AddAsync(It.IsAny <Message>())).Callback( (Message mess) => this.messages.Add(mess)); var service = new MessagesService(mockRepo.Object); await service.AddMessageAssyns("d34", "ABC"); Assert.Equal(4, this.messages.Count); }