Esempio n. 1
0
        void _CompanyCreate()
        {
            var empTypes = company.EmployeeTypes();
            var rnd      = new Random();

            for (int i = 0; i < 5; i++)
            {
                var tp = empTypes.ElementAt(rnd.Next(3));
                var s0 = company.Add(
                    new Employee()
                {
                    Fio          = tp.Name + "_" + (i + 1),
                    EmployeeType = tp,
                    HiringTime   = DateTime.Now.AddMonths(-rnd.Next(10, 500))
                });

                Assert.NotNull(s0, "Error create user");

                for (int j = 0; j < 10; j++)
                {
                    if (s0.EmployeeType.IsPrimary)
                    {
                        continue;
                    }
                    tp = empTypes.ElementAt(rnd.Next(3));
                    var s1 = company.AddSubordinates(s0,
                                                     new Employee()
                    {
                        Fio          = tp.Name + "_" + (j + 1),
                        EmployeeType = tp,
                        HiringTime   = DateTime.Now.AddMonths(-rnd.Next(10, 500))
                    });
                    Assert.NotNull(s1, "Error create user");

                    for (int k = 0; k < 5; k++)
                    {
                        if (s1.EmployeeType.IsPrimary)
                        {
                            continue;
                        }
                        tp = empTypes.ElementAt(rnd.Next(3));
                        var s2 = company.AddSubordinates(s1,
                                                         new Employee()
                        {
                            Fio          = tp.Name + "_" + (k + 1),
                            EmployeeType = tp,
                            HiringTime   = DateTime.Now.AddMonths(-rnd.Next(10, 500))
                        });

                        Assert.NotNull(s2, "Error create user");
                    }
                }
            }
        }