public void SubjectStateTransitionDeletedToUnmodified() { ModelSubject aSubject = new EAVModelLibrary.ModelSubject() { SubjectID = rng.Next() }; Assert.AreEqual(EAV.Model.ObjectState.New, aSubject.ObjectState, "Object state should be 'New' on creation."); aSubject.MarkUnmodified(); Assert.AreEqual(EAV.Model.ObjectState.Unmodified, aSubject.ObjectState, "Object state failed to transition to 'Unmodified'."); aSubject.MarkDeleted(); Assert.AreEqual(EAV.Model.ObjectState.Deleted, aSubject.ObjectState, "Object state failed to transition to 'Deleted'."); aSubject.MarkUnmodified(); }
public void SubjectClearInstancesWhenModified() { ModelSubject aSubject = new EAVModelLibrary.ModelSubject() { SubjectID = rng.Next() }; Assert.AreEqual(EAV.Model.ObjectState.New, aSubject.ObjectState, "Object state should be 'New' on creation."); aSubject.MarkUnmodified(); Assert.AreEqual(EAV.Model.ObjectState.Unmodified, aSubject.ObjectState, "Object state failed to transition to 'Unmodified'."); ModelRootInstance value = new EAVModelLibrary.ModelRootInstance() { InstanceID = rng.Next() }; aSubject.Instances.Add(value); value = new EAVModelLibrary.ModelRootInstance() { InstanceID = rng.Next() }; aSubject.Instances.Add(value); Assert.IsTrue(aSubject.Instances.Contains(value), "Property 'Instances' was not updated properly."); Assert.AreEqual(aSubject, value.Subject, "Property 'Subject' was not set properly."); Assert.AreEqual(aSubject.SubjectID, value.SubjectID, "Property 'SubjectID' was not set properly."); Assert.AreEqual(EAV.Model.ObjectState.Modified, aSubject.ObjectState, "Object state failed to transition to 'Modified'."); aSubject.Instances.Clear(); Assert.IsFalse(aSubject.Instances.Contains(value), "Property 'Instances' was not updated properly."); Assert.IsNull(value.Subject, "Property 'Subject' was not set properly."); Assert.IsNull(value.SubjectID, "Property 'SubjectID' was not set properly."); Assert.IsFalse(aSubject.Instances.Any(), "Property 'Instances' was not updated properly."); Assert.AreEqual(EAV.Model.ObjectState.Modified, aSubject.ObjectState, "Object state should remain 'Modified' when property set."); }
public void SubjectSetContextWhenModified() { ModelSubject aSubject = new EAVModelLibrary.ModelSubject() { SubjectID = rng.Next() }; Assert.AreEqual(EAV.Model.ObjectState.New, aSubject.ObjectState, "Object state should be 'New' on creation."); aSubject.MarkUnmodified(); Assert.AreEqual(EAV.Model.ObjectState.Unmodified, aSubject.ObjectState, "Object state failed to transition to 'Unmodified'."); ModelContext value = new EAVModelLibrary.ModelContext() { ContextID = rng.Next() }; aSubject.Context = value; Assert.AreEqual(value, aSubject.Context, "Property 'Context' was not set properly."); Assert.AreEqual(value.ContextID, aSubject.ContextID, "Property 'ContextID' was not reported properly."); Assert.IsTrue(value.Subjects.Contains(aSubject), "Property 'Subjects' was not updated properly."); Assert.AreEqual(EAV.Model.ObjectState.Modified, aSubject.ObjectState, "Object state failed to transition to 'Modified'."); value = new EAVModelLibrary.ModelContext() { ContextID = rng.Next() }; aSubject.Context = value; Assert.AreEqual(value, aSubject.Context, "Property 'Context' was not set properly."); Assert.AreEqual(value.ContextID, aSubject.ContextID, "Property 'ContextID' was not reported properly."); Assert.IsTrue(value.Subjects.Contains(aSubject), "Property 'Subjects' was not updated properly."); Assert.AreEqual(EAV.Model.ObjectState.Modified, aSubject.ObjectState, "Object state should remain 'Modified' when property set."); }
public void SubjectSetIdentifierWhenUnmodified() { ModelSubject aSubject = new EAVModelLibrary.ModelSubject() { SubjectID = rng.Next() }; Assert.AreEqual(EAV.Model.ObjectState.New, aSubject.ObjectState, "Object state should be 'New' on creation."); aSubject.MarkUnmodified(); Assert.AreEqual(EAV.Model.ObjectState.Unmodified, aSubject.ObjectState, "Object state failed to transition to 'Unmodified'."); string value = Guid.NewGuid().ToString(); aSubject.Identifier = value; Assert.AreEqual(value, aSubject.Identifier, "Property 'Identifier' was not set properly."); Assert.AreEqual(EAV.Model.ObjectState.Modified, aSubject.ObjectState, "Object state failed to transition to 'Modified'."); }
public void SubjectSetEntityWhenUnmodified() { ModelSubject aSubject = new EAVModelLibrary.ModelSubject() { SubjectID = rng.Next() }; Assert.AreEqual(EAV.Model.ObjectState.New, aSubject.ObjectState, "Object state should be 'New' on creation."); aSubject.MarkUnmodified(); Assert.AreEqual(EAV.Model.ObjectState.Unmodified, aSubject.ObjectState, "Object state failed to transition to 'Unmodified'."); ModelEntity value = new EAVModelLibrary.ModelEntity() { EntityID = rng.Next() }; aSubject.Entity = value; Assert.AreEqual(value, aSubject.Entity, "Property 'Entity' was not set properly."); Assert.AreEqual(value.EntityID, aSubject.EntityID, "Property 'EntityID' was not reported properly."); Assert.IsTrue(value.Subjects.Contains(aSubject), "Property 'Subjects' was not updated properly."); Assert.AreEqual(EAV.Model.ObjectState.Modified, aSubject.ObjectState, "Object state failed to transition to 'Modified'."); }
public void SubjectClearInstancesWhenDeleted() { ModelSubject aSubject = new EAVModelLibrary.ModelSubject() { SubjectID = rng.Next() }; Assert.AreEqual(EAV.Model.ObjectState.New, aSubject.ObjectState, "Object state should be 'New' on creation."); ModelRootInstance value = new EAVModelLibrary.ModelRootInstance() { InstanceID = rng.Next() }; aSubject.Instances.Add(value); aSubject.MarkUnmodified(); value.MarkUnmodified(); Assert.AreEqual(EAV.Model.ObjectState.Unmodified, aSubject.ObjectState, "Object state failed to transition to 'Unmodified'."); Assert.AreEqual(EAV.Model.ObjectState.Unmodified, value.ObjectState, "Object state failed to transition to 'Unmodified'."); aSubject.MarkDeleted(); Assert.AreEqual(EAV.Model.ObjectState.Deleted, aSubject.ObjectState, "Object state failed to transition to 'Deleted'."); Assert.AreEqual(EAV.Model.ObjectState.Deleted, value.ObjectState, "Object state failed to transition to 'Deleted'."); aSubject.Instances.Clear(); }