locked
System.NullReferenceException: Object reference not set to an instance of object RRS feed

  • Question

  • Am getting the run time errror like "System.NullReferenceException: Object reference not set to an instance of object".

    for the below code in C#.Please help me out in this.

    [TestMethod]
            public void IAVEmptyGC()
            {
                int addValueAmount = 100;
                int currentBalance = 0;
                ServiceV1 serviceV1 = new ServiceV1();
                GiftCardPurchase purchaseCard = CardUtility.GetGiftCardPurchase(CardType.GiftCard,CardStatus.Inactive, currentBalance, CurrencyType.Usd, "802413");
                purchaseCard.Cost = addValueAmount;
                PosSource pos = SourceProvider.NewPosSource(TestStore.US);
                v2.NGAddValueRequest addValueRequest =
                NGAddValueRequestBuilder.BuildRequest(AddValueActivityType.InitialPurchaseWithoutHold, purchaseCard, pos);
                /*v2.AccountNumber invalidAccountNumber = new v2.AccountNumber();
                invalidAccountNumber.Value = null;*/
                ////Overwrite the card to a non gift card number
                CertificateTenderRequest certificateTenderRequest =
                    NGToCertificateTenderRequestMapper.MapNgAddValueRequest(addValueRequest);
               
                //// Overwrite request with invalid reason code
                certificateTenderRequest.CertificateTenderItems[0].AccountNumber = null;
                CertificateTenderResponse certificateTenderResponse = serviceV1.AddValueAuth(certificateTenderRequest);
                AuthResponse response = new AuthResponse(certificateTenderResponse);         

                ///// overwrite account number with null value
              AssertHelpers.AssertServiceResponse(response, ResponseReasonCode.CardNotOnFile);
            }

    Monday, April 13, 2015 12:07 PM