Exemple #1
0
        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");
        }
Exemple #2
0
        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 }));
        }
Exemple #3
0
        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.");
        }
Exemple #4
0
        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 }));
        }
Exemple #5
0
        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.");
        }
Exemple #6
0
        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.");
        }
Exemple #7
0
 /// <inheritdoc/>
 public bool ContainsKey(MemoryProperty property)
 => PublicProperties.ContainsKey(property);
Exemple #8
0
 /// <inheritdoc/>
 public void Set(MemoryProperty property, DataObject value)
 => PublicProperties.Set(property, value);
Exemple #9
0
 /// <inheritdoc/>
 public MemoryItem Get(MemoryProperty property)
 => PublicProperties.Get(property);
Exemple #10
0
 /// <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;
 }
Exemple #11
0
 /// <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;
 }