コード例 #1
0
        public void CheckIfTwoDigitYearWillBeCorrectlyDetected()
        {
            var testDate       = "29.02.20";
            var dateValidation = new DateValidation();
            //act
            var result = dateValidation.ValidateDate(testDate);

            //assert
            Assert.IsFalse(result);
        }
コード例 #2
0
        public void CheckIfLeapYearWillBeDetected()
        {
            //arrange
            var testDate       = "29.02.2020";
            var dateValidation = new DateValidation();
            //act
            var result = dateValidation.ValidateDate(testDate);

            //assert
            Assert.IsTrue(result);
        }
コード例 #3
0
        public void CheckIfNotRecognizedCultureWillBeDetected()
        {
            //arrange
            var testDateUS     = "12.20.2010";
            var culture        = "test";
            var dateValidation = new DateValidation(culture);

            //act
            var result = dateValidation.ValidateDate(testDateUS);

            //assert
            Assert.IsFalse(result);
        }
コード例 #4
0
        public void CheckIfDateIsInvalidFor_EUCulture()
        {
            //arrange
            var testDateUS     = "12.20.2010";
            var culture        = "eu";
            var dateValidation = new DateValidation(culture);

            //act
            var result = dateValidation.ValidateDate(testDateUS);

            //assert
            Assert.IsFalse(result);
        }
コード例 #5
0
        public void CheckIfDateIsValidFor_USCulture()
        {
            //arrange
            var testDateUS     = "12.21.2010";
            var culture        = "us";
            var dateValidation = new DateValidation(culture);

            //act
            var result = dateValidation.ValidateDate(testDateUS);

            //assert
            Assert.IsTrue(result);
        }
コード例 #6
0
        private bool ValidateForm()
        {
            // TODO - check if Item already exists
            bool output = true;

            errorsItem.Clear();

            // Item validation - check if exists one already
            //if (SqlConnector.CheckIfItemExists(itemItemText.Text, itemAssetText.Text).Count != 0)
            //{
            //    output = false;
            //    errorsItem.Add($"{ itemItemText.Text } { itemAssetText.Text } already exists");
            //}

            // asset validation
            if (itemAssetText.Text.Length > 20)
            {
                output = false;
                errorsItem.Add("Asset Length should be <= 20");
            }

            // Arrived validation
            DateValidation dateValidation = new DateValidation(itemArrivedText.Text);

            if (itemArrivedText.Text.Length == 0)
            {
                output = false;
                errorsItem.Add("Date couldn't be empty");
            }
            if (itemArrivedText.Text.Length > 10)
            {
                output = false;
                errorsItem.Add("Date Length should be 10 simbols");
            }
            if (!dateValidation.ValidateDate())
            {
                output = false;
                errorsItem.Add("Wrong Date pattern");
            }

            // Invoice validation
            InvoiceValidation invoiceValidation = new InvoiceValidation(itemInvoiceText.Text);

            if (itemInvoiceText.Text.Length == 0)
            {
                output = false;
                errorsItem.Add("Invoice couldn't be empty");
            }
            if (itemInvoiceText.Text.Length > 10)
            {
                output = false;
                errorsItem.Add("Invoice Length should be <= 10");
            }
            if (!invoiceValidation.ValidateInvoice())
            {
                output = false;
                errorsItem.Add("Wrong Invoice pattern, should be like X/MM/YY");
            }

            // ccd validation
            CCDValidation ccdValidation = new CCDValidation(itemCcdText.Text);

            if (itemCcdText.Text.Length == 0)
            {
                output = false;
                errorsItem.Add("CCD couldn't be empty");
            }
            if (itemCcdText.Text.Length > 25)
            {
                output = false;
                errorsItem.Add("CCD Length should be <= 25");
            }
            if (!ccdValidation.ValidateCCD())
            {
                output = false;
                errorsItem.Add("Wrong CCD pattern");
            }

            // positionCCD validation
            int  positionInCCD        = 0;
            bool positionrValidNumber = int.TryParse(itemPositionCcdText.Text, out positionInCCD);

            if (positionrValidNumber == false)
            {
                output = false;
                errorsItem.Add("Wrong Position number");
            }

            // status validation
            if (itemStatusText.Text.Length > 20)
            {
                output = false;
                errorsItem.Add("Item Status is Tool long, should be <= 20");
            }

            // container validation
            if (itemContainerText.Text.Length > 10)
            {
                output = false;
                errorsItem.Add("Container Name Too long");
            }

            return(output);
        }