protected BaseFeedbackIntegrationServiceTests()
            {
                _mapper    = new TestFixture().Mapper;
                _dbBuilder = new MockDbBuilder();
                _db        = _dbBuilder
                             .WithLoads(LOADS)
                             .WithUsers(new List <UserEntity> {
                    VALID_USER, INVALID_USER
                })
                             .Build();

                _securityService = new Mock <ISecurityService>();
                _securityService.Setup(_ => _.GetAuthorizedCustomersforUserAsync()).ReturnsAsync((new List <CustomerData>()
                {
                    new CustomerData
                    {
                        CustomerId = VALID_CUSTOMER_ID
                    }
                }).AsReadOnly());

                _feedbackClient = new Mock <IFeedbackClient>();

                _userContext = new Mock <IUserContext>();
                _userContext.SetupGet(_ => _.UserId).Returns(VALID_USER_ID);
                _userContext.SetupGet(_ => _.UserName).Returns(VALID_USER_NAME);

                _config        = new Mock <IConfigurationRoot>();
                _configSection = new Mock <IConfigurationSection>();

                _svc = CreateService();
            }
示例#2
0
            protected BaseLoadStatusTransactionTests(TestFixture fixture)
            {
                _mapper    = fixture.Mapper;
                _dbBuilder = new MockDbBuilder();
                _db        = _dbBuilder
                             .WithLoads(LOADS)
                             .WithUsers(new List <UserEntity> {
                    VALID_CARRIER_USER, INVALID_CARRIER_USER, SHIPPER_USER
                })
                             .WithLoadStatusTransactions(LOAD_STATUS_TRANSACTIONS)
                             .Build();

                _securityService = new Mock <ISecurityService>();
                _securityService.Setup(_ => _.UserHasActionAsync(It.IsAny <string[]>())).ReturnsAsync(true);
                _securityService.Setup(_ => _.GetAuthorizedCustomersforUserAsync()).ReturnsAsync((new List <CustomerData>()
                {
                    new CustomerData
                    {
                        CustomerId = VALID_CUSTOMER_ID
                    }
                }).AsReadOnly());

                _carrierWebApiService = new Mock <ICarrierWebAPIService>();

                _userContext = new Mock <IUserContext>();
                _userContext.SetupGet(_ => _.UserId).Returns(VALID_CARRIER_USER_ID);
            }
示例#3
0
            public async Task SubmitsBillingLoadId()
            {
                var load = VALID_LOAD;

                load.PlatformPlusLoadId = "PLATFORM_PLUS_ID";
                load.LatestLoadTransaction.Claim.BillingLoadId = "BILLING_LOAD_ID";
                var loads = new List <LoadEntity> {
                    load
                };

                _dbBuilder = new MockDbBuilder();
                _db        = _dbBuilder
                             .WithLoads(loads)
                             .WithUsers(new List <UserEntity> {
                    VALID_CARRIER_USER
                })
                             .Build();

                var stopStatuses = new LoadStatusStopData
                {
                    LoadId = VALID_LOAD_ID,
                    Events = new List <LoadStatusStopEventData>
                    {
                        new LoadStatusStopEventData
                        {
                            StopNumber = 1,
                            EventTime  = new DateTimeOffset(new DateTime(2020, 2, 11, 10, 0, 0)),
                            EventType  = StopEventTypeEnum.Arrival
                        }
                    }
                };

                _carrierWebApiService.Setup(_ => _.Send <StopEventData>(It.IsAny <LoadStatusEvent <StopEventData> >()))
                .ReturnsAsync(new LoadStatusEvent <CarrierApiResponseMessages>
                {
                    MessageId   = Guid.Parse("44444444-4444-4444-4444-555555555555"),
                    MessageTime = new DateTimeOffset(new DateTime(2020, 2, 11, 12, 13, 14))
                });

                _svc = CreateService();

                var response = await _svc.AddStopStatuses(stopStatuses);

                response.IsSuccess.Should().BeTrue();

                _carrierWebApiService.Verify(_ => _.Send <StopEventData>(It.Is <LoadStatusEvent <StopEventData> >(
                                                                             e => e.MessageType == "LoadStopEvent" &&
                                                                             e.ApiVersion == "1.1" &&
                                                                             e.Payload.LoadNumber == "BILLING_LOAD_ID" &&
                                                                             e.Payload.StopNbr == 1 &&
                                                                             e.Payload.StatusDateTime == "2020-02-11T10:00:00" &&
                                                                             e.Payload.IsLocalTime == true &&
                                                                             e.Payload.Scac == "TEST"
                                                                             )));
            }
示例#4
0
            public async Task SubmitsBillingLoadId()
            {
                var load = VALID_LOAD;

                load.PlatformPlusLoadId = "PLATFORM_PLUS_ID";
                load.LatestLoadTransaction.Claim.BillingLoadId = "BILLING_LOAD_ID";
                var loads = new List <LoadEntity> {
                    load
                };

                _dbBuilder = new MockDbBuilder();
                _db        = _dbBuilder
                             .WithLoads(loads)
                             .WithUsers(new List <UserEntity> {
                    VALID_CARRIER_USER
                })
                             .Build();

                var inTransitStatus = new LoadStatusInTransitData
                {
                    LoadId       = VALID_LOAD_ID,
                    LocationTime = new DateTimeOffset(new DateTime(2020, 2, 11, 10, 0, 0)),
                    //Oregon
                    Latitude  = 46.161605m,
                    Longitude = -123.414906m
                };

                _carrierWebApiService.Setup(_ => _.Send <InTransitLoadData>(It.IsAny <LoadStatusEvent <InTransitLoadData> >()))
                .ReturnsAsync(new LoadStatusEvent <CarrierApiResponseMessages>
                {
                    MessageId   = Guid.Parse("44444444-4444-4444-4444-555555555555"),
                    MessageTime = new DateTimeOffset(new DateTime(2020, 2, 11, 12, 13, 14))
                });

                _svc = CreateService();

                var response = await _svc.AddInTransitStatus(inTransitStatus);

                response.IsSuccess.Should().BeTrue();

                _carrierWebApiService.Verify(_ => _.Send <InTransitLoadData>(It.Is <LoadStatusEvent <InTransitLoadData> >(
                                                                                 e => e.MessageType == "LoadLocation" &&
                                                                                 e.ApiVersion == "1.1" &&
                                                                                 e.Payload.Loads[0].LoadNumber == "BILLING_LOAD_ID" &&
                                                                                 e.Payload.Loads[0].Latitude == 46.161605m &&
                                                                                 e.Payload.Loads[0].Longitude == -123.414906m &&
                                                                                 e.Payload.Loads[0].LocationTime == "2020-02-11T10:00:00" &&
                                                                                 e.Payload.Loads[0].IsLocalTime == true
                                                                                 )));
            }
            public async Task UserNotFound()
            {
                _config.Setup(_ => _.GetSection(It.Is <string>(s => s == FeedbackQuestionCodeEnum.LB_ShipperReuseCarrierQuestionId.ToString()))).Returns(_configSection.Object);
                _configSection.Setup(a => a.Value).Returns("10");

                _dbBuilder = new MockDbBuilder();
                _db        = _dbBuilder
                             .WithLoads(LOADS)
                             .Build();

                _svc = CreateService();

                Func <Task> action = async() => await _svc.GetResponseAsync(
                    FeedbackQuestionCodeEnum.LB_ShipperReuseCarrierQuestionId, VALID_LOAD_ID);

                (await action.Should().ThrowAsync <Exception>()).WithMessage("Load not found");
            }