Ejemplo n.º 1
0
        public void Should_Use_Custom_StringLength_Boundaries_for_String_Value_Injection()
        {
            //Create an instance of our test class
            var testInstance = new SimpleStringTestClass();

            var stringLengthMax = 30;
            var stringLengthMin = 10;

            //Create an instance of our IntSelector and set some custom bounds
            var selector =
                new StringSelector().SetMax(() => stringLengthMax)
                .SetMin(() => stringLengthMin);

            //Iterate over the test object's properties
            foreach (var property in testInstance.GetType().GetProperties())
            {
                Assert.IsTrue(selector.CanBind(property),
                              string.Format("should have been able to bind to property {0}", property.Name));

                //Inject the value into this property on our test instance class
                selector.Generate(testInstance, property);

                //Get the value out of the property
                var fieldValue = (string)property.GetValue(testInstance, null);
                Assert.IsNotNullOrEmpty(fieldValue);
                Assert.IsTrue(fieldValue.Length <= stringLengthMax && fieldValue.Length >= stringLengthMin, "Custom range should have worked");
            }
        }
Ejemplo n.º 2
0
        public void String_Selector_Injects_All_Strings()
        {
            var stringSelector     = new StringSelector();
            var randomStringsClass = new RandomStringsClass();

            //Iterate over all of the properties in the fullNameClass object...
            foreach (var property in randomStringsClass.GetType().GetProperties())
            {
                //Inject the value into the property
                stringSelector.Generate(randomStringsClass, property);
            }

            //Iterate over all of the properties again
            foreach (var property in randomStringsClass.GetType().GetProperties())
            {
                var fieldValue = property.GetValue(randomStringsClass, null) as string;

                Assert.IsNotNullOrEmpty(fieldValue);
                Assert.IsAssignableFrom <string>(fieldValue, "Should be type of string...");
                Assert.That(fieldValue.Length > 0);
            }
        }
        public void String_Selector_Injects_All_Strings()
        {
            var stringSelector = new StringSelector();
            var randomStringsClass = new RandomStringsClass();

            //Iterate over all of the properties in the fullNameClass object...
            foreach (var property in randomStringsClass.GetType().GetProperties())
            {
                //Inject the value into the property
                stringSelector.Generate(randomStringsClass, property);
            }

            //Iterate over all of the properties again
            foreach (var property in randomStringsClass.GetType().GetProperties())
            {
                var fieldValue = property.GetValue(randomStringsClass, null) as string;

                Assert.IsNotNullOrEmpty(fieldValue);
                Assert.IsAssignableFrom<string>(fieldValue, "Should be type of string...");
                Assert.That(fieldValue.Length > 0);
            }
        }
Ejemplo n.º 4
0
        public void Should_Use_Custom_StringLength_Boundaries_for_String_Value_Injection()
        {
            //Create an instance of our test class
            var testInstance = new SimpleStringTestClass();

            var stringLengthMax = 30;
            var stringLengthMin = 10;

            //Create an instance of our IntSelector and set some custom bounds
            var selector =
                new StringSelector().SetMax(() => stringLengthMax)
                                 .SetMin(() => stringLengthMin);

            //Iterate over the test object's properties
            foreach (var property in testInstance.GetType().GetProperties())
            {
                Assert.IsTrue(selector.CanBind(property),
                              string.Format("should have been able to bind to property {0}", property.Name));

                //Inject the value into this property on our test instance class
                selector.Generate(testInstance, property);

                //Get the value out of the property
                var fieldValue = (string)property.GetValue(testInstance, null);
                Assert.IsNotNullOrEmpty(fieldValue);
                Assert.IsTrue(fieldValue.Length <= stringLengthMax && fieldValue.Length >= stringLengthMin, "Custom range should have worked");
            }
        }