Ejemplo n.º 1
0
        public async Task Call_BusinessEvent_PublishAsync_AmigoTenantTEventLog()
        {
            AmigoTenantTEventLog dataItem = null;
            var message      = new RegisterAmigoTenanttEventLogCommand();
            var eventcommand = new AmigoTenantTEventLog();

            A.CallTo(() => _mapper.Map <RegisterAmigoTenanttEventLogCommand, AmigoTenantTEventLog>(message)).Returns(eventcommand);
            A.CallTo(() => _repository.Add(null)).WithAnyArguments().Invokes((f) => dataItem            = f.Arguments.FirstOrDefault() as AmigoTenantTEventLog);
            A.CallTo(() => _unitOfWork.CommitAsync()).Invokes(() => eventcommand.AmigoTenantTEventLogId = 1).ReturnsLazily(() => Task.FromResult(0));

            //**********   ACT   **********
            await _commandHandler.Handle(message);

            //**********   ASSERT    **********
            //A.CallTo(() => _bus.PublishAsync(eventcommand)).WithAnyArguments().MustHaveHappened(Repeated.Exactly.Once);
            Assert.NotNull(eventcommand);
        }
Ejemplo n.º 2
0
        public async Task Call_UnitOfWork_RegisterAmigoTenantTEventLog_CommandHandler()
        {
            var message = new RegisterAmigoTenanttEventLogCommand();
            var command = new AmigoTenantTEventLog();

            A.CallTo(() => _mapper.Map <RegisterAmigoTenanttEventLogCommand, AmigoTenantTEventLog>(message)).Returns(command);

            AmigoTenantTEventLog dataItem = null;

            A.CallTo(() => _repository.Add(null)).WithAnyArguments().Invokes((f) => dataItem = f.Arguments.FirstOrDefault() as AmigoTenantTEventLog);


            //**********   ACT   **********
            await _commandHandler.Handle(message);

            //**********   ASSERT    **********
            A.CallTo(() => _unitOfWork.CommitAsync()).MustHaveHappened(Repeated.Exactly.Once);
            Assert.NotNull(dataItem);
        }