Example #1
0
        public Person(IApplicationDbContext applicationDbContext)
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("nl-NL");

            _applicationDbContext = applicationDbContext;
            _personValidation     = new PersonValidation();
        }
Example #2
0
        public void PersonValidation_Has_NoError_When_FullyPopulated()
        {
            var sut = new PersonValidation();

            sut.ShouldHaveValidationErrorFor(x => x.Name, new Person {
                Language = "English"
            });
        }
Example #3
0
        public void PersonValidation_Has_Error_When_Whitespace_Language()
        {
            var sut = new PersonValidation();

            sut.ShouldHaveValidationErrorFor(x => x.Language, new Person {
                Language = " ", Name = "Test"
            });
        }
Example #4
0
        public void PersonValidation_Has_Error_When_Empty_Language()
        {
            var sut = new PersonValidation();

            sut.ShouldHaveValidationErrorFor(x => x.Language, new Person {
                Language = string.Empty, Name = "Test"
            });
        }
Example #5
0
        public void PersonValidation_Has_Error_When_Whitespace_Name()
        {
            var sut = new PersonValidation();

            sut.ShouldHaveValidationErrorFor(x => x.Name, new Person {
                Name = " ", Language = "English"
            });
        }
Example #6
0
        public void PersonValidation_Has_Error_When_Empty_Name()
        {
            var sut = new PersonValidation();

            sut.ShouldHaveValidationErrorFor(x => x.Name, new Person {
                Name = string.Empty, Language = "English"
            });
        }
Example #7
0
        public DataTests(ITestOutputHelper output)
        {
            var databaseName = Guid.NewGuid().ToString();

            _context = new MockData().SetupContext(databaseName);

            _logger = new NullLogger <dynamic>();

            _validator = new PersonValidation();
        }
Example #8
0
        public void CheckCreateValuesTestNotMissing()
        {
            ValueUtils       vu = new ValueUtils();
            PersonValidation pv = new PersonValidation(vu);


            String str = "";

            PersonViewModelSave PVmodel = new PersonViewModelSave();

            PVmodel.PersonNummer = "12345";
            PVmodel.ForNamn      = "Per";
            PVmodel.EfterNamn    = "Nilsson";

            Assert.True(pv.CheckCreateValues(PVmodel, ref str));
        }
Example #9
0
        public void CheckCreateValuesTestNotValidPersnr()
        {
            ValueUtils       vu = new ValueUtils();
            PersonValidation pv = new PersonValidation(vu);


            String str = "";

            PersonViewModelSave PVmodel = new PersonViewModelSave();

            PVmodel.PersonNummer = "12";
            PVmodel.ForNamn      = "Per";
            PVmodel.EfterNamn    = "Nilsson";

            Assert.True(pv.CheckCreateValues(PVmodel, ref str) == false);

            Assert.True(str == "Not a valid PersonNummer:");
        }
Example #10
0
 private void Validate()
 {
     ValidSpecification = new PersonValidation <object>();
     ValidSpecification.IsSatisfiedBy(this);
 }
        public IActionResult CreateTest(CreateEmployee createEmployee)
        {
            string           employeeCode     = "";
            string           emailAddress     = "";
            string           mobileNumber     = "";
            PersonValidation personValidation = new PersonValidation
            {
                RoleValidation              = "",
                LocationValidation          = "",
                WeeklyOffValidation         = "",
                EmployeeCodeCheckValidation = "",
                MobileValidation            = "",
                ProbationValidation         = "",
                EmailValidation             = ""
            };

            if (createEmployee.people.RoleId == 0)
            {
                personValidation.RoleValidation = "Please Select Role";
            }
            if (createEmployee.people.LocationId == 0)
            {
                personValidation.LocationValidation = "Please Select Location";
            }
            if (createEmployee.people.WeeklyOffId == 0)
            {
                personValidation.WeeklyOffValidation = "Please Select Weekly Off Type";
            }
            if (createEmployee.people.IsOnProbation == true && createEmployee.people.PropbationPeriodInMonth == null)
            {
                personValidation.ProbationValidation = "Please Select Probation Period";
            }
            if (createEmployee.people.EmployeeCode == null)
            {
                employeeCode = "0";
            }
            else
            {
                employeeCode = createEmployee.people.EmployeeCode;
            }
            if (createEmployee.people.MobileNumber == null)
            {
                mobileNumber = "0";
            }
            else
            {
                mobileNumber = createEmployee.people.MobileNumber;
            }
            if (createEmployee.people.EmailAddress == null)
            {
                emailAddress = "*****@*****.**";
            }
            else
            {
                emailAddress = createEmployee.people.EmailAddress;
            }
            HttpResponseMessage response = _service.GetResponse(ApiUrl + "/api/employee/Employee/CheckEmployee/" + employeeCode + "/" + emailAddress + "/" + mobileNumber);
            string stringData            = response.Content.ReadAsStringAsync().Result;

            string[] data = JsonConvert.DeserializeObject <string[]>(stringData);
            if (data[0] == "InValid")
            {
                personValidation.EmployeeCodeCheckValidation = "Employee Code already exist";
            }
            if (data[1] == "InValid")
            {
                personValidation.EmailValidation = "Email Address already exist";
            }
            if (data[2] == "InValid")
            {
                personValidation.MobileValidation = "Mobile Number already exist";
            }
            return(Json(personValidation));
        }
Example #12
0
 public PersonController(CombisContext context, ILogger <PersonController> logger)
 {
     _logger    = logger ?? throw new ArgumentNullException(nameof(logger));
     _validator = new PersonValidation();
     _handler   = new PersonHandler(context, _logger);
 }
Example #13
0
 public ValidationTests()
 {
     _validator = new PersonValidation();
 }