jyoung's blog

CContact.NewAddress(string purpose) behavior

One would think that calling CContact.NewAddress("somePurpose") would give you a CAddress with the purpose you specified.  However, that is not the case.  The following NUnit demo passes:

[Test, Explicit("Just a demonstration of weird iMIS behavior.")]
public void Demo_NewAddressDoesNotSetPurpose()
{
    var imisContact = new CContact(user)
    {
        Prefix = Prefix,
        FirstName = FirstName,
        MiddleName = MiddleName,
        LastName = LastName,
        Suffix = Suffix
    };

    var address = imisContact.NewAddress(TestAddressPurpose);
    var actualPurpose = address.AddressPurpose;
    Assert.IsEmpty(actualPurpose);
}

Asi.iBO.Errors.CErrors.NewError may throw

Since this doesn't seem to be documented anywhere online (particularly in the API documentation), it is worth noting that CErrors.NewError will throw an exception if the ThrowExceptionOnError property of the associated IiMISUser object is set to true (assuming you are creating an Error and not a Warning).  In this case, it will always throw and never return.  At least that's what I gather from digging around in reflector:

Unexpected CPayment behavior

This NUnit TestFixture demonstrates some unexpected behavior in CPayments.  Note that you will need to alter or provide some of the values to run on your machine, if you so choose, but I think you can see by reading this some gotchas to look out for:

using System;
using System.Configuration;

using Asi.iBO;
using Asi.iBO.Financials;
using NUnit.Framework;

namespace Crown.Imis.IntegrationTests
{
    [TestFixture, Explicit("demos")]
    public class CPaymentGotchaDemonstrations
    {
        [TestFixtureSetUp]
        public void TestFixtureSetUp()
        {
            iboAdmin.InitializeSystem(ConfigurationManager.ConnectionStrings["DataSource.iMIS.Connection"].ConnectionString);
        }

        [Test]
        [ExpectedException(typeof(ArgumentOutOfRangeException))]
        public void Demo_Setting_CreditCardNumber_toVisaTestNumberAfterSetting_CashAccountCode_CausesUnhandledException()
        {
            var payment = new CPayment(CStaffUser.GetDefaultStaffUser())
            {
                CashAccountCode = "VISA",
                CreditCardNumber = "4007000000027"  // VISA test number, eh?
            };
        }

        [Test]
        [ExpectedException(typeof(Asi.iBO.InvalidCardNumberException))]
        public void Demo_Setting_CreditCardNumber_to011201539123After_CashAccountCode_Causes_InvalidCardNumberException()
        {
            var payment = new CPayment(CStaffUser.GetDefaultStaffUser())
            {
                CashAccountCode = "VISA",
                CreditCardNumber = "011201539123"   // it's irrelevant how I came up with this number.  No idea yet on what is wrong with it.
            };
        }

        [Test]
        public void Demo_Setting_PaymentType_After_CreditCardNumber_Clears_CreditCardNumber()
        {
            var payment = new CPayment(CStaffUser.GetDefaultStaffUser())
            {
                CreditCardNumber = "4007000000027", // VISA test number
                PaymentType = EnumPaymentType.Check
            };

            Assert.IsNullOrEmpty(payment.CreditCardNumber);
        }

        [Test]
        public void Demo_SettingCashAccountCodeChangesPaymentTypeToCreditWhenCashAccountIsCreditType()
        {
            var payment = new CPayment(CStaffUser.GetDefaultStaffUser());
            payment.PaymentType = EnumPaymentType.Check;
            payment.CashAccountCode = "VISA";

            Assert.AreEqual(EnumPaymentType.CreditCard, payment.PaymentType);
        }
    }
}

Syndicate content