public void AttachProperties_AttachAlreadyAttachedContext_ThrowsArgumentException() { var prophandler = DummyFactory.GetPropertyHandler(); var attachedProperties = DummyFactory.GetPropertyCollection(12); prophandler.AttachProperties(attachedProperties); Assert.Throws <ArgumentException>(() => prophandler.AttachProperties(attachedProperties)); }
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]); }
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); }
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)); }
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)); }
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"); }
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); }