Esempio n. 1
0
        public async Task Get_SupplierFound_ReturnsExpectedResponse()
        {
            const string id = "1";

            var mockSupplier = new Mock <ISupplier>();

            mockSupplier.Setup(s => s.Id).Returns(id);
            mockSupplier.Setup(s => s.Name).Returns("Uncle Bob's Miracle Cures");

            var expectedSupplier = new GetSupplierModel(mockSupplier.Object);

            var mockMediator = new Mock <IMediator>();

            mockMediator.Setup(m => m.Send(It.IsNotNull <IRequest <ISupplier> >(), It.IsAny <CancellationToken>()))
            .ReturnsAsync(mockSupplier.Object);

            var controller = new SuppliersController(mockMediator.Object);

            var response = await controller.Get(id);

            response.Should().BeEquivalentTo(new ActionResult <GetSupplierModel>(new OkObjectResult(expectedSupplier)));
        }