Esempio n. 1
0
 protected abstract Task <Event> InsertTestOpportunity(string testDatasetIdentifier, OpportunityType opportunityType, TestOpportunityCriteriaEnumeration criteria, TestOpenBookingFlowEnumeration openBookingFlow, SellerIdComponents seller);
Esempio n. 2
0
 protected abstract Task <TComponents> CreateOpportunityWithinTestDataset(string testDatasetIdentifier, OpportunityType opportunityType, TestOpportunityCriteriaEnumeration criteria, TestOpenBookingFlowEnumeration openBookingFlow, SellerIdComponents seller);
Esempio n. 3
0
        protected override async Task <FacilityOpportunity> CreateOpportunityWithinTestDataset(
            string testDatasetIdentifier,
            OpportunityType opportunityType,
            TestOpportunityCriteriaEnumeration criteria,
            TestOpenBookingFlowEnumeration openBookingFlow,
            SellerIdComponents seller)
        {
            if (!_appSettings.FeatureFlags.SingleSeller && !seller.SellerIdLong.HasValue)
            {
                throw new OpenBookingException(new OpenBookingError(), "Seller must have an ID in Multiple Seller Mode");
            }

            long?sellerId         = _appSettings.FeatureFlags.SingleSeller ? null : seller.SellerIdLong;
            var  requiresApproval = openBookingFlow == TestOpenBookingFlowEnumeration.OpenBookingApprovalFlow;

            switch (opportunityType)
            {
            case OpportunityType.FacilityUseSlot:
                int facilityId, slotId;
                switch (criteria)
                {
                case TestOpportunityCriteriaEnumeration.TestOpportunityBookable:
                case TestOpportunityCriteriaEnumeration.TestOpportunityOfflineBookable:
                    (facilityId, slotId) = await FakeBookingSystem.Database.AddFacility(
                        testDatasetIdentifier,
                        sellerId,
                        "[OPEN BOOKING API TEST INTERFACE] Bookable Facility",
                        rnd.Next(2) == 0? 0M : 14.99M,
                        10,
                        requiresApproval);

                    break;

                case TestOpportunityCriteriaEnumeration.TestOpportunityBookableCancellable:
                case TestOpportunityCriteriaEnumeration.TestOpportunityBookableNonFree:
                case TestOpportunityCriteriaEnumeration.TestOpportunityBookableUsingPayment:
                    (facilityId, slotId) = await FakeBookingSystem.Database.AddFacility(
                        testDatasetIdentifier,
                        sellerId,
                        "[OPEN BOOKING API TEST INTERFACE] Bookable Paid Facility",
                        14.99M,
                        10,
                        requiresApproval);

                    break;

                case TestOpportunityCriteriaEnumeration.TestOpportunityBookableFree:
                    (facilityId, slotId) = await FakeBookingSystem.Database.AddFacility(
                        testDatasetIdentifier,
                        sellerId,
                        "[OPEN BOOKING API TEST INTERFACE] Bookable Free Facility",
                        0M,
                        10,
                        requiresApproval);

                    break;

                case TestOpportunityCriteriaEnumeration.TestOpportunityBookableWithinValidFromBeforeStartDate:
                case TestOpportunityCriteriaEnumeration.TestOpportunityBookableOutsideValidFromBeforeStartDate:
                {
                    var isValid = criteria == TestOpportunityCriteriaEnumeration.TestOpportunityBookableWithinValidFromBeforeStartDate;
                    (facilityId, slotId) = await FakeBookingSystem.Database.AddFacility(
                        testDatasetIdentifier,
                        sellerId,
                        $"[OPEN BOOKING API TEST INTERFACE] Bookable Paid Facility {(isValid ? "Within" : "Outside")} Window",
                        14.99M,
                        10,
                        requiresApproval,
                        validFromStartDate : isValid);
                }
                break;

                case TestOpportunityCriteriaEnumeration.TestOpportunityBookableCancellableWithinWindow:
                case TestOpportunityCriteriaEnumeration.TestOpportunityBookableCancellableOutsideWindow:
                {
                    var isValid = criteria == TestOpportunityCriteriaEnumeration.TestOpportunityBookableCancellableWithinWindow;
                    (facilityId, slotId) = await FakeBookingSystem.Database.AddFacility(
                        testDatasetIdentifier,
                        sellerId,
                        $"[OPEN BOOKING API TEST INTERFACE] Bookable Paid Facility {(isValid ? "Within" : "Outside")} Cancellation Window",
                        14.99M,
                        10,
                        requiresApproval,
                        latestCancellationBeforeStartDate : isValid);
                }
                break;

                case TestOpportunityCriteriaEnumeration.TestOpportunityBookableNonFreePrepaymentOptional:
                    (facilityId, slotId) = await FakeBookingSystem.Database.AddFacility(
                        testDatasetIdentifier,
                        sellerId,
                        "[OPEN BOOKING API TEST INTERFACE] Bookable Paid Facility Prepayment Optional",
                        14.99M,
                        10,
                        requiresApproval,
                        prepayment : RequiredStatusType.Optional);

                    break;

                case TestOpportunityCriteriaEnumeration.TestOpportunityBookableNonFreePrepaymentUnavailable:
                    (facilityId, slotId) = await FakeBookingSystem.Database.AddFacility(
                        testDatasetIdentifier,
                        sellerId,
                        "[OPEN BOOKING API TEST INTERFACE] Bookable Paid Facility Prepayment Unavailable",
                        14.99M,
                        10,
                        requiresApproval,
                        prepayment : RequiredStatusType.Unavailable);

                    break;

                case TestOpportunityCriteriaEnumeration.TestOpportunityBookableNonFreePrepaymentRequired:
                    (facilityId, slotId) = await FakeBookingSystem.Database.AddFacility(
                        testDatasetIdentifier,
                        sellerId,
                        "[OPEN BOOKING API TEST INTERFACE] Bookable Paid Facility Prepayment Required",
                        14.99M,
                        10,
                        requiresApproval,
                        prepayment : RequiredStatusType.Required);

                    break;

                case TestOpportunityCriteriaEnumeration.TestOpportunityBookableNoSpaces:
                    (facilityId, slotId) = await FakeBookingSystem.Database.AddFacility(
                        testDatasetIdentifier,
                        sellerId,
                        "[OPEN BOOKING API TEST INTERFACE] Bookable Free Facility No Spaces",
                        14.99M,
                        0,
                        requiresApproval);

                    break;

                case TestOpportunityCriteriaEnumeration.TestOpportunityBookableFiveSpaces:
                    (facilityId, slotId) = await FakeBookingSystem.Database.AddFacility(
                        testDatasetIdentifier,
                        sellerId,
                        "[OPEN BOOKING API TEST INTERFACE] Bookable Free Facility Five Spaces",
                        14.99M,
                        5,
                        requiresApproval);

                    break;

                case TestOpportunityCriteriaEnumeration.TestOpportunityBookableOneSpace:
                    (facilityId, slotId) = await FakeBookingSystem.Database.AddFacility(
                        testDatasetIdentifier,
                        sellerId,
                        "[OPEN BOOKING API TEST INTERFACE] Bookable Free Facility One Space",
                        14.99M,
                        1,
                        requiresApproval);

                    break;

                case TestOpportunityCriteriaEnumeration.TestOpportunityBookableNonFreeTaxNet:
                    (facilityId, slotId) = await FakeBookingSystem.Database.AddFacility(
                        testDatasetIdentifier,
                        2,
                        "[OPEN BOOKING API TEST INTERFACE] Bookable Paid Facility Tax Net",
                        14.99M,
                        10,
                        requiresApproval);

                    break;

                case TestOpportunityCriteriaEnumeration.TestOpportunityBookableNonFreeTaxGross:
                    (facilityId, slotId) = await FakeBookingSystem.Database.AddFacility(
                        testDatasetIdentifier,
                        1,
                        "[OPEN BOOKING API TEST INTERFACE] Bookable Paid Facility Tax Gross",
                        14.99M,
                        10,
                        requiresApproval);

                    break;

                case TestOpportunityCriteriaEnumeration.TestOpportunityBookableSellerTermsOfService:
                    (facilityId, slotId) = await FakeBookingSystem.Database.AddFacility(
                        testDatasetIdentifier,
                        1,
                        "[OPEN BOOKING API TEST INTERFACE] Bookable Facility With Seller Terms Of Service",
                        14.99M,
                        10,
                        requiresApproval);

                    break;

                case TestOpportunityCriteriaEnumeration.TestOpportunityBookableAttendeeDetails:
                    (facilityId, slotId) = await FakeBookingSystem.Database.AddFacility(
                        testDatasetIdentifier,
                        1,
                        "[OPEN BOOKING API TEST INTERFACE] Bookable Facility That Requires Attendee Details",
                        14.99M,
                        10,
                        requiresApproval,
                        requiresAttendeeValidation : true);

                    break;

                case TestOpportunityCriteriaEnumeration.TestOpportunityBookableAdditionalDetails:
                    (facilityId, slotId) = await FakeBookingSystem.Database.AddFacility(
                        testDatasetIdentifier,
                        sellerId,
                        "[OPEN BOOKING API TEST INTERFACE] Bookable Paid Facility That Requires Additional Details",
                        10M,
                        10,
                        requiresApproval,
                        requiresAdditionalDetails : true);

                    break;

                case TestOpportunityCriteriaEnumeration.TestOpportunityBookableWithNegotiation:
                    (facilityId, slotId) = await FakeBookingSystem.Database.AddFacility(
                        testDatasetIdentifier,
                        sellerId,
                        "[OPEN BOOKING API TEST INTERFACE] Bookable Paid Facility That Allows Proposal Amendment",
                        10M,
                        10,
                        requiresApproval,
                        allowProposalAmendment : true);

                    break;

                case TestOpportunityCriteriaEnumeration.TestOpportunityBookableNotCancellable:
                    (facilityId, slotId) = await FakeBookingSystem.Database.AddFacility(
                        testDatasetIdentifier,
                        sellerId,
                        "[OPEN BOOKING API TEST INTERFACE] Bookable Facility Paid That Does Not Allow Full Refund",
                        10M,
                        10,
                        requiresApproval,
                        allowCustomerCancellationFullRefund : false);

                    break;

                case TestOpportunityCriteriaEnumeration.TestOpportunityBookableInPast:
                    (facilityId, slotId) = await FakeBookingSystem.Database.AddFacility(
                        testDatasetIdentifier,
                        sellerId,
                        "[OPEN BOOKING API TEST INTERFACE] Bookable Facility in the Past",
                        10M,
                        10,
                        requiresApproval,
                        allowCustomerCancellationFullRefund : false,
                        inPast : true);

                    break;

                default:
                    throw new OpenBookingException(new OpenBookingError(), "testOpportunityCriteria value not supported");
                }

                return(new FacilityOpportunity
                {
                    OpportunityType = opportunityType,
                    FacilityUseId = facilityId,
                    SlotId = slotId
                });

            default:
                throw new OpenBookingException(new OpenBookingError(), "Opportunity Type not supported");
            }
        }
Esempio n. 4
0
        async Task <Event> IOpportunityStore.CreateOpportunityWithinTestDataset(string testDatasetIdentifier, OpportunityType opportunityType, TestOpportunityCriteriaEnumeration criteria, TestOpenBookingFlowEnumeration openBookingFlow, SellerIdComponents seller)
        {
            var components = await CreateOpportunityWithinTestDataset(testDatasetIdentifier, opportunityType, criteria, openBookingFlow, seller);

            return(OrderCalculations.RenderOpportunityWithOnlyId(opportunityType, RenderOpportunityId(components)));
        }