public void CreateProperty() { MemoryProperty property = new MemoryProperty("Prop", TestType); Assert.IsTrue(property.Key == "Prop", "Property has incorrect name"); Assert.IsTrue(property.Type == TestType, "Property has incorrect datatype"); }
public void DuplicatePrivatePublicProperty() { DataType propType = new DataType("PropType", new MemoryProperty[0], new MemoryProperty[0]); MemoryProperty prop = new MemoryProperty("Prop", propType); Assert.ThrowsException <TypePropertyException>(() => new DataType("ChildType", new MemoryProperty[] { prop }, new MemoryProperty[] { prop })); }
public void DuplicatePropertyInGroup() { IWritableMemoryGroup testGroup = new MemoryGroup(); MemoryProperty prop = new MemoryProperty("Property", new DataType("TestType", new MemoryProperty[0], new MemoryProperty[0])); Assert.IsTrue(testGroup.Add(new MemoryItem(prop)), "Failed to add item."); Assert.IsFalse(testGroup.Add(new MemoryItem(prop)), "Duplicate property was allowed to be added."); }
public void PrivatePropertyInContract() { DataType propType = new DataType("PropType", new MemoryProperty[0], new MemoryProperty[0]); MemoryProperty prop = new MemoryProperty("Prop", propType); DataContract c = new DataContract("TestContract", new MemoryProperty[] { prop }, new DataContract[0]); Assert.ThrowsException <TypePropertyException>(() => new DataType("ChildType", new MemoryProperty[0], new MemoryProperty[] { prop }, new DataContract[] { c })); }
public void ImplementContractWithProperty() { DataType propType = new DataType("PropType", new MemoryProperty[0], new MemoryProperty[0]); MemoryProperty prop = new MemoryProperty("Prop", propType); DataContract c = new DataContract("TestContract", new MemoryProperty[] { prop }, new DataContract[0]); DataType t = new DataType("ChildType", new MemoryProperty[] { prop }, new MemoryProperty[0], new DataContract[] { c }); Assert.IsTrue(t.InheritedContracts.Contains(c), "Implementing type does not inherit from contract."); }
public void InheritTypeWithProperty() { DataType propType = new DataType("PropType", new MemoryProperty[0], new MemoryProperty[0]); MemoryProperty prop = new MemoryProperty("Prop", propType); DataType p = new DataType("ParentType", new MemoryProperty[] { prop }, new MemoryProperty[0]); DataType t = new DataType("ChildType", new MemoryProperty[0], new MemoryProperty[0], parentType: p); Assert.AreEqual(p, t.ParentType, "Child type does not inherit from parent type."); Assert.IsTrue(p.PublicProperties.Contains(prop), "Parent type does not contain property."); Assert.IsTrue(t.PublicProperties.Contains(prop), "Child type does not contain property."); }
/// <inheritdoc/> public bool ContainsKey(MemoryProperty property) => PublicProperties.ContainsKey(property);
/// <inheritdoc/> public void Set(MemoryProperty property, DataObject value) => PublicProperties.Set(property, value);
/// <inheritdoc/> public MemoryItem Get(MemoryProperty property) => PublicProperties.Get(property);
/// <summary> /// Creates a new <see cref="GetCommand"/>. /// </summary> /// <param name="property">The <see cref="MemoryProperty"/> where the desired <see cref="MemoryItem"/> is located.</param> /// <param name="value">An <see cref="ICommand"/> that returns the desired <see cref="DataObject"/> value to store in memory.</param> public SetCommand(MemoryProperty property, ICommand value) { Property = property; Value = value; }
/// <summary> /// Creates a new <see cref="GetCommand"/>. /// </summary> /// <param name="property">The <see cref="MemoryProperty"/> where the desired <see cref="MemoryItem"/> is located.</param> public GetCommand(MemoryProperty property) { Property = property; }