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(); }
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(); }
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."); }
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); } }
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(); }
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); }
public void GetDynamicProperty_PropertyNameDoesNotMatchAProperty_ReturnsNull() { var instance = new ExampleType(); var descriptor = DynamicDescriptor.CreateFromInstance(instance); descriptor.GetDynamicProperty(null).Should().BeNull(); descriptor.GetDynamicProperty("NotAValidPropertyName").Should().BeNull(); }
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) )); }
public static RoundedFragment GetInstance(ExampleType exampleType) { RoundedFragment f = new RoundedFragment(); Bundle args = new Bundle(); args.PutInt(ExampleTypeArgument, (int)exampleType); f.Arguments = args; return(f); }
public override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); if (Arguments != null) { exampleType = (ExampleType)(Arguments.GetInt(ExampleTypeArgument)); } }
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")); }
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"); }
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"); }
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); }
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")); }
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.")); }
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"); }
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"); }
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); }
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"); }
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); } }
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(); }
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); }
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())); }