public void ValueStateTransitionDeletedToUnmodified() { EAVModelLibrary.ModelValue aValue = new EAVModelLibrary.ModelValue() { Instance = new EAVModelLibrary.ModelRootInstance() { InstanceID = rng.Next() }, Attribute = new EAVModelLibrary.ModelAttribute() { AttributeID = rng.Next() } }; Assert.AreEqual(EAV.Model.ObjectState.New, aValue.ObjectState, "Object state should be 'New' on creation."); aValue.MarkUnmodified(); Assert.AreEqual(EAV.Model.ObjectState.Unmodified, aValue.ObjectState, "Object state failed to transition to 'Unmodified'."); aValue.MarkDeleted(); Assert.AreEqual(EAV.Model.ObjectState.Deleted, aValue.ObjectState, "Object state failed to transition to 'Deleted'."); aValue.MarkUnmodified(); }
public void ValueSetUnitWhenUnmodifiedVariableUnitsIsNull() { EAVModelLibrary.ModelValue aValue = new EAVModelLibrary.ModelValue() { Instance = new EAVModelLibrary.ModelRootInstance() { InstanceID = rng.Next() }, Attribute = new EAVModelLibrary.ModelAttribute() { AttributeID = rng.Next(), VariableUnits = null } }; Assert.AreEqual(EAV.Model.ObjectState.New, aValue.ObjectState, "Object state should be 'New' on creation."); aValue.Instance.MarkUnmodified(); aValue.Attribute.MarkUnmodified(); aValue.MarkUnmodified(); Assert.AreEqual(EAV.Model.ObjectState.Unmodified, aValue.ObjectState, "Object state failed to transition to 'Unmodified'."); aValue.Unit = new EAVModelLibrary.ModelUnit() { UnitID = rng.Next() }; }
public void ValueSetUnitWhenUnmodifiedVariableUnitsIsFalse() { EAVModelLibrary.ModelValue aValue = new EAVModelLibrary.ModelValue() { Instance = new EAVModelLibrary.ModelRootInstance() { InstanceID = rng.Next() }, Attribute = new EAVModelLibrary.ModelAttribute() { AttributeID = rng.Next(), VariableUnits = false } }; Assert.AreEqual(EAV.Model.ObjectState.New, aValue.ObjectState, "Object state should be 'New' on creation."); aValue.Instance.MarkUnmodified(); aValue.Attribute.MarkUnmodified(); aValue.MarkUnmodified(); Assert.AreEqual(EAV.Model.ObjectState.Unmodified, aValue.ObjectState, "Object state failed to transition to 'Unmodified'."); EAVModelLibrary.ModelUnit aUnit = new EAVModelLibrary.ModelUnit() { UnitID = rng.Next() }; aValue.Unit = aUnit; Assert.AreEqual(aUnit, aValue.Unit, "Property 'Units' was not set properly."); Assert.AreEqual(aUnit.UnitID, aValue.UnitID, "Property 'UnitID' was not reported properly."); Assert.AreEqual(EAV.Model.ObjectState.Modified, aValue.ObjectState, "Object state failed to transition to 'Modified'."); Assert.AreEqual(EAV.Model.ObjectState.New, aUnit.ObjectState, String.Format("Object state for Unit object incorrectly transitioned to '{0}' when 'Unit' property set.", aUnit.ObjectState)); }
public void ValueSetAttributeWhenUnmodified() { 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.ModelAttribute attribute = new EAVModelLibrary.ModelAttribute() { AttributeID = rng.Next() }; aValue.Attribute = attribute; Assert.AreEqual(attribute, aValue.Attribute, "Property 'Attribute' was not set properly."); Assert.AreEqual(attribute.AttributeID, aValue.AttributeID, "Property 'AttributeID' was not reported properly."); Assert.IsTrue(attribute.Values.Contains(aValue), "Property 'Values' was not updated properly."); Assert.AreEqual(EAV.Model.ObjectState.Modified, aValue.ObjectState, "Object state failed to transition to 'Modified'."); }
public void ValueSetRawValueWhenModified() { EAVModelLibrary.ModelValue aValue = new EAVModelLibrary.ModelValue() { Instance = new EAVModelLibrary.ModelRootInstance() { InstanceID = rng.Next() }, Attribute = new EAVModelLibrary.ModelAttribute() { AttributeID = rng.Next() } }; Assert.AreEqual(EAV.Model.ObjectState.New, aValue.ObjectState, "Object state should be 'New' on creation."); aValue.Instance.MarkUnmodified(); aValue.Attribute.MarkUnmodified(); aValue.MarkUnmodified(); Assert.AreEqual(EAV.Model.ObjectState.Unmodified, aValue.ObjectState, "Object state failed to transition to 'Unmodified'."); string value = Guid.NewGuid().ToString(); aValue.RawValue = value; Assert.AreEqual(value, aValue.RawValue, "Property 'RawValue' was not set properly."); Assert.AreEqual(EAV.Model.ObjectState.Modified, aValue.ObjectState, "Object state failed to transition to 'Modified'."); value = Guid.NewGuid().ToString(); aValue.RawValue = value; Assert.AreEqual(value, aValue.RawValue, "Property 'RawValue' was not set properly."); Assert.AreEqual(EAV.Model.ObjectState.Modified, aValue.ObjectState, "Object state should remain 'Modified' when property set."); }
public void ValueSetAttributeWhenUnmodifiedWithNullInstance() { EAVModelLibrary.ModelValue aValue = new EAVModelLibrary.ModelValue() { Attribute = new EAVModelLibrary.ModelAttribute() { AttributeID = rng.Next() } }; Assert.AreEqual(EAV.Model.ObjectState.New, aValue.ObjectState, "Object state should be 'New' on creation."); aValue.Attribute.MarkUnmodified(); aValue.MarkUnmodified(); }