📜  如何测试 mediatr - 任何代码示例

📅  最后修改于: 2022-03-11 14:56:50.485000             🧑  作者: Mango

代码示例1
mockPeopleService = new Mock();
  var people = ....;

            var expectedResult = new GetCatsResponse()
            {
                Male = new List() { "Garfield", "Jim", "Max", "Tom" },
                Female = new List() { "Garfield", "Simba", "Tabby" }
            };

            mockPeopleService.Setup(ps => ps.GetPeople()).Returns(people);

            var handler = new GetCatsHandler(mockPeopleService.Object);

            var actualResult = await GetActualResult(handler);

            actualResult.Should().BeEquivalentTo(expectedResult, optons => optons.WithStrictOrdering());