Ejemplo n.º 1
0
        public static async Task Main(string[] args)
        {
            // Change this to execute an example!
            ExampleType typeToExecute = ExampleType.AsyncProgramming;

            example[(int)typeToExecute]();
        }
    private void DrawContentGUI()
    {
        //Display styles and display example GUIStyle
        EditorGUILayout.BeginVertical(EditorStyles.helpBox);
        {
            string info = HasStyles
                  ? "Editor Styles"
                  : "No styles found, click the buttonto get all editor styles.";

            EditorGUILayout.BeginHorizontal();
            {
                EditorGUILayout.LabelField(info, EditorStyles.boldLabel);
                exampleType = (ExampleType)EditorGUILayout.EnumPopup(exampleType);
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.Space();

            EditorGUI.indentLevel++;
            {
                for (int i = 0; i < serializedStyles.Count; i++)
                {
                    DrawStyle(serializedStyles[i], foundStyles[i]);
                }
            }
            EditorGUI.indentLevel--;
        }
        EditorGUILayout.EndVertical();
    }
Ejemplo n.º 3
0
        public void GetProperties_ReturnsNormalProperties()
        {
            var instance   = new ExampleType();
            var descriptor = DynamicDescriptor.CreateFromInstance(instance);
            var properties = descriptor.GetProperties();

            bool containsProperty1 = false, containsProperty2 = false, containsProperty3 = false, containsProperty4 = false;

            foreach (PropertyDescriptor property in properties)
            {
                if (property.Name == "Property1")
                {
                    containsProperty1 = true;
                }
                if (property.Name == "Property2")
                {
                    containsProperty2 = true;
                }
                if (property.Name == "Property3")
                {
                    containsProperty3 = true;
                }
                if (property.Name == "Property4")
                {
                    containsProperty4 = true;
                }
            }

            containsProperty1.Should().BeTrue();
            containsProperty2.Should().BeTrue();
            containsProperty3.Should().BeTrue();
            containsProperty4.Should().BeTrue();
        }
Ejemplo n.º 4
0
        private static string GetExampleDomain(string name, ExampleType exampleType)
        {
            if (exampleType == ExampleType.Basic)
            {
                return(BasicTemplate(name));
            }
            if (exampleType == ExampleType.WithAuth)
            {
                return(AuthTemplate(name));
            }
            if (exampleType == ExampleType.WithBus)
            {
                return(BusTemplate(name));
            }
            if (exampleType == ExampleType.WithAuthServer)
            {
                return(AuthServerTemplate(name));
            }
            if (exampleType == ExampleType.WithForeignKey)
            {
                return(ForeignKeyTemplate(name));
            }

            throw new Exception("Example type was not recognized.");
        }
Ejemplo n.º 5
0
        public DocExample(ExampleType aType, string aInfo)
        {
            type     = aType;
            info     = aInfo;
            comments = true;

            if (type == ExampleType.CodeSample)
            {
                string[] names = info.Split(' ');

                for (int i = 0; i < Program.items.Count; i++)
                {
                    if (Array.IndexOf(names, Program.items[i].Name) != -1)
                    {
                        Program.items[i].AddExample(this);
                    }
                }
            }
            else if (type == ExampleType.Document)
            {
                int split = info.IndexOf(' ');
                category = info.Substring(0, split);
                info     = info.Substring(split + 1);
                Program.items.Add(this);
            }
        }
Ejemplo n.º 6
0
        public void GetProperties_SingleAttribute_ReturnsPropertiesWithThatAttribute()
        {
            var instance   = new ExampleType();
            var descriptor = DynamicDescriptor.CreateFromInstance(instance);
            var properties = descriptor.GetProperties(new Attribute[] { new AttributeOne() });

            bool containsProperty1 = false, containsProperty2 = false, containsProperty3 = false, containsProperty4 = false;

            foreach (PropertyDescriptor property in properties)
            {
                if (property.Name == "Property1")
                {
                    containsProperty1 = true;
                }
                if (property.Name == "Property2")
                {
                    containsProperty2 = true;
                }
                if (property.Name == "Property3")
                {
                    containsProperty3 = true;
                }
                if (property.Name == "Property4")
                {
                    containsProperty4 = true;
                }
            }

            containsProperty1.Should().BeTrue();
            containsProperty2.Should().BeFalse();
            containsProperty3.Should().BeTrue();
            containsProperty4.Should().BeFalse();
        }
Ejemplo n.º 7
0
        public DocExample(ExampleType aType, string aInfo)
        {
            type     = aType;
            info     = aInfo;
            comments = true;

            if (type == ExampleType.CodeSample)
            {
                string[] names = info.Split(' ');

                for (int i = 0; i < Program.items.Count; i++)
                {
                    if (Array.IndexOf(names, Program.items[i].Name) != -1)
                    {
                        Program.items[i].AddExample(this);
                    }
                }
            }
            else if (type == ExampleType.Document)
            {
                string[] words = info.Split(' ');
                category  = words[0];
                sortIndex = int.Parse(words[1]);
                info      = String.Join(" ", words, 2, words.Length - 2);
                Program.items.Add(this);
            }
        }
        public void ExampleTest_withItemCount()
        {
            //arrange
            var databaseName          = "testDatabase";
            var collectionName        = typeof(ExampleType).Name;
            var db                    = mongoServer.GetDatabase(databaseName);
            var collection            = db.GetCollection <ExampleType>(collectionName);
            var expectedNumberOfItems = 2;

            //act
            var item1 = new ExampleType()
            {
                MyProperty = 1
            };

            collection.Insert(item1);
            var item2 = new ExampleType()
            {
                MyProperty = 1
            };

            collection.Insert(item2);

            //assert
            mongoServer.AssertDatabaseExists(databaseName)
            .AssertCollectionExists <ExampleType>()
            .AssertCollectionItemCount(expectedNumberOfItems)
            .AssertCollectionHasItemWithProperty <ExampleType>(x => x.MyProperty == 1, expectedNumberOfItems);
        }
Ejemplo n.º 9
0
        public void GetDynamicProperty_PropertyNameDoesNotMatchAProperty_ReturnsNull()
        {
            var instance   = new ExampleType();
            var descriptor = DynamicDescriptor.CreateFromInstance(instance);

            descriptor.GetDynamicProperty(null).Should().BeNull();
            descriptor.GetDynamicProperty("NotAValidPropertyName").Should().BeNull();
        }
Ejemplo n.º 10
0
        public void GetProperties_NullOrEmptyAttributeArray_ReturnsSameValueAsGetPropertiesWithoutAttributesSpecified()
        {
            var instance   = new ExampleType();
            var descriptor = DynamicDescriptor.CreateFromInstance(instance);

            descriptor.GetProperties(null).Should().BeEquivalentTo(descriptor.GetProperties());
            descriptor.GetProperties(Array.Empty <Attribute>()).Should().BeEquivalentTo(descriptor.GetProperties());
        }
        /// <summary>
        /// Returns true if EntityViewModel instances are equal
        /// </summary>
        /// <param name="other">Instance of EntityViewModel to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(EntityViewModel other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Id == other.Id ||
                     Id != null &&
                     Id.Equals(other.Id)
                     ) &&
                 (
                     StringField == other.StringField ||
                     StringField != null &&
                     StringField.Equals(other.StringField)
                 ) &&
                 (
                     RelationIdField == other.RelationIdField ||
                     RelationIdField != null &&
                     RelationIdField.Equals(other.RelationIdField)
                 ) &&
                 (
                     DictionaryField == other.DictionaryField ||
                     DictionaryField != null &&
                     DictionaryField.Equals(other.DictionaryField)
                 ) &&
                 (
                     IntegerField == other.IntegerField ||
                     IntegerField != null &&
                     IntegerField.Equals(other.IntegerField)
                 ) &&
                 (
                     DoubleField == other.DoubleField ||
                     DoubleField != null &&
                     DoubleField.Equals(other.DoubleField)
                 ) &&
                 (
                     DateField == other.DateField ||
                     DateField != null &&
                     DateField.Equals(other.DateField)
                 ) &&
                 (
                     ExampleType == other.ExampleType ||
                     ExampleType != null &&
                     ExampleType.Equals(other.ExampleType)
                 ) &&
                 (
                     ExampleStatus == other.ExampleStatus ||
                     ExampleStatus != null &&
                     ExampleStatus.Equals(other.ExampleStatus)
                 ));
        }
Ejemplo n.º 12
0
        public static RoundedFragment GetInstance(ExampleType exampleType)
        {
            RoundedFragment f    = new RoundedFragment();
            Bundle          args = new Bundle();

            args.PutInt(ExampleTypeArgument, (int)exampleType);
            f.Arguments = args;
            return(f);
        }
Ejemplo n.º 13
0
        public override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            if (Arguments != null)
            {
                exampleType = (ExampleType)(Arguments.GetInt(ExampleTypeArgument));
            }
        }
Ejemplo n.º 14
0
 public static bool InterceptAndReturnTest(ExampleType exampleType, out int returnValue, ref string someString)
 {
     if (string.IsNullOrWhiteSpace(someString))
     {
         returnValue = 0;
         return(false);  // Shorts and will not return anything.
     }
     returnValue = 1337; // This will return the following value to the target method, and return said value.
     return(true);
 }
        public void GetDynamicProperty_ExpressionRefersToAValueTypeProperty_ReturnsDynamicPropertyDescriptorForThatProperty()
        {
            ExampleType instance = new ExampleType();
            DynamicTypeDescriptor descriptor = DynamicDescriptor.CreateFromInstance(instance);

            DynamicPropertyDescriptor propertyDescriptor = descriptor.GetDynamicProperty((ExampleType o) => o.Property4);

            Assert.That(propertyDescriptor, Is.Not.Null);
            Assert.That(propertyDescriptor.Name, Is.EqualTo("Property4"));
        }
Ejemplo n.º 16
0
        public void GetDynamicProperty_PropertyNameMatchesAProperty_ReturnsDynamicPropertyDescriptorForThatProperty()
        {
            var instance   = new ExampleType();
            var descriptor = DynamicDescriptor.CreateFromInstance(instance);

            var propertyDescriptor = descriptor.GetDynamicProperty("Property1");

            propertyDescriptor.Should().NotBeNull();
            propertyDescriptor.Name.Should().Be("Property1");
        }
Ejemplo n.º 17
0
        public void GetDynamicProperty_ExpressionRefersToAValueTypeProperty_ReturnsDynamicPropertyDescriptorForThatProperty()
        {
            var instance   = new ExampleType();
            var descriptor = DynamicDescriptor.CreateFromInstance(instance);

            var propertyDescriptor = descriptor.GetDynamicProperty((ExampleType o) => o.Property4);

            propertyDescriptor.Should().NotBeNull();
            propertyDescriptor.Name.Should().Be("Property4");
        }
Ejemplo n.º 18
0
        private static (ExampleType type, string name) RunPrompt()
        {
            AnsiConsole.WriteLine();
            AnsiConsole.Render(new Rule("[yellow]Create an Example Project[/]").RuleStyle("grey").Centered());

            var typeString  = AskExampleType();
            var exampleType = ExampleType.FromName(typeString, ignoreCase: true);
            var projectName = AskExampleProjectName();

            return(exampleType, projectName);
        }
Ejemplo n.º 19
0
        public void GetProperties_NoPropertyOrderSet_ReturnsPropertiesInAlphabeticalOrder()
        {
            var instance   = new ExampleType();
            var descriptor = DynamicDescriptor.CreateFromInstance(instance);

            var properties = descriptor.GetProperties();

            properties[0].Name.Should().Be("Property1");
            properties[1].Name.Should().Be("Property2");
            properties[2].Name.Should().Be("Property3");
            properties[3].Name.Should().Be("Property4");
        }
        public void GetDynamicProperties_AllPropertiesActive_ReturnsSequenceContainingAllDynamicProperties()
        {
            ExampleType instance = new ExampleType();
            DynamicTypeDescriptor descriptor = DynamicDescriptor.CreateFromInstance(instance);

            DynamicPropertyDescriptor[] properties = descriptor.GetDynamicProperties().ToArray();

            Assert.That(properties.Length, Is.EqualTo(4));
            Assert.That(properties[0].Name, Is.EqualTo("Property1"));
            Assert.That(properties[1].Name, Is.EqualTo("Property2"));
            Assert.That(properties[2].Name, Is.EqualTo("Property3"));
            Assert.That(properties[3].Name, Is.EqualTo("Property4"));
        }
Ejemplo n.º 21
0
        public void GetDynamicProperty_ExpressionRefersToSomethingOtherThanAProperty_ReturnsNull()
        {
            var instance   = new ExampleType();
            var descriptor = DynamicDescriptor.CreateFromInstance(instance);

            Action act1 = () => descriptor.GetDynamicProperty((ExampleType o) => o.field);

            act1.ShouldThrow <ArgumentException>().WithMessage("Expression 'o => o.field' refers to a field, not a property.");

            Action act2 = () => descriptor.GetDynamicProperty((ExampleType o) => o.Method());

            act2.ShouldThrow <ArgumentException>().WithMessage("Expression 'o => o.Method()' refers to a method, not a property.");
        }
        public void GetDynamicProperty_ExpressionRefersToSomethingOtherThanAProperty_ReturnsNull()
        {
            ExampleType instance = new ExampleType();
            DynamicTypeDescriptor descriptor = DynamicDescriptor.CreateFromInstance(instance);

            Assert.That(() => descriptor.GetDynamicProperty((ExampleType o) => o.field),
                Throws.TypeOf<ArgumentException>()
                      .And.Message.Contains("Expression 'o => o.field' refers to a field, not a property."));

            Assert.That(() => descriptor.GetDynamicProperty((ExampleType o) => o.Method()),
                Throws.TypeOf<ArgumentException>()
                      .And.Message.Contains("Expression 'o => o.Method()' refers to a method, not a property."));
        }
Ejemplo n.º 23
0
        public void GetDynamicProperties_AllPropertiesActive_ReturnsSequenceContainingAllDynamicProperties()
        {
            var instance   = new ExampleType();
            var descriptor = DynamicDescriptor.CreateFromInstance(instance);

            var properties = descriptor.GetDynamicProperties().ToArray();

            properties.Should().HaveCount(4);
            properties[0].Name.Should().Be("Property1");
            properties[1].Name.Should().Be("Property2");
            properties[2].Name.Should().Be("Property3");
            properties[3].Name.Should().Be("Property4");
        }
Ejemplo n.º 24
0
        public void GetProperties_SomePropertiesAreNotActive_ReturnsOnlyActiveProperties()
        {
            var instance   = new ExampleType();
            var descriptor = DynamicDescriptor.CreateFromInstance(instance);

            descriptor.GetDynamicProperty("Property1").SetActive(true);
            descriptor.GetDynamicProperty("Property2").SetActive(false);
            descriptor.GetDynamicProperty("Property3").SetActive(true);
            descriptor.GetDynamicProperty("Property4").SetActive(false);

            var properties = descriptor.GetProperties();

            properties.Should().HaveCount(2);
            properties[0].Name.Should().Be("Property1");
            properties[1].Name.Should().Be("Property3");
        }
Ejemplo n.º 25
0
        public void Evaluator_ExecAddReferenceFromVariable()
        {
            // this should not fail even without the call to AddReference
            var eval = new Evaluator("return person.Name");

            var person = new ExampleType()
            {
                ID   = 1,
                Name = "John"
            };

            eval["person"] = person;

            var name = eval.Eval <string>();

            Assert.AreEqual("John", name);
        }
Ejemplo n.º 26
0
        public void GetProperties_PropertyOrderSet_MultiplePropertiesHaveTheSameOrder_ReturnThosePropertiesInAlphabeticalOrder()
        {
            var instance   = new ExampleType();
            var descriptor = DynamicDescriptor.CreateFromInstance(instance);

            descriptor.GetDynamicProperty("Property1").SetPropertyOrder(1);
            descriptor.GetDynamicProperty("Property2").SetPropertyOrder(1);
            descriptor.GetDynamicProperty("Property3").SetPropertyOrder(0);
            descriptor.GetDynamicProperty("Property4").SetPropertyOrder(0);

            var properties = descriptor.GetProperties();

            properties[0].Name.Should().Be("Property3");
            properties[1].Name.Should().Be("Property4");
            properties[2].Name.Should().Be("Property1");
            properties[3].Name.Should().Be("Property2");
        }
Ejemplo n.º 27
0
        public void GetProperties_SomePropertyOrdersSet_ReturnsPropertiesInOrderSpecifiedByPropertyOrderThenOtherPropertiesInAlphabeticalOrder()
        {
            var instance   = new ExampleType();
            var descriptor = DynamicDescriptor.CreateFromInstance(instance);

            descriptor.GetDynamicProperty("Property1").SetPropertyOrder(null);
            descriptor.GetDynamicProperty("Property2").SetPropertyOrder(null);
            descriptor.GetDynamicProperty("Property3").SetPropertyOrder(1);
            descriptor.GetDynamicProperty("Property4").SetPropertyOrder(0);

            var properties = descriptor.GetProperties();

            properties[0].Name.Should().Be("Property4");
            properties[1].Name.Should().Be("Property3");
            properties[2].Name.Should().Be("Property1");
            properties[3].Name.Should().Be("Property2");
        }
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (Id != null)
         {
             hashCode = hashCode * 59 + Id.GetHashCode();
         }
         if (StringField != null)
         {
             hashCode = hashCode * 59 + StringField.GetHashCode();
         }
         if (RelationIdField != null)
         {
             hashCode = hashCode * 59 + RelationIdField.GetHashCode();
         }
         if (DictionaryField != null)
         {
             hashCode = hashCode * 59 + DictionaryField.GetHashCode();
         }
         if (IntegerField != null)
         {
             hashCode = hashCode * 59 + IntegerField.GetHashCode();
         }
         if (DoubleField != null)
         {
             hashCode = hashCode * 59 + DoubleField.GetHashCode();
         }
         if (DateField != null)
         {
             hashCode = hashCode * 59 + DateField.GetHashCode();
         }
         if (ExampleType != null)
         {
             hashCode = hashCode * 59 + ExampleType.GetHashCode();
         }
         if (ExampleStatus != null)
         {
             hashCode = hashCode * 59 + ExampleStatus.GetHashCode();
         }
         return(hashCode);
     }
 }
Ejemplo n.º 29
0
        public void PropertyReset_RaisesPropertyChangedEvent()
        {
            string propertyChanged = null;

            var instance   = new ExampleType();
            var descriptor = DynamicDescriptor.CreateFromInstance(instance);

            descriptor.PropertyChanged += (s, e) =>
            {
                propertyChanged = e.PropertyName;
            };

            var property = descriptor.GetDynamicProperty(nameof(instance.Property1));

            property.ResetValue(descriptor);

            instance.Property1.Should().BeNull();
            propertyChanged.Should().Be("Property1");
        }
        public void ExampleTest_Failing()
        {
            //arrange
            var databaseName   = "testDatabase";
            var collectionName = typeof(ExampleType).Name;
            var db             = mongoServer.GetDatabase(databaseName);
            var collection     = db.GetCollection <ExampleType>(collectionName);

            //act
            var item = new ExampleType()
            {
                MyProperty = 2
            };

            collection.Insert(item);

            //assert
            mongoServer.AssertDatabaseExists(databaseName)
            .AssertCollectionExists <ExampleType>()
            .AssertCollectionItemCount(1)
            .AssertCollectionHasItemWithProperty <ExampleType>(x => x.MyProperty == 1);
        }
 public void SetType(ExampleType type)
 {
     this.type = type;
     SyncView();
 }
Ejemplo n.º 32
0
 public ExampleAttributes(ExampleType typeOfExample)
 {
     this.ExampleType = typeOfExample;
 }
        public void GetProperties_SomePropertiesAreNotActive_ReturnsOnlyActiveProperties()
        {
            ExampleType instance = new ExampleType();
            DynamicTypeDescriptor descriptor = DynamicDescriptor.CreateFromInstance(instance);

            descriptor.GetDynamicProperty("Property1").SetActive(true);
            descriptor.GetDynamicProperty("Property2").SetActive(false);
            descriptor.GetDynamicProperty("Property3").SetActive(true);
            descriptor.GetDynamicProperty("Property4").SetActive(false);

            PropertyDescriptorCollection properties = descriptor.GetProperties();

            Assert.That(properties.Count, Is.EqualTo(2));
            Assert.That(properties[0].Name, Is.EqualTo("Property1"));
            Assert.That(properties[1].Name, Is.EqualTo("Property3"));
        }
        public void GetProperties_SomePropertyOrdersSet_ReturnsPropertiesInOrderSpecifiedByPropertyOrderThenOtherPropertiesInAlphabeticalOrder()
        {
            ExampleType instance = new ExampleType();
            DynamicTypeDescriptor descriptor = DynamicDescriptor.CreateFromInstance(instance);

            descriptor.GetDynamicProperty("Property1").SetPropertyOrder(null);
            descriptor.GetDynamicProperty("Property2").SetPropertyOrder(null);
            descriptor.GetDynamicProperty("Property3").SetPropertyOrder(1);
            descriptor.GetDynamicProperty("Property4").SetPropertyOrder(0);

            PropertyDescriptorCollection properties = descriptor.GetProperties();

            Assert.That(properties[0].Name, Is.EqualTo("Property4"));
            Assert.That(properties[1].Name, Is.EqualTo("Property3"));
            Assert.That(properties[2].Name, Is.EqualTo("Property1"));
            Assert.That(properties[3].Name, Is.EqualTo("Property2"));
        }
        public void PropertySet_RaisesPropertyChangedEvent()
        {
            string propertyChanged = null;

            var instance = new ExampleType();
            var descriptor = DynamicDescriptor.CreateFromInstance(instance);
            descriptor.PropertyChanged += (s, e) =>
            {
                propertyChanged = e.PropertyName;
            };

            var property = descriptor.GetDynamicProperty(nameof(instance.Property1));
            property.SetValue(descriptor, "modified");

            Assert.That(instance.Property1, Is.EqualTo("modified"));
            Assert.That(propertyChanged, Is.EqualTo("Property1"));
        }
        public void GetDynamicProperty_PropertyNameDoesNotMatchAProperty_ReturnsNull()
        {
            ExampleType instance = new ExampleType();
            DynamicTypeDescriptor descriptor = DynamicDescriptor.CreateFromInstance(instance);

            Assert.That(descriptor.GetDynamicProperty(null), Is.Null);
            Assert.That(descriptor.GetDynamicProperty("NotAValidPropertyName"), Is.Null);
        }
			[Test] public void ClonedByFieldsTest () {
				var original = new ExampleType {stringField = "a"};
				Assert.AreEqual(original.stringField, original.BitwiseCloned().stringField);
			}
Ejemplo n.º 38
0
 public StreamAdapter(Context context, ExampleType exampleType)
     : base(context, 0)
 {
     this.exampleType = exampleType;
     mInflater        = LayoutInflater.From(Context);
 }
        public void GetProperties_SingleAttribute_ReturnsPropertiesWithThatAttribute()
        {
            ExampleType instance = new ExampleType();
            DynamicTypeDescriptor descriptor = DynamicDescriptor.CreateFromInstance(instance);
            PropertyDescriptorCollection properties = descriptor.GetProperties(new Attribute[] { new AttributeOne() });

            bool containsProperty1 = false, containsProperty2 = false, containsProperty3 = false, containsProperty4 = false;
            foreach (PropertyDescriptor property in properties)
            {
                if (property.Name == "Property1") containsProperty1 = true;
                if (property.Name == "Property2") containsProperty2 = true;
                if (property.Name == "Property3") containsProperty3 = true;
                if (property.Name == "Property4") containsProperty4 = true;
            }

            Assert.That(containsProperty1, Is.True);
            Assert.That(containsProperty2, Is.False);
            Assert.That(containsProperty3, Is.True);
            Assert.That(containsProperty4, Is.False);
        }
        public void GetProperties_NoPropertyOrderSet_ReturnsPropertiesInAlphabeticalOrder()
        {
            ExampleType instance = new ExampleType();
            DynamicTypeDescriptor descriptor = DynamicDescriptor.CreateFromInstance(instance);

            PropertyDescriptorCollection properties = descriptor.GetProperties();

            Assert.That(properties[0].Name, Is.EqualTo("Property1"));
            Assert.That(properties[1].Name, Is.EqualTo("Property2"));
            Assert.That(properties[2].Name, Is.EqualTo("Property3"));
            Assert.That(properties[3].Name, Is.EqualTo("Property4"));
        }
        public void GetProperties_PropertyOrderSet_MultiplePropertiesHaveTheSameOrder_ReturnThosePropertiesInAlphabeticalOrder()
        {
            ExampleType instance = new ExampleType();
            DynamicTypeDescriptor descriptor = DynamicDescriptor.CreateFromInstance(instance);

            descriptor.GetDynamicProperty("Property1").SetPropertyOrder(1);
            descriptor.GetDynamicProperty("Property2").SetPropertyOrder(1);
            descriptor.GetDynamicProperty("Property3").SetPropertyOrder(0);
            descriptor.GetDynamicProperty("Property4").SetPropertyOrder(0);

            PropertyDescriptorCollection properties = descriptor.GetProperties();

            Assert.That(properties[0].Name, Is.EqualTo("Property3"));
            Assert.That(properties[1].Name, Is.EqualTo("Property4"));
            Assert.That(properties[2].Name, Is.EqualTo("Property1"));
            Assert.That(properties[3].Name, Is.EqualTo("Property2"));
        }
        public void GetDynamicProperty_PropertyNameMatchesAProperty_ReturnsDynamicPropertyDescriptorForThatProperty()
        {
            ExampleType instance = new ExampleType();
            DynamicTypeDescriptor descriptor = DynamicDescriptor.CreateFromInstance(instance);

            DynamicPropertyDescriptor propertyDescriptor = descriptor.GetDynamicProperty("Property1");

            Assert.That(propertyDescriptor, Is.Not.Null);
            Assert.That(propertyDescriptor.Name, Is.EqualTo("Property1"));
        }
        public void GetProperties_NullOrEmptyAttributeArray_ReturnsSameValueAsGetPropertiesWithoutAttributesSpecified()
        {
            ExampleType instance = new ExampleType();
            DynamicTypeDescriptor descriptor = DynamicDescriptor.CreateFromInstance(instance);

            Assert.That(descriptor.GetProperties(null), Is.EqualTo(descriptor.GetProperties()));
            Assert.That(descriptor.GetProperties(new Attribute[] { }), Is.EqualTo(descriptor.GetProperties()));
        }