Пример #1
0
        /// <summary>
        /// Sets <see cref="Location"/> to the specified pincode.
        /// </summary>
        /// <param name="pincode">The pincode.</param>
        public void SetPincode(string pincode)
        {
            if (!AadhaarHelper.ValidatePincode(pincode))
            {
                throw new ArgumentOutOfRangeException(nameof(pincode), InvalidPincode);
            }

            Location     = pincode;
            LocationType = LocationType.Pincode;
        }
        public void ValidatePincodeTest()
        {
            var inside  = new[] { "000000", "999999" };
            var outside = new[] { null, string.Empty, "9999999", "999 999" };

            // Valid Tests.
            foreach (var aadhaarNumber in inside)
            {
                Assert.True(AadhaarHelper.ValidatePincode(aadhaarNumber));
            }

            // Invalid Tests.
            foreach (var aadhaarNumber in outside)
            {
                Assert.False(AadhaarHelper.ValidatePincode(aadhaarNumber));
            }
        }