Пример #1
0
        public void ValueSetInstanceWhenUnmodified()
        {
            EAVModelLibrary.ModelValue aValue = new EAVModelLibrary.ModelValue()
            {
                Attribute = new EAVModelLibrary.ModelAttribute()
                {
                    AttributeID = rng.Next()
                }, Instance = new EAVModelLibrary.ModelChildInstance()
                {
                    InstanceID = rng.Next()
                }
            };

            Assert.AreEqual(EAV.Model.ObjectState.New, aValue.ObjectState, "Object state should be 'New' on creation.");

            aValue.Attribute.MarkUnmodified();
            aValue.Instance.MarkUnmodified();

            aValue.MarkUnmodified();

            Assert.AreEqual(EAV.Model.ObjectState.Unmodified, aValue.ObjectState, "Object state failed to transition to 'Unmodified'.");

            EAVModelLibrary.ModelChildInstance instance = new EAVModelLibrary.ModelChildInstance()
            {
                InstanceID = rng.Next()
            };
            aValue.Instance = instance;

            Assert.AreEqual(instance, aValue.Instance, "Property 'Instance' was not set properly.");
            Assert.AreEqual(instance.InstanceID, aValue.InstanceID, "Property 'InstanceID' was not reported properly.");
            Assert.IsTrue(instance.Values.Contains(aValue), "Property 'Values' was not updated properly.");
            Assert.AreEqual(EAV.Model.ObjectState.Modified, aValue.ObjectState, "Object state failed to transition to 'Modified'.");
        }
Пример #2
0
        public void ValueSetInstanceWhenNew()
        {
            EAV.Model.IModelValue aValue = factory.Create <EAV.Model.IModelValue>();

            Assert.AreEqual(EAV.Model.ObjectState.New, aValue.ObjectState, "Object state should be 'New' on creation.");

            EAVModelLibrary.ModelChildInstance value = new EAVModelLibrary.ModelChildInstance()
            {
                InstanceID = rng.Next()
            };
            aValue.Instance = value;

            Assert.AreEqual(value, aValue.Instance, "Property 'Instance' was not set properly.");
            Assert.AreEqual(value.InstanceID, aValue.InstanceID, "Property 'InstanceID' was not reported properly.");
            Assert.IsTrue(value.Values.Contains(aValue), "Property 'Values' was not updated properly.");
            Assert.AreEqual(EAV.Model.ObjectState.New, aValue.ObjectState, "Object state should remain 'New' when property set.");
        }