public void Airplane_HasRequiredMembers()
        {
            Type     type     = typeof(Airplane);
            Airplane Airplane = (Airplane)Activator.CreateInstance(type, "ABC123", 2, 3);

            PropertyInfo prop = type.GetProperty("PlaneNumber");

            PropertyValidator.ValidateReadOnly(prop, "PlaneNumber", typeof(string));

            prop = type.GetProperty("BookedFirstClassSeats");
            PropertyValidator.ValidateReadOnly(prop, "BookedFirstClassSeats", typeof(int));

            prop = type.GetProperty("AvailableFirstClassSeats");
            PropertyValidator.ValidateReadOnly(prop, "AvailableFirstClassSeats", typeof(int));

            prop = type.GetProperty("TotalFirstClassSeats");
            PropertyValidator.ValidateReadOnly(prop, "TotalFirstClassSeats", typeof(int));


            prop = type.GetProperty("BookedCoachSeats");
            PropertyValidator.ValidateReadOnly(prop, "BookedCoachSeats", typeof(int));

            prop = type.GetProperty("AvailableCoachSeats");
            PropertyValidator.ValidateReadOnly(prop, "AvailableCoachSeats", typeof(int));

            prop = type.GetProperty("TotalCoachSeats");
            PropertyValidator.ValidateReadOnly(prop, "TotalCoachSeats", typeof(int));

            MethodInfo method = type.GetMethod("ReserveSeats");

            MethodValidator.ValidatePublicMethod(method, "ReserveSeats", typeof(bool));
        }
Exemple #2
0
        public void Employee_HasRequiredMembers()
        {
            Type type = typeof(Employee);

            PropertyInfo prop = type.GetProperty("EmployeeId");

            PropertyValidator.ValidateReadPrivateWrite(prop, "EmployeeId", typeof(int));

            prop = type.GetProperty("FirstName");
            PropertyValidator.ValidateReadPrivateWrite(prop, "FirstName", typeof(string));

            prop = type.GetProperty("LastName");
            PropertyValidator.ValidateReadWrite(prop, "LastName", typeof(string));

            prop = type.GetProperty("FullName");
            PropertyValidator.ValidateReadOnly(prop, "FullName", typeof(string));

            prop = type.GetProperty("Department");
            PropertyValidator.ValidateReadWrite(prop, "Department", typeof(string));

            prop = type.GetProperty("AnnualSalary");
            PropertyValidator.ValidateReadPrivateWrite(prop, "AnnualSalary", typeof(double));

            MethodInfo method = type.GetMethod("RaiseSalary");

            MethodValidator.ValidatePublicMethod(method, "RaiseSalary", typeof(void));
        }
Exemple #3
0
        public void Elevator_HasRequiredMembers()
        {
            Type     type     = typeof(Elevator);
            Elevator elevator = (Elevator)Activator.CreateInstance(type, 3);

            PropertyInfo prop = type.GetProperty("CurrentLevel");

            PropertyValidator.ValidateReadOnly(prop, "CurrentLevel", typeof(int));

            prop = type.GetProperty("NumberOfLevels");
            PropertyValidator.ValidateReadOnly(prop, "NumberOfLevels", typeof(int));

            prop = type.GetProperty("DoorIsOpen");
            PropertyValidator.ValidateReadOnly(prop, "DoorIsOpen", typeof(bool));

            MethodInfo method = type.GetMethod("OpenDoor");

            MethodValidator.ValidatePublicMethod(method, "OpenDoor", typeof(void));

            method = type.GetMethod("CloseDoor");
            MethodValidator.ValidatePublicMethod(method, "CloseDoor", typeof(void));

            method = type.GetMethod("GoUp");
            MethodValidator.ValidatePublicMethod(method, "GoUp", typeof(void));
            Assert.AreEqual(1, method.GetParameters().Length, "GoUp should accept 1 parameter");

            method = type.GetMethod("GoDown");
            MethodValidator.ValidatePublicMethod(method, "GoDown", typeof(void));
            Assert.AreEqual(1, method.GetParameters().Length, "GoDown should accept 1 parameter");
        }
        public void Television_HasRequiredMembers()
        {
            Type       type = typeof(Television);
            Television tv   = (Television)Activator.CreateInstance(type);

            PropertyInfo prop = type.GetProperty("IsOn");

            PropertyValidator.ValidateReadPrivateWrite(prop, "IsOn", typeof(bool));

            prop = type.GetProperty("CurrentChannel");
            PropertyValidator.ValidateReadPrivateWrite(prop, "CurrentChannel", typeof(int));

            prop = type.GetProperty("CurrentVolume");
            PropertyValidator.ValidateReadPrivateWrite(prop, "CurrentVolume", typeof(int));

            MethodInfo method = type.GetMethod("TurnOff");

            MethodValidator.ValidatePublicMethod(method, "TurnOff", typeof(void));

            method = type.GetMethod("TurnOn");
            MethodValidator.ValidatePublicMethod(method, "TurnOn", typeof(void));

            method = type.GetMethod("ChangeChannel");
            MethodValidator.ValidatePublicMethod(method, "ChangeChannel", typeof(void));
            Assert.AreEqual(1, method.GetParameters().Length, "ChangeChannel should accept 1 parameter");

            method = type.GetMethod("ChannelUp");
            MethodValidator.ValidatePublicMethod(method, "ChannelUp", typeof(void));

            method = type.GetMethod("ChannelDown");
            MethodValidator.ValidatePublicMethod(method, "ChannelDown", typeof(void));

            method = type.GetMethod("RaiseVolume");
            MethodValidator.ValidatePublicMethod(method, "RaiseVolume", typeof(void));

            method = type.GetMethod("LowerVolume");
            MethodValidator.ValidatePublicMethod(method, "LowerVolume", typeof(void));
        }