Esempio n. 1
0
        public AddAttributeSetResponseModel AddAttributeSet(VirtualCardModel virtualCard,
                                                            AuctionHeaderModel auctionHeader)
        {
            AddAttributeSetResponseModel addAttributeSetResponse = default;

            using (ConsoleCapture capture = new ConsoleCapture())
            {
                try
                {
                    string        loyaltyId    = virtualCard?.LOYALTYIDNUMBER ?? string.Empty;
                    AuctionHeader attributeSet = null;
                    if (auctionHeader != null)
                    {
                        attributeSet = new AuctionHeader()
                        {
                            AuctionEventName = auctionHeader.AuctionEventName,
                            AuctionPointType = auctionHeader.AuctionPointType,
                            AuctionTxnType   = auctionHeader.AuctionTxnType,
                            CDRewardID       = auctionHeader.CDRewardID,
                            HeaderGPRpts     = auctionHeader.HeaderGPRpts
                        };

                        if (virtualCard != null)
                        {
                            attributeSet.AddTransientProperty("VcKey", virtualCard.VCKEY);
                        }
                    }

                    var lwAddAttributeSet = lwSvc.AddAttributeSet(loyaltyId,
                                                                  attributeSet, String.Empty, out double time);
                    if (lwAddAttributeSet != null)
                    {
                        addAttributeSetResponse = new AddAttributeSetResponseModel()
                        {
                            EarnedPoints = lwAddAttributeSet
                                           .EarnedPoints
                                           .Select(x => new EarnedPointResponseModel()
                            {
                                PointType  = x.PointType,
                                PointValue = (decimal)(x.PointValue ?? 0)
                            })
                                           .ToList()
                        };
                    }
                }
                catch (LWClientException ex)
                {
                    throw new LWServiceException(ex.Message, ex.ErrorCode);
                }
                catch (Exception ex)
                {
                    throw new LWServiceException(ex.Message, -1);
                }
                finally
                {
                    stepContext.AddAttachment(new Attachment("AddAttributeSet", capture.Output, Attachment.Type.Text));
                }
            }
            return(addAttributeSetResponse);
        }
Esempio n. 2
0
        public void AddAttributeSet_Positive(MemberModel member,
                                             AuctionHeaderModel auctionHeaderRequestModel,
                                             IHertzTier tier, bool useRanum)
        {
            MemberController memController = new MemberController(Database, TestStep);

            try
            {
                //Generate unique LIDs for each virtual card in the member
                member = memController.AssignUniqueLIDs(member);
                string ranum;

                TestStep.Start($"Make AddMember Call", "Source Member should be added successfully");
                MemberModel memberOut = memController.AddMember(member);
                AssertModels.AreEqualOnly(member, memberOut, MemberModel.BaseVerify);
                TestStep.Pass("Source Member was added successfully and member object was returned", memberOut.ReportDetail());
                VirtualCardModel vc = memberOut.VirtualCards.First();

                //Transactions are added to test the API with ranum and also to test the negative points scenario
                TestStep.Start($"Add Transaction to the source member", "Transactions added successfully");
                vc.Transactions = TxnHeaderController.GenerateRandomTransactions(vc, tier.ParentProgram, 1, 500);
                if (useRanum)
                {
                    ranum = vc.Transactions.Select(x => x.A_RANUM).First();
                }
                else
                {
                    ranum = null;
                }
                Assert.IsNotNull(vc.Transactions, "Expected populated transaction object, but transaction object returned was null");
                TestStep.Pass("Transaction added to the source member", vc.Transactions.ReportDetail());

                TestStep.Start("Update Existing Source Member with added transaction", "Source Member object should be returned from UpdateMember call");
                MemberModel updatedMember = memController.UpdateMember(memberOut);
                Assert.IsNotNull(updatedMember, "Expected non null Member object to be returned");
                TestStep.Pass("Member object returned from UpdateMember API call", updatedMember.ReportDetail());

                TestStep.Start($"Make AddAttributeSet Call", "AddAttributeSet call should return AddAttributeSet object");
                AddAttributeSetResponseModel addAttributeSetResponseModel = memController.AddAttributeSet(vc, auctionHeaderRequestModel);
                Assert.IsNotNull(addAttributeSetResponseModel, "Expected populated AddAttributeSetResponseModel object, but AddAttributeSetResponseModel object returned was null");
                Assert.IsNotNull(addAttributeSetResponseModel.EarnedPoints, "Expected populated EarnedPoints list object, but it was null");
                TestStep.Pass("AddAttributeSetResponseModel object was returned", addAttributeSetResponseModel.EarnedPoints.ReportDetail());

                TestStep.Start($"Verify AuctionHeader ", "AuctionHeader returned should be correct");
                Assert.AreNotEqual(0, addAttributeSetResponseModel.EarnedPoints.Count);
                Assert.AreEqual(auctionHeaderRequestModel.HeaderGPRpts, Math.Abs(addAttributeSetResponseModel.EarnedPoints.FirstOrDefault().PointValue));
                TestStep.Pass("AuctionHeader response is as expcted", addAttributeSetResponseModel.EarnedPoints.ReportDetail());
            }
            catch (AssertionException ex)
            {
                TestStep.Fail(ex.Message);
                Assert.Fail();
            }
            catch (LWServiceException ex)
            {
                TestStep.Fail(ex.Message, new[] { $"Error Code: {ex.ErrorCode}", $"Error Message: {ex.ErrorMessage}" });
                Assert.Fail();
            }
            catch (AssertModelEqualityException ex)
            {
                TestStep.Fail(ex.Message, ex.ComparisonFailures);
                Assert.Fail();
            }
            catch (Exception ex)
            {
                TestStep.Abort(ex.Message);
                Assert.Fail();
            }
        }