Esempio n. 1
0
        public async Task ShouldSendCommandToMediator()
        {
            AddCigarCommand command = new AddCigarCommand()
            {
                Blend  = "Family Reserve",
                Brand  = "Padron",
                Gauge  = 52,
                Length = 5.5M
            };

            Guid newCigarId = Guid.NewGuid();

            Mock <IMediator> mediatorMock = new Mock <IMediator>();

            mediatorMock
            .Setup(mediator => mediator.Send(command, CancellationToken.None))
            .ReturnsAsync(newCigarId);

            CigarsController controller = new CigarsController(mediatorMock.Object);

            ActionResult <Guid> result = await controller.Post(command);

            CreatedAtActionResult actionResult = (CreatedAtActionResult)result.Result;

            Assert.Equal(newCigarId, actionResult.Value);
        }
Esempio n. 2
0
 public CigarsControllerTests()
 {
     mockCigarService = new Mock <ICigarService>();
     controller       = new CigarsController(mockCigarService.Object);
 }