NStub.CSharp.ObjectGeneration.BuildDataDictionary.AddDataItem C# (CSharp) Method

AddDataItem() public method

Adds the specified data item to the "General" topic of this list.
public AddDataItem ( string key, IBuilderData item ) : void
key string The key of the item.
item IBuilderData The data item to add.
return void
        public void AddDataItem(string key, IBuilderData item)
        {
            this.generalData.Add(key, item);
            isDirty = true;
        }

Same methods

BuildDataDictionary::AddDataItem ( string key, IBuilderData item, bool replace ) : void
BuildDataDictionary::AddDataItem ( string category, string key, IBuilderData item ) : void
BuildDataDictionary::AddDataItem ( string category, string key, IBuilderData item, bool replace ) : void
BuildDataDictionary::AddDataItem ( string category, string key, IBuilderData item, bool replace, bool skip ) : void

Usage Example

Esempio n. 1
0
        public void PropertyIsDirtyNormalBehavior()
        {
            // Test read access of 'IsDirty' Property.
            var expected = false;
            var actual = testObject.IsDirty;
            Assert.AreEqual(expected, actual);

            testObject.AddDataItem("Moo", "Key", item1);
            expected = true;
            actual = testObject.IsDirty;
            Assert.AreEqual(expected, actual);

            this.testObject = new BuildDataDictionary();
            testObject.AddDataItem("YesInGeneral", item2);
            actual = testObject.IsDirty;
            Assert.AreEqual(expected, actual);

            this.testObject = new BuildDataDictionary();
            testObject.AddDataItem("NotInGeneral", "My-Key", item3);
            actual = testObject.IsDirty;
            Assert.AreEqual(expected, actual);

            testObject.Save();
            expected = false;
            actual = testObject.IsDirty;
            Assert.AreEqual(expected, actual);

            // replacing the existing from above should not affect the dirty flag.
            testObject.AddDataItem("NotInGeneral", "My-Key", item3, true);
            actual = testObject.IsDirty;
            Assert.AreEqual(expected, actual);

            testObject.AddDataItem("NotInGeneral", "My-OtherKey", item3, true);
            expected = true;
            actual = testObject.IsDirty;
            Assert.AreEqual(expected, actual);
        }