static IList <ITask> CreateTasks(IObjectHelper testDataSetHelper, IContact assignedTo, int recordsCount)
        {
            Random        rndGenerator = new Random();
            IList <ITask> taskList     = new List <ITask>();

            for (int i = 0; i < recordsCount; i++)
            {
                var task = testDataSetHelper.CreateTask();
                task.Subject     = $"Task №{i}";
                task.Description = $"Task for the {assignedTo?.FirstName} № {i}";
                int rndStatus = rndGenerator.Next(0, 5);
                task.Status             = (TaskStatus)rndStatus;
                task.DueDate            = DateTime.Now.AddHours((90 - rndStatus * 9) + 24).Date;
                task.EstimatedWorkHours = rndGenerator.Next(10, 20);
                if (task.Status == TaskStatus.WaitingForSomeoneElse ||
                    task.Status == TaskStatus.Completed ||
                    task.Status == TaskStatus.InProgress)
                {
                    task.StartDate       = DateTime.Now.AddHours(-rndGenerator.Next(720)).Date;
                    task.ActualWorkHours = rndGenerator.Next(task.EstimatedWorkHours - 10, task.EstimatedWorkHours + 10);
                }
                task.DueDate = DateTime.Now.AddHours((90 - rndStatus * 9) + 24).Date;
                task.SetAssignedTo(assignedTo);
                task.Priority = (Priority)rndGenerator.Next(3);
                taskList.Add(task);
            }
            return(taskList);
        }
        static IPhoneNumber GetPhoneNumber(IContact contact, IObjectHelper objectHelper)
        {
            IPhoneNumber phoneNumber = objectHelper.CreatePhoneNumber(contact);

            phoneNumber.Number    = "+0 000 111 222 333";
            phoneNumber.PhoneType = "Work";
            return(phoneNumber);
        }
        static IPosition GetPosition(IContact contact, IObjectHelper objectHelper)
        {
            string    positionTitle = "a pretty good job for a really good guy";
            IPosition position      = objectHelper.CreatePosition();

            position.Title = positionTitle;
            if (contact.Department != null)
            {
                position.AddDepartment(contact.Department);
                contact.Department.AddPositions(position);
            }
            contact.SetPosition(position);
            return(position);
        }
        static IAddress GetAddress(IContact contact, IObjectHelper objectHelper)
        {
            IAddress address = objectHelper.CreateAddress();

            address.ZipPostal     = "000111222333";
            address.Street        = "Maksima Gorkogo";
            address.City          = "Tula";
            address.StateProvince = "SomeProvince";
            contact.SetAddress1(address);
            string   countryName = "YourCountryNameHere";
            ICountry country     = objectHelper.CreateCountry(address);

            country.Name = countryName;
            return(address);
        }
        public static void FillContact(this IObjectHelper objectHelper, IContact contact, IDepartment department, int index)
        {
            contact.Email     = $"{Contact_EmailPrefix}{index}.com";
            contact.FirstName = $"{Contact_FirstNamePrefix}{index}";
            contact.LastName  = $"{Contact_LastNamePrefix}{index}";
            contact.Birthday  = RandomBirthday(new Random());

            contact.SetDepartment(department);
            //contact.Photo = a picture from somewhere could be here;

            contact.TitleOfCourtesy = TitleOfCourtesy.Mr;

            _ = GetPhoneNumber(contact, objectHelper);
            _ = GetAddress(contact, objectHelper);
            _ = GetPosition(contact, objectHelper);
        }
コード例 #6
0
 public LicenceGenerator()
 {
     _objectHelper     = ObjectHelperFactory.GetObjectHelperFactory();
     _encryptionHelper = EncryptionHelperFactory.GetEncryptionHelper();
 }
コード例 #7
0
        public AssetValidator(IStringLocalizer stringLocalizer, ICountryService countryService, IObjectHelper objectHelper)
        {
            RuleFor(m => m.AssetName).NotEmpty().WithMessage(stringLocalizer["asset.assetname.empty"])
            .MinimumLength(10).WithMessage(stringLocalizer["asset.assetname.minlength"]);

            RuleFor(m => m.CountryOfDepartment).NotEmpty().WithMessage(stringLocalizer["asset.countryofdepartment.empty"]);

            RuleFor(m => m.CountryOfDepartment).Must(country => countryService.ExistsCountry(country))
            .WithMessage(stringLocalizer["asset.countryofdepartment.valid"]);

            RuleFor(m => m.PurchaseDate).Must(purchaseDate => objectHelper.IsNotOlderThanOneYear(purchaseDate))
            .WithMessage(stringLocalizer["asset.purchasedate.olderthanayear"]);

            RuleFor(m => m.EMailAdressOfDepartment)
            .EmailAddress().WithMessage(stringLocalizer["asset.emailadressofdepartment.valid"])
            .NotEmpty().WithMessage(stringLocalizer["asset.emailadressofdepartment.empty"]);
        }
 public static void FillContact(this IObjectHelper objectHelper, IContact contact, int index)
 {
     objectHelper.FillContact(contact, null, index);
 }
コード例 #9
0
 public LicenceValidator(ISerialGenerator serialGenerator)
 {
     _serialGenerator  = serialGenerator;
     _encryptionHelper = EncryptionHelperFactory.GetEncryptionHelper();
     _objectHelper     = ObjectHelperFactory.GetObjectHelperFactory();
 }
コード例 #10
0
        public void Setup()
        {
            base.SetUp();

            _objectHelper = (IObjectHelper)_services.GetService(typeof(IObjectHelper));
        }