public void GetById_ReturnsExpected() { var expected = new Recipe(); _mockRepo.Setup(r => r.GetRecipeById(It.IsAny <int>())).Returns(expected); var result = _controller.GetById(1) as OkObjectResult; Assert.AreEqual(expected, result?.Value); }
public async void ShouldGetByIdCorrectly() { var mediatorMock = new Mock <IMediator>(); var controller = new RecipeController(mediatorMock.Object); await controller.GetById(new Guid("F3583BB5-DCD4-4161-990F-CF97D7156B97")); mediatorMock.Verify(x => x.Send(It.Is <GetRecipeById>(y => y.Id == new Guid("F3583BB5-DCD4-4161-990F-CF97D7156B97") && y.StripMetadata == true), It.IsAny <CancellationToken>()), Times.Once); mediatorMock.VerifyNoOtherCalls(); }