Example #1
0
        public void Validate_ChildClassesInheritFromBaseType_ShouldBeEqual(object[] values, string baseType)
        {
            foreach (var typeName in values.Select(Convert.ToString).ToArray())
            {
                var type    = TypeGenerator.GetType(typeName);
                var message = $"{typeName} does not inherit from {baseType} class";

                Assert.That(type.BaseType.Name, Is.EqualTo(baseType), message);
            }
        }
Example #2
0
        public void Validate_AbstractClasses_ShouldBeTrue()
        {
            foreach (var className in abstractClasses)
            {
                var type    = TypeGenerator.GetType(className);
                var message = $"{className} type is not abstract!";

                Assert.That(type.IsAbstract, Is.True, message);
            }
        }
        public void ValidateClassProduct_PrivateSetters_AllShouldBeTrue()
        {
            var methods = TypeGenerator.GetType("Product")
                          .GetMethods(nonPublicFlags);

            foreach (var method in methods.Where(x => x.Name.StartsWith("set")))
            {
                this.message = $"{method.Name} does not contain private setter";
                Assert.That(method.IsPrivate, Is.True, message);
            }
        }
        public void ValidateClassProduct_GettersReturnType_AllShouldBeDouble()
        {
            var getMethods = TypeGenerator.GetType("Product")
                             .GetMethods(publicFlags);

            foreach (var method in getMethods.Where(x => x.Name.StartsWith("get")))
            {
                this.message = $"{method.Name} does not return value of type double!";
                Assert.That(method.ReturnType, Is.EqualTo(typeof(Double)), message);
            }
        }
        public void ValidateClassProduct_ContainsProps_ShouldBeTrue()
        {
            var properties = TypeGenerator.GetType("Product")
                             .GetProperties(publicFlags)
                             .Select(p => p.Name);

            this.message = $"Product type does not contain Price property";
            Assert.That(properties.Contains(priceProperty), Is.True, this.message);

            this.message = $"Product type does not contain Weight property";
            Assert.That(properties.Contains(weightProperty), Is.True, this.message);
        }
Example #6
0
        public void Validate_ConcreteClassExist_SouldAllBeTrue()
        {
            var factoryClasses = new[] {
                "ProductFactory",
                "StorageFactory",
                "VehicleFactory"
            };

            var entityClasses = new[]
            {
                "Gpu",
                "HardDrive",
                "Ram",
                "SolidStateDrive",
                "Product",

                "Storage",
                "AutomatedWarehouse",
                "DistributionCenter",
                "Warehouse",

                "Vehicle",
                "Semi",
                "Truck",
                "Van"
            };

            var controllerClasses = new[]
            {
                "StorageMaster"
            };

            var allClasses = new[]
            {
                factoryClasses,
                entityClasses,
                controllerClasses
            };

            foreach (var @class in allClasses)
            {
                foreach (var typeName in @class)
                {
                    var type    = TypeGenerator.GetType(typeName);
                    var message = $"{typeName} type does not exist!";

                    Assert.That(type, Is.Not.Null, message);
                }
            }
        }
Example #7
0
        public void Validate_AbstractClassesHasProtectedConstructor_ShoudBeTrue()
        {
            foreach (var classType in abstractClasses)
            {
                var type         = TypeGenerator.GetType(classType);
                var constructors = type.GetConstructors();

                var message = $"{classType} has public constructor.";
                Assert.That(constructors.Length, Is.EqualTo(0), message);

                constructors = type
                               .GetConstructors((BindingFlags.Instance | BindingFlags.NonPublic));

                foreach (var constructor in constructors)
                {
                    message = $"{classType} does not contain protected constructor!";
                    Assert.That(constructor.IsFamily, Is.True, message);
                }
            }
        }
Example #8
0
 public void GetTypeBeforeEachTest()
 {
     type = TypeGenerator.GetType(wantedType);
 }