コード例 #1
0
        public void Should_return_empty_dictionary_when_invalid_fields_parameters_passed(string invalidFields)
        {
            var validator = new FieldsValidator();

            var result = validator.GetValidFields(invalidFields, typeof(SimpleTypes));

            Assert.IsEmpty(result);
        }
コード例 #2
0
        public VehicleDetailEditorForm(VehicleDetailEditorModel model)
        {
            InitializeComponent();
            _presenter = new VehicleDetailEditorPresenter(this, model);

            FieldsValidator.SetIconAlignment(txtLicenseNumber, System.Windows.Forms.ErrorIconAlignment.MiddleRight);
            FieldsValidator.SetIconAlignment(dtpExpirationDate, System.Windows.Forms.ErrorIconAlignment.MiddleRight);
        }
コード例 #3
0
        public void Should_return_dictionary_contains_valid_fields_without_underscores_when_valid_fields_parameters_passed(string validFields)
        {
            var validator = new FieldsValidator();

            var result = validator.GetValidFields(validFields, typeof(SimpleTypes));

            Assert.True(result.ContainsKey("firstproperty"));
        }
コード例 #4
0
        public void Should_return_dictionary_with_valid_fields_when_valid_and_invalid_fields_parameters_passed(string mixedFields)
        {
            var validator = new FieldsValidator();

            var result = validator.GetValidFields(mixedFields, typeof(SimpleTypes));

            Assert.AreEqual(2, result.Count);
            Assert.True(result.ContainsKey("firstproperty"));
            Assert.True(result.ContainsKey("secondproperty"));
        }
        public void WhenValidFieldParameterPassed_ShouldReturnDictionaryContainingTheFieldWithoutUnderscores(string validField)
        {
            //Arange
            var cut = new FieldsValidator();

            //Act
            Dictionary <string, bool> result = cut.GetValidFields(validField, typeof(DummyObjectWithSimpleTypes));

            Assert.True(result.ContainsKey("firstproperty"));
        }
        public void WhenOnlyValidFieldsParameterPassed_ShouldReturnNonEmptyDictionary(string validFields)
        {
            //Arange
            var cut = new FieldsValidator();

            //Act
            Dictionary <string, bool> result = cut.GetValidFields(validFields, typeof(DummyObjectWithSimpleTypes));

            Assert.IsNotEmpty(result);
        }
        public void WhenInvalidFieldsWithSpecialSymbolsParameterPassed_ShouldReturnEmptyDictionary(string invalidFields)
        {
            //Arange
            var cut = new FieldsValidator();

            //Act
            Dictionary <string, bool> result = cut.GetValidFields(invalidFields, typeof(DummyObjectWithSimpleTypes));

            Assert.IsEmpty(result);
        }
        public void WhenValidFieldsParameterPassed_ShouldReturnDictionaryContainingEachValidFieldWithLowercase(string validFields)
        {
            //Arange
            var cut = new FieldsValidator();

            //Act
            Dictionary <string, bool> result = cut.GetValidFields(validFields, typeof(DummyObjectWithSimpleTypes));

            Assert.True(result.ContainsKey("firstproperty"));
            Assert.True(result.ContainsKey("secondproperty"));
        }
        public void WhenValidAndInvalidFieldsParameterPassed_ShouldReturnDictionaryWithValidFieldsOnly(string mixedFields)
        {
            //Arange
            var cut = new FieldsValidator();

            //Act
            Dictionary <string, bool> result = cut.GetValidFields(mixedFields, typeof(DummyObjectWithSimpleTypes));

            Assert.AreEqual(2, result.Count);
            Assert.True(result.ContainsKey("firstproperty"));
            Assert.True(result.ContainsKey("secondproperty"));
        }
コード例 #10
0
        public VehicleEditorForm(VehicleEditorModel model)
        {
            InitializeComponent();
            _presenter = new VehicleEditorPresenter(this, model);

            // set validation alignment
            FieldsValidator.SetIconAlignment(lookUpCustomer, System.Windows.Forms.ErrorIconAlignment.MiddleRight);
            FieldsValidator.SetIconAlignment(lookUpBrand, System.Windows.Forms.ErrorIconAlignment.MiddleRight);
            FieldsValidator.SetIconAlignment(lookUpType, System.Windows.Forms.ErrorIconAlignment.MiddleRight);
            FieldsValidator.SetIconAlignment(txtYearOfPurchase, System.Windows.Forms.ErrorIconAlignment.MiddleRight);
            FieldsValidator.SetIconAlignment(txtLicenseNumber, System.Windows.Forms.ErrorIconAlignment.MiddleRight);
            FieldsValidator.SetIconAlignment(txtCode, System.Windows.Forms.ErrorIconAlignment.MiddleRight);
            ValidateExpireDate.SetIconAlignment(dtpExpirationDate, System.Windows.Forms.ErrorIconAlignment.MiddleRight);

            this.Load += VehicleEditorForm_Load;

            //lookupWheelDetailGv.EditValueChanged += lookupWheelDetailGv_EditValueChanged;
            gvVehicleWheel.PopupMenuShowing  += gvVehicleWheel_PopupMenuShowing;
            gvVehicleWheel.FocusedRowChanged += gvVehicleWheel_FocusedRowChanged;

            ////collumn setting for lookup specialSparepart in grid
            //LookUpColumnInfoCollection coll = lookupWheelDetailGv.Columns;

            //coll.Add(new LookUpColumnInfo("SerialNumber", 0, "Nomor Seri"));
            ////coll.Add(new LookUpColumnInfo("SparepartName", 0, "Sparepart"));
            //lookupWheelDetailGv.BestFitMode = BestFitMode.BestFitResizePopup;
            //lookupWheelDetailGv.SearchMode = SearchMode.AutoComplete;
            //lookupWheelDetailGv.AutoSearchColumnIndex = 1;

            //collumn setting for lookup specialSparepart in grid
            _repoItemLookUpEdit = new RepositoryItemLookUpEdit();
            _repoItemLookUpEdit.DisplayMember = "SerialNumber";
            _repoItemLookUpEdit.ValueMember   = "SerialNumber";
            LookUpColumnInfoCollection coll = _repoItemLookUpEdit.Columns;

            coll.Add(new LookUpColumnInfo("SerialNumber", 0, "Nomor Seri"));
            //coll.Add(new LookUpColumnInfo("SparepartName", 0, "Sparepart"));
            _repoItemLookUpEdit.BestFitMode                      = BestFitMode.BestFitResizePopup;
            _repoItemLookUpEdit.SearchMode                       = SearchMode.AutoComplete;
            _repoItemLookUpEdit.AutoSearchColumnIndex            = 1;
            _repoItemLookUpEdit.NullValuePromptShowForEmptyValue = false;
            _repoItemLookUpEdit.EditValueChanged                += _repoItemLookUpEdit_EditValueChanged;

            lookUpCustomer.EditValueChanged += lookUpCustomer_EditValueChanged;

            gvVehicleWheel.CustomRowCellEditForEditing += gvVehicleWheel_CustomRowCellEditForEditing;
        }
コード例 #11
0
 protected override void ExecuteSave()
 {
     if (FieldsValidator.Validate())
     {
         try
         {
             MethodBase.GetCurrentMethod().Info("Save Vehicle Detail's changes");
             _presenter.SaveChanges();
             this.Close();
         }
         catch (Exception ex)
         {
             MethodBase.GetCurrentMethod().Fatal("An error occured while trying to save Vehicle Detail", ex);
             this.ShowError("Proses simpan data Detail Kendaraan gagal!");
         }
     }
 }
コード例 #12
0
 public bool VerifyLoginUser(string userName, string password)
 {
     if (FieldsValidator.IsValidEmail(userName))
     {
         this.UserName        = userName;
         this.SuccessfulLogin = loginRequestService.ValidateLoginUser(userName, password);
         if (this.SuccessfulLogin)
         {
             this.ResultInfo = "Loggin was successful";
         }
         else
         {
             this.ResultInfo = "An error was heppening, login faild";
         }
     }
     else
     {
         this.ResultInfo      = "Invalid email";
         this.SuccessfulLogin = false;
     }
     return(this.SuccessfulLogin);
 }
コード例 #13
0
        protected override void ExecuteSave()
        {
            if (!bgwSave.IsBusy)
            {
                bool   validated  = true;
                string errMessage = "";

                FormHelpers.CurrentMainForm.UpdateStatusInformation("Memeriksa nomor seri yang kembar dalam daftar", false);

                List <string> duplicatedWheel = VehicleWheelList.Where(wh => !string.IsNullOrEmpty(wh.WheelDetail.SerialNumber)).GroupBy(x => x.WheelDetail.SerialNumber)
                                                .Where(group => group.Count() > 1)
                                                .Select(group => group.Key).ToList();

                if (duplicatedWheel.Count > 0)
                {
                    errMessage += "Terdapat ban yang sama! \n";
                    validated   = false;
                }

                FormHelpers.CurrentMainForm.UpdateStatusInformation("Memeriksa kode kendaraan yang kembar pada database", false);

                if (!_presenter.IsCodeValidated())
                {
                    errMessage += "Kode sudah terdaftar! \n";
                    validated   = false;
                }

                FormHelpers.CurrentMainForm.UpdateStatusInformation("Memeriksa nomor polisi yang kembar pada database", false);

                if (!_presenter.IsLicenseNumberValidated())
                {
                    errMessage += "Nopol sudah terdaftar! \n";
                    validated   = false;
                }

                if (FieldsValidator.Validate() && valGroupName.Validate() && validated)
                {
                    FormHelpers.CurrentMainForm.UpdateStatusInformation("Proses Penyimpanan dimulai", false);

                    try
                    {
                        MethodBase.GetCurrentMethod().Info("Save Vehicle's changes");
                        this.Enabled = false;
                        bgwSave.RunWorkerAsync();
                    }
                    catch (Exception ex)
                    {
                        MethodBase.GetCurrentMethod().Fatal("An error occured while trying to save Vehicle", ex);
                        this.ShowError("Proses simpan data Kendaraan gagal!");
                    }
                }
                else
                {
                    this.ShowWarning(errMessage);
                }
            }
            else
            {
                this.Enabled = false;
            }
        }
コード例 #14
0
        public void VeryfyIsValidEmailFalseOnlyText()
        {
            bool expectedResult = FieldsValidator.IsValidEmail("user");

            Assert.AreEqual(expectedResult, false);
        }
コード例 #15
0
        public void VeryfyIsValidEmailFalseWithoutPoint()
        {
            bool expectedResult = FieldsValidator.IsValidEmail("a@a");

            Assert.AreEqual(expectedResult, false);
        }
コード例 #16
0
        public void VeryfyIsValidEmailTrue()
        {
            bool expectedResult = FieldsValidator.IsValidEmail("*****@*****.**");

            Assert.AreEqual(expectedResult, true);
        }