예제 #1
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.");
        }
예제 #2
0
        public void SubjectSetContextWhenNew()
        {
            EAV.Model.IModelSubject aSubject = factory.Create<EAV.Model.IModelSubject>();

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

            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.New, aSubject.ObjectState, "Object state should remain 'New' when property set.");
        }