Inheritance: INotifyPropertyChanged
Esempio n. 1
0
        /// <summary>
        ///     Now try to understand this scenario, to call this method we need to pass these parameters.
        ///     Now there is no way to understand what these parameters are or how these parameters needs to be passed.
        ///     To find that we need to find Invoking Expression of "BusinessMethodDependency" and detects all it's parameter
        ///     initialize recursively.
        ///     To find dependencies we need to find the method "BusinessMethod" programmatically not hard coded fashion.
        ///     To test this method, we need to 2 setup methods
        ///         1.  Setup of Parameters from "BusinessMethod".
        ///         2.  Setup of inner properties (IntThrows, IntStaticThrows, PubliceByteProp, PublicStringProp), fields,
        ///         methods (ArgumentNullException, SomethingDynamicComplex, ThrowException,
        ///         BusinessLogicExampleOfSameplemethod, BusinessLogicExampleOfSamepleMethodString,
        ///         SampleMethod, SampleMethodString, ThrowException("Needs to be covered" + intX + y))
        /// </summary>
        /// <param name="somethingComplex"></param>
        /// <param name="sample"></param>
        /// <param name="classWithProperties"></param>
        /// <param name="classWithMethods"></param>
        /// <param name="required"></param>
        /// <param name="prep"></param>
        public void BusinessMethodDependency(dynamic somethingComplex,
                                             dynamic sample,
                                             ClassWithProperties classWithProperties,
                                             ClassWithMethods classWithMethods,
                                             IRequired required,
                                             IRequiredPrep prep)
        {
            Utility.ArgumentNullException("Testing"); // this method needs to be Faked
            somethingComplex.SomethingDynamicComplex();
            var x = classWithProperties.PubliceByteProp;
            var y = classWithProperties.PublicStringProp;

            Utility.ThrowException(); // this method needs to be Faked

            var classWithBusinessLogic = new ClassWithBusinessLogic(required);

            classWithBusinessLogic.BusinessLogicExampleOfSameplemethod();
            y = classWithBusinessLogic.BusinessLogicExampleOfSamepleMethodString() + x;

            var classWithBusinessLogic2 = new ClassWithBusinessLogic2();

            classWithBusinessLogic2.SampleMethodString();

            var requiredConcrete = new Required();

            requiredConcrete.SampleMethod(prep);
            requiredConcrete.SampleMethodString(prep);

            var intX = (int)sample + 5 + IntThrows + IntStaticThrows;

            Utility.ThrowException("Needs to be covered" + intX + y); // this method needs to be Faked and covered
        }
Esempio n. 2
0
        public void BuildsNewInstanceFromExisting()
        {
            var obj    = new ClassWithProperties();
            var result = obj.NewInstance();

            Assert.Equal(obj.GetType(), result.GetType());
        }
Esempio n. 3
0
        public void GetAllInstanceFields()
        {
            var obj    = new ClassWithProperties();
            var fields = obj.GetInstanceFields();

            Assert.Equal(3, fields.Count());
        }
Esempio n. 4
0
        public void SetPropertiesFrom()
        {
            var cwp = new ClassWithProperties
            {
                MyBool              = true,
                MyInt               = 5,
                MyString            = "hello world",
                MyDouble            = 2.2,
                MyBoolPrivateGetter = true
            };

            cwp.SetMyBoolPrivateSetter(true);

            var cwp2 = new ClassWithProperties();

            Assert.Equal(false, cwp2.MyBool);
            Assert.Equal(false, cwp2.GetMyBoolPrivateGetter());

            cwp2.SetPropertiesFrom(cwp);
            Assert.Equal(true, cwp2.MyBool);
            Assert.Equal(5, cwp2.MyInt);
            Assert.Equal("hello world", cwp2.MyString);
            Assert.Equal(2.2, cwp2.MyDouble);
            // public set and get required
            Assert.Equal(false, cwp2.GetMyBoolPrivateGetter());
            Assert.Equal(false, cwp2.MyBoolPrivateSetter);

            Assert.True(true);
        }
Esempio n. 5
0
        public void OrderBy_Generates_Order_OData()
        {
            var instance = new ClassWithProperties();

            var actual = instance.OrderBy(x => x.StringProperty);

            Assert.AreEqual("$orderby=(StringProperty asc)", actual.ToString());
        }
Esempio n. 6
0
        public void Filter_Generates_Inequality_Filter_When_Expression_Represents_Inequality()
        {
            var instance = new ClassWithProperties();

            var actual = instance.Filter(x => x.StringProperty != "value");

            Assert.AreEqual("$filter=(StringProperty ne 'value')", actual.ToString());
        }
Esempio n. 7
0
        public void Filter_Generates_LessThan_Filter_When_Expression_Represents_LessThan()
        {
            var instance = new ClassWithProperties();

            var actual = instance.Filter(x => x.IntegerProperty < 7);

            Assert.AreEqual("$filter=(IntegerProperty lt '7')", actual.ToString());
        }
Esempio n. 8
0
        /// <summary>
        ///     To test this method we need to find invocation expression of "BusinessMethod" in "BusinessMethodInitial2" and
        ///     "BusinessMethodInitial" and create two test method accordingly.
        /// </summary>
        /// <param name="x"></param>
        /// <param name="somethingComplex"></param>
        /// <param name="required"></param>
        public void BusinessMethod(int x, dynamic somethingComplex, IRequired required)
        {
            var prep = new RequiredPrep();
            var classWithProperties = new ClassWithProperties(required);
            var classWithMethods    = new ClassWithMethods(required);

            BusinessMethodDependency(somethingComplex, x, classWithProperties, classWithMethods, required, prep);
        }
Esempio n. 9
0
        public void Filter_Generates_OData_Filter_For_Equality()
        {
            var instance = new ClassWithProperties();

            var actual = instance.Filter(x => x.StringProperty == "value");

            Assert.AreEqual("$filter=(StringProperty eq 'value')", actual.ToString());
        }
Esempio n. 10
0
        public void OrderBy_Can_Order_Descending()
        {
            var instance = new ClassWithProperties();

            var actual = instance.OrderBy(x => x.StringProperty, OrderBy.Descending);

            Assert.AreEqual("$orderby=(StringProperty desc)", actual.ToString());
        }
Esempio n. 11
0
        public void DoesNotIncludeStaticFields()
        {
            var obj    = new ClassWithProperties();
            var fields = obj.GetInstanceFields();

            var field = fields.FirstOrDefault(f => f.Name.Contains("Static"));

            Assert.Null(field);
        }
Esempio n. 12
0
        public void Clone()
        {
            var cwp  = new ClassWithProperties();
            var cwp2 = cwp.Clone();

            Assert.NotNull(cwp2);
            Assert.NotSame(cwp, cwp2);

            Assert.True(true);
        }
Esempio n. 13
0
        public void DoesNotPullEqualNameDifferentType()
        {
            var baseObj   = new ClassWithProperties();
            var evaluated = new { SomeString = 4 };

            var fields = baseObj.GetInstanceFields();
            var field  = fields.First(n => n.Name.Equals("AField"));
            var result = evaluated.HasFieldMatching(field);

            Assert.False(result);
        }
Esempio n. 14
0
        public void AMatchIsFound()
        {
            var baseObj   = new ClassWithProperties();
            var evaluated = new SubClass();

            var fields = baseObj.GetInstanceFields();
            var field  = fields.First(n => n.Name.Equals("AField"));
            var result = evaluated.HasFieldMatching(field);

            Assert.True(result);
        }
Esempio n. 15
0
        public void CanReadObjectWithProperties()
        {
            var now   = DateTime.Now;
            var value = new ClassWithProperties("test", 42, Math.PI, now);
            var read  = _reader.Read(value);

            Assert.Equal(typeof(ClassWithProperties), read.Type);
            Assert.Equal(nameof(ClassWithProperties), read.Name);
            Assert.Equal(value, read.Value);
            Assert.Null(read.Format);
            Assert.Null(read.Formatter);

            Assert.NotEmpty(read.Properties);

            Assert.Collection(read.Properties,
                              r =>
            {
                Assert.Equal(nameof(ClassWithProperties.Name), r.Name);
                Assert.Equal(typeof(String), r.Type);
                Assert.Equal("test", r.Value);
                Assert.Null(read.Format);
                Assert.Null(read.Formatter);
                Assert.Empty(r.Properties);
            },
                              r =>
            {
                Assert.Equal(nameof(ClassWithProperties.MeaningOfEverything), r.Name);
                Assert.Equal(typeof(int), r.Type);
                Assert.Equal(42, r.Value);
                Assert.Null(read.Format);
                Assert.Null(read.Formatter);
                Assert.Empty(r.Properties);
            },
                              r =>
            {
                Assert.Equal(nameof(ClassWithProperties.Pi), r.Name);
                Assert.Equal(typeof(double), r.Type);
                Assert.Equal(Math.PI, Assert.IsType <double>(r.Value), 10);
                Assert.Null(read.Format);
                Assert.Null(read.Formatter);
                Assert.Empty(r.Properties);
            },
                              r =>
            {
                Assert.Equal(nameof(ClassWithProperties.RunAt), r.Name);
                Assert.Equal(typeof(DateTime), r.Type);
                Assert.Equal(now, r.Value);
                Assert.Null(read.Format);
                Assert.Null(read.Formatter);
                Assert.Empty(r.Properties);
            }
                              );
        }
Esempio n. 16
0
        public void CloneThenSetPropertiesFrom()
        {
            var cwp = new ClassWithProperties {
                MyBool = true
            };
            var cwp2 = cwp.CloneAndSetPropertiesFrom();

            Assert.NotSame(cwp, cwp2);
            Assert.Equal(true, cwp2.MyBool);

            Assert.True(true);
        }
Esempio n. 17
0
        public void SetValue_InstanceIsNull_ThrowTargetException()
        {
            // Setup
            var target = new ClassWithProperties();

            var propertySpec = new PropertySpec(target.GetType().GetProperty("IntegerProperty"));

            // Call
            TestDelegate call = () => propertySpec.SetValue(null, 2);

            // Assert
            Assert.Throws <TargetException>(call);
        }
Esempio n. 18
0
        public void SetValue_ProperInstanceTypeAndValueType_PropertyIsUpdated()
        {
            // Setup
            var target = new ClassWithProperties();

            var propertySpec = new PropertySpec(target.GetType().GetProperty("IntegerProperty"));

            // Call
            propertySpec.SetValue(target, 2);

            // Assert
            Assert.AreEqual(2, target.IntegerProperty);
        }
Esempio n. 19
0
        public void ParameteredConstructor_ForIndexProperty_ThrowArgumentException()
        {
            // Setup
            PropertyInfo propertyInfo = new ClassWithProperties().GetType().GetProperty("Item");

            // Call
            TestDelegate call = () => new PropertySpec(propertyInfo);

            // Assert
            const string expectedMessage = "Index properties are not allowed.";

            TestHelper.AssertThrowsArgumentExceptionAndTestMessage <ArgumentException>(call, expectedMessage);
        }
Esempio n. 20
0
        public void IsNonCustomExpandableObjectProperty_PropertyWithSomeTypeConverter_ReturnFalse()
        {
            // Setup
            var target = new ClassWithProperties();

            var propertySpec = new PropertySpec(target.GetType().GetProperty("StringPropertyWithSomeTypeConverter"));

            // Call
            bool hasExpandableObjectTypeConverter = propertySpec.IsNonCustomExpandableObjectProperty();

            // Assert
            Assert.False(hasExpandableObjectTypeConverter);
        }
        public void Instance_is_not_equal_to_instance_with_other_values()
        {
            var instanceWithOtherValues = new ClassWithProperties
            {
                IntegerValue = 0,
                StringValue = "other string",
                ClassReference = new ClassWithProperties()
            };

            var areEqual = _comparer.Equals(_instance, instanceWithOtherValues);

            Assert.IsFalse(areEqual);
        }
    public async Task Spreadsheet_AddAsRow_NullObject()
    {
        // Arrange
        ClassWithProperties obj = null !;

        using var stream            = new MemoryStream();
        await using var spreadsheet = await Spreadsheet.CreateNewAsync(stream);

        await spreadsheet.StartWorksheetAsync("Sheet");

        // Act & Assert
        await Assert.ThrowsAsync <ArgumentNullException>(() => spreadsheet.AddAsRowAsync(obj).AsTask());
    }
Esempio n. 23
0
        public void Test_SetPropertyValue_WithInt()
        {
            //---------------Set up test pack-------------------
            ClassWithProperties classWithProperties = new ClassWithProperties();
            const int           newValue            = 345;

            //---------------Assert Precondition----------------
            Assert.AreEqual(0, classWithProperties.IntProperty);
            //---------------Execute Test ----------------------
            ReflectionUtilities.SetPropertyValue(classWithProperties, "IntProperty", newValue);
            //---------------Test Result -----------------------
            Assert.AreEqual(newValue, classWithProperties.IntProperty);
        }
Esempio n. 24
0
        public void Test_SetPropertyValue_WithInterface()
        {
            //---------------Set up test pack-------------------
            ClassWithProperties classWithProperties = new ClassWithProperties();
            IMyInterface        newValue            = new MyInterfaceClass();

            //---------------Assert Precondition----------------
            Assert.IsNull(classWithProperties.InterfaceProperty);
            //---------------Execute Test ----------------------
            ReflectionUtilities.SetPropertyValue(classWithProperties, "InterfaceProperty", newValue);
            //---------------Test Result -----------------------
            Assert.AreSame(newValue, classWithProperties.InterfaceProperty);
        }
Esempio n. 25
0
        public void Test_SetPropertyValue_WithObject()
        {
            //---------------Set up test pack-------------------
            ClassWithProperties classWithProperties = new ClassWithProperties();
            object newValue = new object();

            //---------------Assert Precondition----------------
            Assert.IsNull(classWithProperties.ObjectProperty);
            //---------------Execute Test ----------------------
            ReflectionUtilities.SetPropertyValue(classWithProperties, "ObjectProperty", newValue);
            //---------------Test Result -----------------------
            Assert.AreSame(newValue, classWithProperties.ObjectProperty);
        }
Esempio n. 26
0
        public void Test_SetPropertyValue_WithString()
        {
            //---------------Set up test pack-------------------
            ClassWithProperties classWithProperties = new ClassWithProperties();
            const string        newValue            = "MyString";

            //---------------Assert Precondition----------------
            Assert.IsNull(classWithProperties.StringProperty);
            //---------------Execute Test ----------------------
            ReflectionUtilities.SetPropertyValue(classWithProperties, "StringProperty", newValue);
            //---------------Test Result -----------------------
            Assert.AreEqual(newValue, classWithProperties.StringProperty);
        }
        public void IsBrowsable_PropertyHasBrowsableFalseAttribute_ReturnFalse()
        {
            // Setup
            var instance   = new ClassWithProperties();
            var spec       = new PropertySpec(instance.GetType().GetProperty("PropertyWithBrowsableFalseAttribute"));
            var descriptor = new PropertySpecDescriptor(spec, instance);

            // Call
            bool isBrowsable = descriptor.IsBrowsable;

            // Assert
            Assert.IsFalse(isBrowsable);
        }
Esempio n. 28
0
        public void ConcreteClassWithProperties()
        {
            var data = new ClassWithProperties
            {
                Name       = "Chris",
                Value      = "10000",
                TaxedValue = "6000",
                Currency   = "dollars",
                InCa       = "InCa"
            };

            Render(data);
        }
        public void ShouldSerializeValue_ReturnFalse()
        {
            // Setup
            var instance           = new ClassWithProperties();
            var spec               = new PropertySpec(instance.GetType().GetProperty("PropertyWithOnlyGetter"));
            var propertyDescriptor = new PropertySpecDescriptor(spec, instance);

            // Call
            bool shouldSerializeValue = propertyDescriptor.ShouldSerializeValue(instance);

            // Assert
            Assert.IsFalse(shouldSerializeValue);
        }
        public void CanResetValue_ReturnFalse()
        {
            // Setup
            var instance           = new ClassWithProperties();
            var spec               = new PropertySpec(instance.GetType().GetProperty("PropertyWithOnlyGetter"));
            var propertyDescriptor = new PropertySpecDescriptor(spec, instance);

            // Call
            bool canReset = propertyDescriptor.CanResetValue(instance);

            // Assert
            Assert.IsFalse(canReset);
        }
        public void GetValue_SimpleValueProperty_ReturnPropertyValue()
        {
            // Setup
            var instance           = new ClassWithProperties();
            var spec               = new PropertySpec(instance.GetType().GetProperty("PropertyWithOnlyGetter"));
            var propertyDescriptor = new PropertySpecDescriptor(spec, instance);

            // Call
            object value = propertyDescriptor.GetValue(instance);

            // Assert
            Assert.AreEqual(instance.PropertyWithOnlyGetter, value);
        }
        public void GetValue_ObjectValueProperty_ReturnPropertyValue()
        {
            // Setup
            var instance           = new ClassWithProperties();
            var spec               = new PropertySpec(instance.GetType().GetProperty("ComplexSubProperty"));
            var propertyDescriptor = new PropertySpecDescriptor(spec, instance);

            // Call
            object value = propertyDescriptor.GetValue(instance);

            // Assert
            Assert.AreSame(instance.ComplexSubProperty, value);
        }
        public void IsReadOnly_PropertyHasReadOnlyFalseAttribute_ReturnFalse()
        {
            // Setup
            var instance   = new ClassWithProperties();
            var spec       = new PropertySpec(instance.GetType().GetProperty("PropertyWithReadOnlyFalseAttribute"));
            var descriptor = new PropertySpecDescriptor(spec, instance);

            // Call
            bool isReadOnly = descriptor.IsReadOnly;

            // Assert
            Assert.IsFalse(isReadOnly);
        }
        public void IsReadOnly_PropertyHasNoAttributeAndOnlyGetter_ReturnTrue()
        {
            // Setup
            var instance   = new ClassWithProperties();
            var spec       = new PropertySpec(instance.GetType().GetProperty("PropertyWithOnlyGetter"));
            var descriptor = new PropertySpecDescriptor(spec, instance);

            // Call
            bool isReadOnly = descriptor.IsReadOnly;

            // Assert
            Assert.IsTrue(isReadOnly);
        }
Esempio n. 35
0
        public void IsNonCustomExpandableObjectProperty_PropertyWithCustomExpandableObjectTypeConverter_ReturnFalse()
        {
            // Setup
            var target = new ClassWithProperties();

            var propertySpec = new PropertySpec(target.GetType().GetProperty("StringPropertyWithCustomExpandableObjectConverter"));

            // Call
            bool hasExpandableObjectTypeConverter = propertySpec.IsNonCustomExpandableObjectProperty();

            // Assert
            Assert.False(hasExpandableObjectTypeConverter,
                         "As we cannot copy the same behavior of a ExpandableObjectConverter with customizations, we should not recognize it as such.");
        }
Esempio n. 36
0
        public void Test_SetPrivatePropToNull_WherePropBool()
        {
            //---------------Set up test pack-------------------
            const string propertyName        = "BoolProp";
            var          classWithProperties = new ClassWithProperties();

            //---------------Assert Precondition----------------
            Assert.IsFalse((bool)ReflectionUtilities.GetPrivatePropertyValue(classWithProperties, propertyName));
            //---------------Execute Test ----------------------
            ReflectionUtilities.SetPrivatePropertyValue(classWithProperties, propertyName, null);
            //---------------Test Result -----------------------
            bool propValue = (bool)ReflectionUtilities.GetPrivatePropertyValue(classWithProperties, propertyName);

            Assert.IsFalse(propValue);
        }
        public void SetUp()
        {
            _referencedInstance = new ClassWithProperties();

            _instance = new ClassWithProperties
            {
                IntegerValue = 2,
                StringValue = "string",
                ClassReference = _referencedInstance
            };

            _instanceWithSameValues = new ClassWithProperties
            {
                IntegerValue = 2,
                StringValue = "string",
                ClassReference = _referencedInstance
            };

            _comparer = new PropertyComparer();
        }
 public void SetUp()
 {
     _left = new ClassWithProperties { IntegerValue = 1, StringValue = "2", ClassReference = _left };
     _right = new ClassWithProperties { IntegerValue = 1, StringValue = "2", ClassReference = _left };
 }
 public void Test_SetPropertyValue_WithObject()
 {
     //---------------Set up test pack-------------------
     ClassWithProperties classWithProperties = new ClassWithProperties();
     object newValue = new object();
     //---------------Assert Precondition----------------
     Assert.IsNull(classWithProperties.ObjectProperty);
     //---------------Execute Test ----------------------
     ReflectionUtilities.SetPropertyValue(classWithProperties, "ObjectProperty", newValue);
     //---------------Test Result -----------------------
     Assert.AreSame(newValue, classWithProperties.ObjectProperty);
 }
Esempio n. 40
0
        public void TestSerializesProperties()
        {
            var instance = new ClassWithProperties {
                A = 1,
                B = 2,
                C = "foo"
            };

            Serializer.Bind(() => instance.A);
            Serializer.Bind(() => instance.B);
            Serializer.Bind(() => instance.C);

            Scheduler.WaitFor(Serializer.Save());

            Assert.AreEqual(1, (int)Scheduler.WaitFor(Tangle.Get("A")));
            Assert.AreEqual(2, (int)Scheduler.WaitFor(Tangle.Get("B")));
            Assert.AreEqual("foo", (string)Scheduler.WaitFor(Tangle.Get("C")));
        }
Esempio n. 41
0
        public void Filter_Throws_ArgumentException_When_ExpressionType_Not_Supported()
        {
            var instance = new ClassWithProperties();

            Assert.Throws<ArgumentException>(() => instance.Filter(x => x.StringProperty.Contains("abc123")));
        }
Esempio n. 42
0
        public void Filter_Throws_ArgumentException_When_LeftSide_Not_A_Property()
        {
            var instance = new ClassWithProperties();

            Assert.Throws<ArgumentException>(() => instance.Filter(x => 7 == x.IntegerProperty));
        }
Esempio n. 43
0
        public void TestPropertySerializerSaveAndLoad()
        {
            Scheduler.WaitFor(Wrapper.ExecuteSQL("CREATE TEMPORARY TABLE Data (name TEXT, value VARIANT)"));

            var props = new ClassWithProperties();
            var serializer = new DatabasePropertySerializer(Wrapper, "Data");

            serializer.Bind(() => props.A);
            serializer.Bind(() => props.B);
            serializer.Bind(() => props.C);
            serializer.Bind(() => props.D);

            var timeA = DateTime.UtcNow;
            var timeB = timeA.AddDays(1);

            props.A = 5;
            props.B = 10;
            props.C = "Test";
            props.D = timeA;

            Scheduler.WaitFor(serializer.Save());

            Assert.AreEqual(
                4,
                Scheduler.WaitFor(Wrapper.ExecuteScalar<long>("SELECT COUNT(value) FROM Data"))
            );

            props.A = props.B = 0;
            props.C = "Baz";
            props.D = timeB;

            Scheduler.WaitFor(serializer.Load());

            Assert.AreEqual(
                5, props.A
            );
            Assert.AreEqual(
                10, props.B
            );
            Assert.AreEqual(
                "Test", props.C
            );
            Assert.AreEqual(
                timeA, props.D
            );
        }
Esempio n. 44
0
        public void Filter_Works_With_Fields()
        {
            var instance = new ClassWithProperties();

            var actual = instance.Filter(x => x.Field == "foo");

            Assert.AreEqual("$filter=(Field eq 'foo')", actual.ToString());
        }
 public void Test_SetPrivatePropToNull_WherePropBool()
 {
     //---------------Set up test pack-------------------
     const string propertyName = "BoolProp";
     var classWithProperties = new ClassWithProperties();
     //---------------Assert Precondition----------------
     Assert.IsFalse((bool) ReflectionUtilities.GetPrivatePropertyValue(classWithProperties, propertyName));
     //---------------Execute Test ----------------------
     ReflectionUtilities.SetPrivatePropertyValue(classWithProperties, propertyName, null);
     //---------------Test Result -----------------------
     bool propValue = (bool) ReflectionUtilities.GetPrivatePropertyValue(classWithProperties, propertyName);
     Assert.IsFalse(propValue);
 }
 public void Test_SetPropertyValue_ToNull_WithInterface()
 {
     //---------------Set up test pack-------------------
     ClassWithProperties classWithProperties = new ClassWithProperties();
     IMyInterface oldValue = new MyInterfaceClass();
     classWithProperties.InterfaceProperty = oldValue;
     //---------------Assert Precondition----------------
     Assert.AreSame(oldValue, classWithProperties.InterfaceProperty);
     //---------------Execute Test ----------------------
     ReflectionUtilities.SetPropertyValue(classWithProperties, "InterfaceProperty", null);
     //---------------Test Result -----------------------
     Assert.IsNull(classWithProperties.InterfaceProperty);
 }
Esempio n. 47
0
        public void OrderBy_Throws_ArgumentException_When_Expression_Not_A_Member()
        {
            var instance = new ClassWithProperties();

            Assert.Throws<ArgumentException>(() => instance.OrderBy(x => "foo"));
        }
 public void Test_SetPropertyValue_WithString()
 {
     //---------------Set up test pack-------------------
     ClassWithProperties classWithProperties = new ClassWithProperties();
     const string newValue = "MyString";
     //---------------Assert Precondition----------------
     Assert.IsNull(classWithProperties.StringProperty);
     //---------------Execute Test ----------------------
     ReflectionUtilities.SetPropertyValue(classWithProperties, "StringProperty", newValue);
     //---------------Test Result -----------------------
     Assert.AreEqual(newValue, classWithProperties.StringProperty);
 }
 public void Test_SetPropertyValue_WithInt()
 {
     //---------------Set up test pack-------------------
     ClassWithProperties classWithProperties = new ClassWithProperties();
     const int newValue = 345;
     //---------------Assert Precondition----------------
     Assert.AreEqual(0, classWithProperties.IntProperty);
     //---------------Execute Test ----------------------
     ReflectionUtilities.SetPropertyValue(classWithProperties, "IntProperty", newValue);
     //---------------Test Result -----------------------
     Assert.AreEqual(newValue, classWithProperties.IntProperty);
 }