public async Task Handle_MultiplePlansPresent_ReturnsMatchingPlan() { //Arrange var fakeMediator = Substitute.For <IMediator>(); fakeMediator .Send(Arg.Any <GetSupportedPlansQuery>()) .Returns(new [] { new Plan( "non-matching-1", 1337, new Bundle(), Array.Empty <PullDogPlan>()), new Plan( "matching", 1337, new Bundle(), Array.Empty <PullDogPlan>()), new Plan( "non-matching-2", 1337, new Bundle(), Array.Empty <PullDogPlan>()) }); var handler = new GetPlanByIdQueryHandler( fakeMediator); //Act var bundle = await handler.Handle(new GetPlanByIdQuery("matching"), default); //Assert Assert.IsNotNull(bundle); Assert.AreEqual("matching", bundle.Id); }
public async void ShouldReturnPlanWhenIsRequested(GetPlanByIdQueryHandlerTestsFixture fixture) { //Arrange var plan = Plan.Create(10, new List <TaskRoute>(), DateTimeOffset.UtcNow); fixture.PlanRepository.GetPlan(Arg.Any <int>()).Returns(plan); var sut = new GetPlanByIdQueryHandler(fixture.PlanRepository); //Act Plan result = await sut.Handle(new GetPlansQuery(), CancellationToken.None); //Assert result.Should().NotBeNull(); result.Id.Should().Be(1); result.Name.Should().Be("new plan"); }