Example #1
0
        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.");
        }
Example #2
0
        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.");
        }
Example #3
0
        public void SubjectStateTransitionNewToUnmodifiedWithValidID()
        {
            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'.");
        }
Example #4
0
        public void SubjectAddToInstancesWhenNew()
        {
            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);

            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.New, aSubject.ObjectState, "Object state should remain 'New' when property set.");
        }
Example #5
0
        public void SubjectAddToInstancesWhenDeleted()
        {
            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.Instances.Add(new EAVModelLibrary.ModelRootInstance() { InstanceID = rng.Next() });
        }
Example #6
0
        public void SubjectSetIdentifierWhenDeleted()
        {
            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.Identifier = Guid.NewGuid().ToString();
        }
Example #7
0
        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'.");
        }
Example #8
0
        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'.");
        }