Пример #1
0
        public async Task Call_BusinessEvent_PublishAsync_RegisterMoveEvent()
        {
            var eventcommand = new RegisterMoveEvent();
            var command      = new AmigoTenantTService()
            {
                ChargeType = "FAKE"
            };
            //---->  Include Changes
            var message = new RegisterAmigoTenanttServiceCommand
            {
                AmigoTenantTUserId    = 1,
                ActivityTypeId        = 1,
                Username              = "******",
                AmigoTenantTServiceId = 1
            };

            A.CallTo(() => _mapper.Map <RegisterAmigoTenanttServiceCommand, AmigoTenantTService>(message)).Returns(command);
            A.CallTo(() => _mapper.Map <RegisterAmigoTenanttServiceCommand, RegisterMoveEvent>(message)).Returns(eventcommand);
            A.CallTo(() => _unitOfWork.CommitAsync())
            .Invokes(() => command.AmigoTenantTServiceId = 1)
            .ReturnsLazily(() => Task.FromResult(0));

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

            //**********   ASSERT    **********
            A.CallTo(() => _bus.PublishAsync(eventcommand)).WithAnyArguments().MustHaveHappened(Repeated.Exactly.Once);
            Assert.NotNull(eventcommand);
            Assert.IsNotNull(message);
        }
        public async Task Call_UnitOfWork_To_UpdateAmigoTenantTServiceApproveCommandHandler()
        {
            var command = new AmigoTenantTService();
            var message = new UpdateAmigoTenantTServiceApproveCommand();

            A.CallTo(() => _mapper.Map <UpdateAmigoTenantTServiceApproveCommand, AmigoTenantTService>(message)).Returns(command);

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

            //**********   ASSERT    **********
            A.CallTo(() => _repository.UpdatePartial(null)).WithAnyArguments().MustHaveHappened(Repeated.Exactly.Once);
            A.CallTo(() => _unitOfWork.CommitAsync()).MustHaveHappened(Repeated.Exactly.Once);
        }
Пример #3
0
        public async Task Call_UnitOfWork_and_include_audit_fields()
        {
            //**********  ARRANGE  **********
            var message = new RegisterAmigoTenanttServiceCommand
            {
                AmigoTenantTUserId = 1,
                UserId             = 1
            };
            AmigoTenantTService dataItem = null;

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

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

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