コード例 #1
0
        public static void Sample()
        {
            Console.WriteLine("---------- Generic.Where ----------");

            Employee emp = new Employee();

            emp.Name = "Test001";
            SubEmployee <Employee> class1 = new SubEmployee <Employee>(emp);

            class1.Print();

            GenericStruct <Struct> gs = new GenericStruct <Struct>();             // ok.
            //GenericStruct<Class> gs_error = new GenericStruct<Class>(); // error
            GenericClass <Class> gc = new GenericClass <Class>();                 // ok.
            //GenericClass<Struct> gc_error = new GenericClass<Struct>(); // error
            GenericNew <New> gn = new GenericNew <New>();                         // ok.
            //GenericNew<Interface> gn_error = new GenericNew<Interface>(); // error
            GenericBase <Base> gb = new GenericBase <Base>();                     // ok.
            //GenericBase<Class> gb_error = new GenericBase<Class>(); // error
            GenericInterface <Interface> gi = new GenericInterface <Interface>(); // ok
            //GenericInterface<Class> gi_error = new GenericInterface<Class>(); // error
            GenericU <TClass, UClass> gu = new GenericU <TClass, UClass>();       // ok

            //GenericU<VClass, UClass> gu_error = new GenericU<VClass, UClass>(); // error

            Console.WriteLine("\n");
        }
コード例 #2
0
        static void Main(string[] args)
        {
            IOutput           stringOutput = new StringOutput();
            EmployeeComponent director     = new Employee("Director", Program.POSITIONS[0], 20);
            EmployeeComponent manager      = new Employee("Manager of storing", POSITIONS[1], 15);
            EmployeeComponent manager2     = new Employee("Manager of marketing", POSITIONS[1], 12);
            EmployeeComponent x            = new SubEmployee("X", POSITIONS[2], 10);
            EmployeeComponent y            = new SubEmployee("Y", POSITIONS[2], 10);
            EmployeeComponent a            = new SubEmployee("A", POSITIONS[2], 10);
            EmployeeComponent b            = new SubEmployee("B", POSITIONS[2], 10);
            EmployeeComponent c            = new Employee("Another one manager", POSITIONS[1], 10);
            EmployeeComponent d            = new SubEmployee("D", POSITIONS[2], 10);

            director.Add(manager, manager2);
            manager.Add(x, y, c);
            manager2.Add(a, b);
            c.Add(d);
            Company company = new Company(director, stringOutput);

            System.Console.WriteLine("----------");
            company.PrintHierarchy();
            System.Console.WriteLine("----------");
            company.PrintAllByPosition("manager");
            System.Console.WriteLine("----------");
            company.PrintAllWithHighestSalaryAndHigherThan(9);
            System.Console.WriteLine("----------");
            company.PrintAllWithParent(manager);
            System.Console.WriteLine("----------");
            company.PrintBackwards();
            System.Console.WriteLine("----------");
            System.Console.ReadKey();
        }
コード例 #3
0
        public void TestAdding()
        {
            SubEmployee subEmployee = new SubEmployee("Vasya2", Position, 44);

            Assert.AreEqual(0, ((Employee)Employee).Employees.Count);
            Employee.Add(subEmployee);
            Assert.AreEqual(1, ((Employee)Employee).Employees.Count);
            Assert.AreSame(subEmployee, ((Employee)Employee).Employees[0]);
        }
コード例 #4
0
ファイル: DemeterPrinciple.cs プロジェクト: ManoKing/GameBase
    public List <SubEmployee> getAllEmployee()
    {
        List <SubEmployee> list = new ArrayList <SubEmployee>();

        for (int i = 0; i < 100; i++)
        {
            SubEmployee emp = new SubEmployee();
            //为分公司人员按顺序分配一个ID
            emp.setId("分公司" + i);
            list.add(emp);
        }
        return(list);
    }
コード例 #5
0
        public virtual void GetFullInfoTest(string name, string position, int salary, bool isSubEmployee)
        {
            EmployeeComponent obj;

            if (isSubEmployee)
            {
                obj = new SubEmployee(name, position, salary);
            }
            else
            {
                obj = new Employee(name, position, salary);
            }
            Assert.IsTrue(obj.GetFullInfo().Contains(name));
            Assert.IsTrue(obj.GetFullInfo().Contains(position));
            Assert.IsTrue(obj.GetFullInfo().Contains(salary.ToString()));
        }
コード例 #6
0
ファイル: CompanyTest.cs プロジェクト: SMTRPZ/Novak-IT71
        public void TestCompanyWithEmployees()
        {
            IOutput           stringOutput = new StringOutput();
            EmployeeComponent director     = new Employee("Director", "director", 20);
            EmployeeComponent manager      = new Employee("Manager of storing", "manager", 15);
            EmployeeComponent manager2     = new Employee("Manager of marketing", "manager", 12);
            EmployeeComponent x            = new SubEmployee("X", "team group", 10);
            EmployeeComponent y            = new SubEmployee("Y", "team group", 10);
            EmployeeComponent a            = new SubEmployee("A", "team group", 10);
            EmployeeComponent b            = new SubEmployee("B", "team group", 10);
            EmployeeComponent c            = new SubEmployee("Another one manager", "manager", 10);

            director.Add(manager, manager2);
            manager.Add(x, y, c);
            manager2.Add(a, b);
            Company       company = new Company(director, stringOutput);
            PrivateObject obj     = new PrivateObject(company);
            var           root    = obj.GetField("_root");

            Assert.IsTrue(root is Employee);
            Assert.AreSame(director, root);
            Assert.IsTrue(((EmployeeComponent)root).Name == "Director");
            Assert.IsTrue(((Employee)root).Employees.Count == 2);
        }
コード例 #7
0
 public NoOneSubordinatesBahavior()
 {
     employee = new SubEmployee("Vasya", "manager", 5);
 }
コード例 #8
0