Exemple #1
0
        public async Task CreatesNewMessagePassValidationWithoutId()
        {
            // Arrange
            var message = new Message()
            {
                Content = "Hello World"
            };
            var mockService = new Mock <IMessageDbService>();

            mockService.Setup(service => service.CreateAsync(message))
            .Callback(() => message.Id = 1);

            var controller = new MessagesController(mockService.Object);

            var result = await controller.CreateAsync(message);

            Assert.That(message.Id, Is.GreaterThan(0));
        }