Example #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);
        }
Example #2
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);
        }
Example #3
0
        public void RegisterAmigoTenanttServiceAsync_SendCommand_To_Bus_SendAsync()
        {
            DateTime       baseTime   = new DateTime(2017, 01, 11, 7, 0, 0);
            DateTimeOffset sourceTime = new DateTimeOffset(baseTime, TimeZoneInfo.Local.GetUtcOffset(baseTime));

            var request = new AmigoTenanttServiceDTO();
            var command = new RegisterAmigoTenanttServiceCommand();

            request.ServiceStartDate     = sourceTime;
            request.ServiceStartDateTZ   = "America/New_York";
            request.ReportedActivityDate = sourceTime;


            A.CallTo(() => _mapper.Map <AmigoTenanttServiceDTO, RegisterAmigoTenanttServiceCommand>(request)).Returns(command);

            //**********   ACT   **********
            var resp = _appService.RegisterAmigoTenanttServiceAsync(request);

            //**********   ASSERT    **********
            Assert.NotNull(resp);

            A.CallTo(() => _bus.SendAsync(command)).WithAnyArguments().MustHaveHappened(Repeated.Exactly.Once);
        }