Ejemplo n.º 1
0
        public void AttachProperties_AttachAlreadyAttachedContext_ThrowsArgumentException()
        {
            var prophandler = DummyFactory.GetPropertyHandler();

            var attachedProperties = DummyFactory.GetPropertyCollection(12);

            prophandler.AttachProperties(attachedProperties);
            Assert.Throws <ArgumentException>(() => prophandler.AttachProperties(attachedProperties));
        }
Ejemplo n.º 2
0
        public void Indexer_TryGetFirstPropertyFromContext_ReturnsProperty()
        {
            var prophandler        = DummyFactory.GetPropertyHandler();
            var attachedProperties = DummyFactory.GetPropertyCollection(12);

            prophandler.AttachProperties(attachedProperties);
            var firstProperty = attachedProperties.First();

            Assert.AreEqual(firstProperty, prophandler[firstProperty.Name, firstProperty.Context]);
        }
Ejemplo n.º 3
0
        public void SetProperty_SetPropertyInOtherContextAndReadTheCommonName_ReturnsSetValue()
        {
            var prophandler        = DummyFactory.GetPropertyHandler();
            var anotherContext     = new Context("AnotherContext");
            var attachedProperties = DummyFactory.GetPropertyCollection(12, anotherContext);

            prophandler.AttachProperties(attachedProperties);
            prophandler.SetProperty(prophandler.PropertyNames.Department, prophandler.PropertyNames.ContextNames.Department, "Hello World");
            Assert.AreEqual("Hello World", prophandler.Department);
        }
Ejemplo n.º 4
0
        public void AttachProperties_AttachCollectionForContext_ContextAttached()
        {
            var prophandler = DummyFactory.GetPropertyHandler();

            var context            = new Context("context");
            var attachedProperties = DummyFactory.GetPropertyCollection(12, context);

            prophandler.AttachProperties(attachedProperties);

            Assert.IsTrue(prophandler.AttachedContexts.Contains(context));
            Assert.AreEqual(attachedProperties, prophandler.GetProperties(context));
        }
Ejemplo n.º 5
0
        public void AttachProperties_AttachCollectionForContext_AnotherContextNotAttached()
        {
            var prophandler = DummyFactory.GetPropertyHandler();

            var context            = new Context("context");
            var attachedProperties = DummyFactory.GetPropertyCollection(12, context);

            prophandler.AttachProperties(attachedProperties);
            var anotherContext = new Context("anotherContext");

            Assert.IsFalse(prophandler.AttachedContexts.Contains(anotherContext));
            Assert.IsNull(prophandler.GetProperties(anotherContext));
        }
Ejemplo n.º 6
0
        public void MakeReadOnly_AttachContextAfterReadonly_AttachContextBecomesReadonly()
        {
            var prophandler = DummyFactory.GetPropertyHandler("username");

            prophandler.MakeReadOnly();

            var anotherContext     = new Context("AnotherContext");
            var attachedProperties = DummyFactory.GetPropertyCollection(12, anotherContext);

            prophandler.AttachProperties(attachedProperties);

            Assert.Throws <ReadOnlyException>(() => prophandler.Department = "Other Department");
        }
Ejemplo n.º 7
0
        public void CreateWritable_AttachContextAfterReadonly_AttachContextBecomesReadonly()
        {
            var prophandler = DummyFactory.GetPropertyHandler("username");

            prophandler.MakeReadOnly();

            var anotherContext     = new Context("AnotherContext");
            var attachedProperties = DummyFactory.GetPropertyCollection(12, anotherContext);

            prophandler.AttachProperties(attachedProperties);

            var newprophander = prophandler.CreateWritable();

            Assert.AreNotSame(prophandler, newprophander);

            newprophander.StreetAddress = "Other Address";
            newprophander.Department    = "Other Department";

            Assert.AreEqual("Other Address", newprophander.StreetAddress);
            Assert.AreEqual("Other Department", newprophander.Department);
            Assert.AreNotEqual("Other Address", prophandler.StreetAddress);
            Assert.AreNotEqual("Other Department", prophandler.Department);
        }