Exemple #1
0
        public async Task QryHandler_ObterContratoPorId_Simples()
        {
            var fixture = new Fixture();

            var returnThis = fixture.Create <ContratoDeEmprestimoModel>();

            var obterContratoPorId = Substitute.For <IObterContratoPorId>();

            obterContratoPorId.ObterContratoPorId(Arg.Any <ObterContratoPorIdQuery>())
            .Returns(returnThis);

            var handler = new ObterContratoPorIdHandler(obterContratoPorId);
            var result  = await handler.Handle(fixture.Create <ObterContratoPorIdQuery>());

            obterContratoPorId.Received(1)
            .ObterContratoPorId(Arg.Any <ObterContratoPorIdQuery>());
            result.Should().BeEquivalentTo(returnThis);
        }
Exemple #2
0
        public async Task QryHandler_ObterContratoPorId_Inexistente()
        {
            var fixture = new Fixture();

            var obterContratoPorId = Substitute.For <IObterContratoPorId>();

            obterContratoPorId.ObterContratoPorId(Arg.Any <ObterContratoPorIdQuery>())
            .Returns((ContratoDeEmprestimoModel)null);

            var handler = new ObterContratoPorIdHandler(obterContratoPorId);

            await FluentActions
            .Invoking(async() => await handler.Handle(new ObterContratoPorIdQuery()))
            .Should()
            .ThrowAsync <ResourceNotFoundException>();

            obterContratoPorId.Received(1)
            .ObterContratoPorId(Arg.Any <ObterContratoPorIdQuery>());
        }