예제 #1
0
        public async Task CreateAssetEnquiry_ShouldThrowException_WhenAssetAlreadyExists_InDbContext()
        {
            var request = new TrackAReportRequest {
                ReferenceNumber = AssetEnquiryConstants.EXISTING_EXTERNAL_ID
            };

            using (var db = new InthubContext(ContextOptions))
            {
                var availabilityService = CreateAssetEnquiryService(db);

                var result = await Assert.ThrowsAsync <AssetAlreadyExistsException>(() => availabilityService.CreateAssetEnquiry(request));

                Assert.Equal(string.Format(ExceptionMessage.ASSET_ENQUIRY_ALREADY_EXISTS, AssetEnquiryConstants.EXISTING_EXTERNAL_ID), result.Message);
            }
        }
예제 #2
0
        public async Task CreateAssetEnquiry_ShouldReturn_Successfully_AfterCreatingAssetEnquriy_InDb()
        {
            var request = new TrackAReportRequest {
                ReferenceNumber = AssetEnquiryConstants.NEW_ENQIRY, AssetId = "123", AssetType = EAssetType.StreetLightFault
            };

            using (var db = new InthubContext(ContextOptions))
            {
                var availabilityService = CreateAssetEnquiryService(db);

                await availabilityService.CreateAssetEnquiry(request);

                var assetEnquiry = db.AssetEnquiries
                                   .FirstOrDefault(_ => _.ExternalReference == request.ReferenceNumber);
                Assert.NotNull(assetEnquiry);
            }
        }
예제 #3
0
 public async Task <HttpResponseMessage> AssetEnquiry(TrackAReportRequest model) =>
 await PostAsync(AssetEnquiryEndpoint, model);