public ClassWithAllDataTypes GetNewChanged() { ClassWithAllDataTypes newChanged = ClassWithAllDataTypes.NewObject(); newChanged.Int32Property = 13; return(newChanged); }
public void CommitSub_ObjectNewInParent() { var newObject = ClassWithAllDataTypes.NewObject(); CheckNotMarkedAsChanged(newObject); Assert.That(newObject.State, Is.EqualTo(StateType.New)); using (ClientTransaction.Current.CreateSubTransaction().EnterDiscardingScope()) { CheckNotMarkedAsChanged(newObject); Assert.That(newObject.State, Is.EqualTo(StateType.Unchanged)); newObject.RegisterForCommit(); CheckMarkedAsChanged(newObject); Assert.That(newObject.State, Is.EqualTo(StateType.Changed)); ClientTransaction.Current.Commit(); CheckNotMarkedAsChanged(newObject); Assert.That(newObject.State, Is.EqualTo(StateType.Unchanged)); } CheckNotMarkedAsChanged(newObject); Assert.That(newObject.State, Is.EqualTo(StateType.New)); }
private ClassWithAllDataTypes CreateSaveableNewObject() { var result = ClassWithAllDataTypes.NewObject(); result.FillMandatoryProperties(); return(result); }
public void ConstructedObjectIsDerived() { ClassWithAllDataTypes classWithAllDataTypes = ClassWithAllDataTypes.NewObject(); Assert.That(classWithAllDataTypes, Is.Not.TypeOf <ClassWithAllDataTypes>()); Assert.That(classWithAllDataTypes, Is.InstanceOf <ClassWithAllDataTypes>()); }
public void ObjectValuesCanBeChangedInParentAndChildSubTransactions() { SetDatabaseModifyable(); ClassWithAllDataTypes cwadt = DomainObjectIDs.ClassWithAllDataTypes1.GetObject <ClassWithAllDataTypes> (); Assert.That(cwadt.Int32Property, Is.Not.EqualTo(7)); Assert.That(cwadt.Int16Property, Is.Not.EqualTo(8)); using (ClientTransaction.Current.CreateSubTransaction().EnterDiscardingScope()) { cwadt.Int32Property = 7; using (ClientTransaction.Current.CreateSubTransaction().EnterDiscardingScope()) { Assert.That(cwadt.Int32Property, Is.EqualTo(7)); cwadt.Int16Property = 8; ClientTransaction.Current.Commit(); } Assert.That(cwadt.Int32Property, Is.EqualTo(7)); Assert.That(cwadt.Int16Property, Is.EqualTo(8)); ClientTransaction.Current.Commit(); } Assert.That(cwadt.Int32Property, Is.EqualTo(7)); Assert.That(cwadt.Int16Property, Is.EqualTo(8)); TestableClientTransaction.Commit(); using (ClientTransaction.CreateRootTransaction().EnterDiscardingScope()) { var objectInThisTransaction = cwadt.GetHandle().GetObject(); Assert.That(objectInThisTransaction.Int32Property, Is.EqualTo(7)); Assert.That(objectInThisTransaction.Int16Property, Is.EqualTo(8)); } }
public void SetPropertyValue_WithNullAndAbstractProperty() { ClassWithAllDataTypes classWithAllDataTypes = ClassWithAllDataTypes.NewObject(); classWithAllDataTypes.StringWithNullValueProperty = null; Assert.That(classWithAllDataTypes.StringWithNullValueProperty, Is.Null); }
public void InvalidStateType() { ClassWithAllDataTypes newObject = ClassWithAllDataTypes.NewObject(); DataContainer newObjectDataContainer = newObject.InternalDataContainer; ClassWithAllDataTypes loadedObject = DomainObjectIDs.ClassWithAllDataTypes1.GetObject <ClassWithAllDataTypes> (); DataContainer loadedObjectDataContainer = newObject.InternalDataContainer; Assert.That(newObject.IsInvalid, Is.False); Assert.That(newObject.State, Is.EqualTo(StateType.New)); Assert.That(loadedObject.IsInvalid, Is.False); Assert.That(loadedObject.State, Is.EqualTo(StateType.Unchanged)); newObject.Delete(); Assert.That(newObject.IsInvalid, Is.True); Assert.That(newObject.State, Is.EqualTo(StateType.Invalid)); Assert.That(newObjectDataContainer.IsDiscarded, Is.True); Assert.That(newObjectDataContainer.State, Is.EqualTo(StateType.Invalid)); loadedObject.Delete(); TestableClientTransaction.Commit(); Assert.That(loadedObject.IsInvalid, Is.True); Assert.That(loadedObject.State, Is.EqualTo(StateType.Invalid)); Assert.That(loadedObjectDataContainer.IsDiscarded, Is.True); Assert.That(loadedObjectDataContainer.State, Is.EqualTo(StateType.Invalid)); }
public void CommitSavesPropertyValuesToParentTransaction() { Order loadedOrder = DomainObjectIDs.Order1.GetObject <Order> (); ClassWithAllDataTypes newClassWithAllDataTypes = ClassWithAllDataTypes.NewObject(); loadedOrder.OrderNumber = 5; newClassWithAllDataTypes.Int16Property = 7; using (TestableClientTransaction.CreateSubTransaction().EnterDiscardingScope()) { loadedOrder.OrderNumber = 13; newClassWithAllDataTypes.Int16Property = 47; ClientTransactionScope.CurrentTransaction.Commit(); Assert.That(loadedOrder.State, Is.EqualTo(StateType.Unchanged)); Assert.That(newClassWithAllDataTypes.State, Is.EqualTo(StateType.Unchanged)); Assert.That(loadedOrder.OrderNumber, Is.EqualTo(13)); Assert.That(newClassWithAllDataTypes.Int16Property, Is.EqualTo(47)); } Assert.That(loadedOrder.OrderNumber, Is.EqualTo(13)); Assert.That(newClassWithAllDataTypes.Int16Property, Is.EqualTo(47)); Assert.That(loadedOrder.State, Is.EqualTo(StateType.Changed)); Assert.That(newClassWithAllDataTypes.State, Is.EqualTo(StateType.New)); }
public void SetValidEnumValue() { var instance = ClassWithAllDataTypes.NewObject(); instance.EnumProperty = ClassWithAllDataTypes.EnumType.Value0; Assert.That(instance.EnumProperty, Is.EqualTo(ClassWithAllDataTypes.EnumType.Value0)); }
public static DomainObject GetNewObject() { var newInstance = ClassWithAllDataTypes.NewObject(); Assert.That(newInstance.State, Is.EqualTo(StateType.New)); return(newInstance); }
public void CreateCloneHull_TouchesNoProperties() { ClassWithAllDataTypes clone = _cloner.CreateCloneHull(_classWithAllDataTypes); Assert.That(clone.Int32Property, Is.Not.EqualTo(_classWithAllDataTypes.Int32Property)); Assert.That(clone.Properties[typeof(ClassWithAllDataTypes), "Int32Property"].HasBeenTouched, Is.False); }
public void IsNullPropertyValue() { ClassWithAllDataTypes cwadt = ClassWithAllDataTypes.NewObject(); Assert.That(cwadt.Properties["Remotion.Data.DomainObjects.UnitTests.TestDomain.ClassWithAllDataTypes.NaBooleanProperty"].IsNull, Is.True); Assert.That(cwadt.Properties["Remotion.Data.DomainObjects.UnitTests.TestDomain.ClassWithAllDataTypes.BooleanProperty"].IsNull, Is.False); cwadt.Properties["Remotion.Data.DomainObjects.UnitTests.TestDomain.ClassWithAllDataTypes.NaBooleanProperty"].SetValue <bool?> (true); Assert.That(cwadt.Properties["Remotion.Data.DomainObjects.UnitTests.TestDomain.ClassWithAllDataTypes.NaBooleanProperty"].IsNull, Is.False); cwadt.Properties["Remotion.Data.DomainObjects.UnitTests.TestDomain.ClassWithAllDataTypes.NaBooleanProperty"].SetValue <bool?> (null); Assert.That(cwadt.Properties["Remotion.Data.DomainObjects.UnitTests.TestDomain.ClassWithAllDataTypes.NaBooleanProperty"].IsNull, Is.True); cwadt.Properties["Remotion.Data.DomainObjects.UnitTests.TestDomain.ClassWithAllDataTypes.NaBooleanProperty"].SetValue <bool?> (null); Assert.That(cwadt.Properties["Remotion.Data.DomainObjects.UnitTests.TestDomain.ClassWithAllDataTypes.NaBooleanProperty"].IsNull, Is.True); Assert.That(cwadt.Properties["Remotion.Data.DomainObjects.UnitTests.TestDomain.ClassWithAllDataTypes.StringWithNullValueProperty"].IsNull, Is.True); Assert.That(cwadt.Properties["Remotion.Data.DomainObjects.UnitTests.TestDomain.ClassWithAllDataTypes.StringProperty"].IsNull, Is.False); cwadt.Properties["Remotion.Data.DomainObjects.UnitTests.TestDomain.ClassWithAllDataTypes.StringWithNullValueProperty"].SetValue(""); Assert.That(cwadt.Properties["Remotion.Data.DomainObjects.UnitTests.TestDomain.ClassWithAllDataTypes.StringWithNullValueProperty"].IsNull, Is.False); cwadt.Properties["Remotion.Data.DomainObjects.UnitTests.TestDomain.ClassWithAllDataTypes.StringWithNullValueProperty"].SetValue <string> (null); Assert.That(cwadt.Properties["Remotion.Data.DomainObjects.UnitTests.TestDomain.ClassWithAllDataTypes.StringWithNullValueProperty"].IsNull, Is.True); Assert.That(cwadt.Properties["Remotion.Data.DomainObjects.UnitTests.TestDomain.ClassWithAllDataTypes.ExtensibleEnumWithNullValueProperty"].IsNull, Is.True); Assert.That(cwadt.Properties["Remotion.Data.DomainObjects.UnitTests.TestDomain.ClassWithAllDataTypes.ExtensibleEnumProperty"].IsNull, Is.False); cwadt.Properties["Remotion.Data.DomainObjects.UnitTests.TestDomain.ClassWithAllDataTypes.ExtensibleEnumWithNullValueProperty"].SetValue(Color.Values.Green()); Assert.That(cwadt.Properties["Remotion.Data.DomainObjects.UnitTests.TestDomain.ClassWithAllDataTypes.ExtensibleEnumWithNullValueProperty"].IsNull, Is.False); cwadt.Properties["Remotion.Data.DomainObjects.UnitTests.TestDomain.ClassWithAllDataTypes.ExtensibleEnumWithNullValueProperty"].SetValue <Color> (null); Assert.That(cwadt.Properties["Remotion.Data.DomainObjects.UnitTests.TestDomain.ClassWithAllDataTypes.ExtensibleEnumWithNullValueProperty"].IsNull, Is.True); }
public void FinishTransport_FilterNew() { TransportedDomainObjects transportedObjects = TransportAndDeleteObjects( DomainObjectIDs.ClassWithAllDataTypes1, DomainObjectIDs.ClassWithAllDataTypes2); transportedObjects.FinishTransport(transportedObject => { Assert.That(transportedObject.State == StateType.New); return(((ClassWithAllDataTypes)transportedObject).Int32Property < 0); }); using (ClientTransaction.CreateRootTransaction().EnterNonDiscardingScope()) { try { DomainObjectIDs.ClassWithAllDataTypes1.GetObject <ClassWithAllDataTypes> (); Assert.Fail("Expected ObjectsNotFoundException"); } catch (ObjectsNotFoundException) { // ok } ClassWithAllDataTypes c2 = DomainObjectIDs.ClassWithAllDataTypes2.GetObject <ClassWithAllDataTypes> (); Assert.That(c2.Int32Property, Is.EqualTo(-2147483647)); } }
public override void SetUp() { base.SetUp(); _loadedClassWithAllDataTypes = DomainObjectIDs.ClassWithAllDataTypes1.GetObject <ClassWithAllDataTypes> (); _newClassWithAllDataTypes = ClassWithAllDataTypes.NewObject(); _loadedClassWithAllDataTypesMixin = Mixin.Get <MixinWithAccessToDomainObjectProperties <ClassWithAllDataTypes> > (_loadedClassWithAllDataTypes); _newClassWithAllDataTypesMixin = Mixin.Get <MixinWithAccessToDomainObjectProperties <ClassWithAllDataTypes> > (_newClassWithAllDataTypes); }
private int GetInt32Property(ClientTransaction clientTransaction) { using (clientTransaction.EnterDiscardingScope()) { ClassWithAllDataTypes objectWithAllDataTypes = DomainObjectIDs.ObjectWithAllDataTypes1.GetObject <ClassWithAllDataTypes> (); return(objectWithAllDataTypes.Int32Property); } }
public void CommitRoot() { var newObject = ClassWithAllDataTypes.NewObject(); newObject.DateTimeProperty = new DateTime(2012, 12, 12); newObject.DateProperty = new DateTime(2012, 12, 12); Assert.That(newObject.State, Is.EqualTo(StateType.New)); var changedObject = DomainObjectIDs.ClassWithAllDataTypes1.GetObject <ClassWithAllDataTypes> (); ++changedObject.Int32Property; Assert.That(changedObject.State, Is.EqualTo(StateType.Changed)); var unchangedObject = DomainObjectIDs.ClassWithAllDataTypes2.GetObject <ClassWithAllDataTypes> (); Assert.That(unchangedObject.State, Is.EqualTo(StateType.Unchanged)); newObject.RegisterForCommit(); changedObject.RegisterForCommit(); unchangedObject.RegisterForCommit(); Assert.That(newObject.State, Is.EqualTo(StateType.New)); CheckNotMarkedAsChanged(newObject); Assert.That(changedObject.State, Is.EqualTo(StateType.Changed)); CheckMarkedAsChanged(changedObject); Assert.That(unchangedObject.State, Is.EqualTo(StateType.Changed)); CheckMarkedAsChanged(unchangedObject); var objectEventReceiverMock = MockRepository.GenerateMock <DomainObjectMockEventReceiver> (newObject); var transactionEventReceiverMock = MockRepository.GenerateMock <ClientTransactionMockEventReceiver> (TestableClientTransaction); var listenerMock = ClientTransactionTestHelperWithMocks.CreateAndAddListenerMock(TestableClientTransaction); SetDatabaseModifyable(); CommitTransactionAndCheckTimestamps(newObject, changedObject, unchangedObject); listenerMock.AssertWasCalled( mock => mock.TransactionCommitting( Arg.Is(TestableClientTransaction), Arg <ReadOnlyCollection <DomainObject> > .List.Equivalent(new[] { newObject, changedObject, unchangedObject }), Arg <ICommittingEventRegistrar> .Is.Anything)); listenerMock.AssertWasCalled( mock => mock.TransactionCommitValidate( Arg.Is(TestableClientTransaction), Arg <ReadOnlyCollection <PersistableData> > .Matches( x => x.Select(d => d.DomainObject).SetEquals(new[] { newObject, changedObject, unchangedObject })))); objectEventReceiverMock.AssertWasCalled(mock => mock.Committing()); objectEventReceiverMock.AssertWasCalled(mock => mock.Committed()); transactionEventReceiverMock.AssertWasCalled(mock => mock.Committing(newObject, changedObject, unchangedObject)); transactionEventReceiverMock.AssertWasCalled(mock => mock.Committed(newObject, changedObject, unchangedObject)); Assert.That(newObject.State, Is.EqualTo(StateType.Unchanged)); CheckNotMarkedAsChanged(newObject); Assert.That(changedObject.State, Is.EqualTo(StateType.Unchanged)); CheckNotMarkedAsChanged(changedObject); Assert.That(unchangedObject.State, Is.EqualTo(StateType.Unchanged)); CheckNotMarkedAsChanged(unchangedObject); }
public void TryGetObject_Invalid() { var domainObject = ClassWithAllDataTypes.NewObject(); domainObject.Delete(); Assert.That(domainObject.State, Is.EqualTo(StateType.Invalid)); Assert.That(LifetimeService.TryGetObject(TestableClientTransaction, domainObject.ID), Is.SameAs(domainObject)); }
public void SetNullIntoNonNullableValueType() { ClassWithAllDataTypes classWithAllDataTypes = ClassWithAllDataTypes.NewObject(); Assert.That( () => SetPropertyValue(classWithAllDataTypes.InternalDataContainer, typeof(ClassWithAllDataTypes), "BooleanProperty", null), Throws.InvalidOperationException.With.Message.EqualTo( "Property 'Remotion.Data.DomainObjects.UnitTests.TestDomain.ClassWithAllDataTypes.BooleanProperty' does not allow null values.")); }
public void LoadingOfSimpleObject() { ClassWithAllDataTypes classWithAllDataTypes = DomainObjectIDs.ClassWithAllDataTypes1.GetObject <ClassWithAllDataTypes> (); Assert.That(classWithAllDataTypes.ID.Value, Is.EqualTo(DomainObjectIDs.ClassWithAllDataTypes1.Value), "ID.Value"); Assert.That(classWithAllDataTypes.ID.ClassID, Is.EqualTo(DomainObjectIDs.ClassWithAllDataTypes1.ClassID), "ID.ClassID"); Assert.That(classWithAllDataTypes.ID.StorageProviderDefinition, Is.SameAs(DomainObjectIDs.ClassWithAllDataTypes1.StorageProviderDefinition), "ID.StorageProviderDefinition"); Assert.That(classWithAllDataTypes.BooleanProperty, Is.EqualTo(false), "BooleanProperty"); Assert.That(classWithAllDataTypes.ByteProperty, Is.EqualTo(85), "ByteProperty"); Assert.That(classWithAllDataTypes.DateProperty, Is.EqualTo(new DateTime(2005, 1, 1)), "DateProperty"); Assert.That(classWithAllDataTypes.DateTimeProperty, Is.EqualTo(new DateTime(2005, 1, 1, 17, 0, 0)), "DateTimeProperty"); Assert.That(classWithAllDataTypes.DecimalProperty, Is.EqualTo(123456.789m), "DecimalProperty"); Assert.That(classWithAllDataTypes.DoubleProperty, Is.EqualTo(987654.321d), "DoubleProperty"); Assert.That(classWithAllDataTypes.EnumProperty, Is.EqualTo(ClassWithAllDataTypes.EnumType.Value1), "EnumProperty"); Assert.That(classWithAllDataTypes.ExtensibleEnumProperty, Is.EqualTo(Color.Values.Red()), "ExtensibleEnumProperty"); Assert.That(classWithAllDataTypes.FlagsProperty, Is.EqualTo(ClassWithAllDataTypes.FlagsType.Flag2), "FlagsProperty"); Assert.That(classWithAllDataTypes.GuidProperty, Is.EqualTo(new Guid("{236C2DCE-43BD-45ad-BDE6-15F8C05C4B29}")), "GuidProperty"); Assert.That(classWithAllDataTypes.Int16Property, Is.EqualTo(32767), "Int16Property"); Assert.That(classWithAllDataTypes.Int32Property, Is.EqualTo(2147483647), "Int32Property"); Assert.That(classWithAllDataTypes.Int64Property, Is.EqualTo(9223372036854775807L), "Int64Property"); Assert.That(classWithAllDataTypes.SingleProperty, Is.EqualTo(6789.321f), "SingleProperty"); Assert.That(classWithAllDataTypes.StringProperty, Is.EqualTo("abcdeföäü"), "StringProperty"); Assert.That(classWithAllDataTypes.StringPropertyWithoutMaxLength, Is.EqualTo("12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"), "StringPropertyWithoutMaxLength"); ResourceManager.IsEqualToImage1(classWithAllDataTypes.BinaryProperty, "BinaryProperty"); Assert.That(classWithAllDataTypes.NaBooleanProperty, Is.EqualTo(true), "NaBooleanProperty"); Assert.That(classWithAllDataTypes.NaByteProperty, Is.EqualTo((byte)78), "NaByteProperty"); Assert.That(classWithAllDataTypes.NaDateProperty, Is.EqualTo(new DateTime(2005, 2, 1)), "NaDateProperty"); Assert.That(classWithAllDataTypes.NaDateTimeProperty, Is.EqualTo(new DateTime(2005, 2, 1, 5, 0, 0)), "NaDateTimeProperty"); Assert.That(classWithAllDataTypes.NaDecimalProperty, Is.EqualTo(765.098m), "NaDecimalProperty"); Assert.That(classWithAllDataTypes.NaDoubleProperty, Is.EqualTo(654321.789d), "NaDoubleProperty"); Assert.That(classWithAllDataTypes.NaEnumProperty, Is.EqualTo(ClassWithAllDataTypes.EnumType.Value2), "NaEnumProperty"); Assert.That(classWithAllDataTypes.NaFlagsProperty, Is.EqualTo(ClassWithAllDataTypes.FlagsType.Flag1 | ClassWithAllDataTypes.FlagsType.Flag2), "NaFlagsProperty"); Assert.That(classWithAllDataTypes.NaGuidProperty, Is.EqualTo(new Guid("{19B2DFBE-B7BB-448e-8002-F4DBF6032AE8}")), "NaGuidProperty"); Assert.That(classWithAllDataTypes.NaInt16Property, Is.EqualTo((short)12000), "NaInt16Property"); Assert.That(classWithAllDataTypes.NaInt32Property, Is.EqualTo(-2147483647), "NaInt32Property"); Assert.That(classWithAllDataTypes.NaInt64Property, Is.EqualTo(3147483647L), "NaInt64Property"); Assert.That(classWithAllDataTypes.NaSingleProperty, Is.EqualTo(12.456F), "NaSingleProperty"); Assert.That(classWithAllDataTypes.NaBooleanWithNullValueProperty, Is.Null, "NaBooleanWithNullValueProperty"); Assert.That(classWithAllDataTypes.NaByteWithNullValueProperty, Is.Null, "NaByteWithNullValueProperty"); Assert.That(classWithAllDataTypes.NaDecimalWithNullValueProperty, Is.Null, "NaDecimalWithNullValueProperty"); Assert.That(classWithAllDataTypes.NaDateWithNullValueProperty, Is.Null, "NaDateWithNullValueProperty"); Assert.That(classWithAllDataTypes.NaDateTimeWithNullValueProperty, Is.Null, "NaDateTimeWithNullValueProperty"); Assert.That(classWithAllDataTypes.NaDoubleWithNullValueProperty, Is.Null, "NaDoubleWithNullValueProperty"); Assert.That(classWithAllDataTypes.NaEnumWithNullValueProperty, Is.Null, "NaEnumWithNullValueProperty"); Assert.That(classWithAllDataTypes.NaFlagsWithNullValueProperty, Is.Null, "NaFlagsWithNullValueProperty"); Assert.That(classWithAllDataTypes.NaGuidWithNullValueProperty, Is.Null, "NaGuidWithNullValueProperty"); Assert.That(classWithAllDataTypes.NaInt16WithNullValueProperty, Is.Null, "NaInt16WithNullValueProperty"); Assert.That(classWithAllDataTypes.NaInt32WithNullValueProperty, Is.Null, "NaInt32WithNullValueProperty"); Assert.That(classWithAllDataTypes.NaInt64WithNullValueProperty, Is.Null, "NaInt64WithNullValueProperty"); Assert.That(classWithAllDataTypes.NaSingleWithNullValueProperty, Is.Null, "NaSingleWithNullValueProperty"); Assert.That(classWithAllDataTypes.StringWithNullValueProperty, Is.Null, "StringWithNullValueProperty"); Assert.That(classWithAllDataTypes.ExtensibleEnumWithNullValueProperty, Is.Null, "ExtensibleEnumWithNullValueProperty"); Assert.That(classWithAllDataTypes.NullableBinaryProperty, Is.Null, "NullableBinaryProperty"); }
public void CreateValueClone_OriginalValueNotCloned() { _classWithAllDataTypes.Int32Property = -2; ClassWithAllDataTypes clone = _cloner.CreateValueClone(_classWithAllDataTypes); Assert.That(clone.Int32Property, Is.EqualTo(_classWithAllDataTypes.Int32Property)); Assert.That(clone.Properties[typeof(ClassWithAllDataTypes), "Int32Property"].GetOriginalValue <int> (), Is.Not.EqualTo(_classWithAllDataTypes.Properties[typeof(ClassWithAllDataTypes), "Int32Property"].GetOriginalValue <int> ())); Assert.That(clone.Properties[typeof(ClassWithAllDataTypes), "Int32Property"].GetOriginalValue <int> (), Is.EqualTo(0)); }
public void NeedsLoadModeDataContainerOnly_Serialization_ISerializable_True() { var classWithAllDataTypes = _transaction.ExecuteInScope(() => ClassWithAllDataTypes.NewObject()); Assert.That(classWithAllDataTypes.NeedsLoadModeDataContainerOnly, Is.True); var deserializedClassWithAllDataTypes = Serializer.SerializeAndDeserialize(classWithAllDataTypes); Assert.That(deserializedClassWithAllDataTypes.NeedsLoadModeDataContainerOnly, Is.True); }
public void OnLoaded() { var id = new ObjectID("ClassWithAllDataTypes", new Guid("{3F647D79-0CAF-4a53-BAA7-A56831F8CE2D}")); ClassWithAllDataTypes classWithAllDataTypes = id.GetObject <ClassWithAllDataTypes> (); Assert.That(classWithAllDataTypes.OnLoadedCalled, Is.True); Assert.That(classWithAllDataTypes.OnLoadedCallCount, Is.EqualTo(1)); Assert.That(classWithAllDataTypes.OnLoadedLoadMode, Is.EqualTo(LoadMode.WholeDomainObjectInitialized)); }
public void ConstructionOfSimpleObjectWorks() { Order order = Order.NewObject(); Assert.That(WasCreatedByFactory(order), Is.True); ClassWithAllDataTypes classWithAllDataTypes = ClassWithAllDataTypes.NewObject(); Assert.That(classWithAllDataTypes, Is.Not.Null); Assert.That(WasCreatedByFactory(classWithAllDataTypes), Is.True); }
private void SetInt32Property(int value, ClientTransaction clientTransaction) { using (clientTransaction.EnterDiscardingScope()) { ClassWithAllDataTypes objectWithAllDataTypes = DomainObjectIDs.ObjectWithAllDataTypes1.GetObject <ClassWithAllDataTypes> (); objectWithAllDataTypes.Int32Property = value; clientTransaction.Commit(); } }
public void NewObject_NoOp() { var domainObject = ClassWithAllDataTypes.NewObject(); Assert.That(domainObject.State, Is.EqualTo(StateType.New)); domainObject.RegisterForCommit(); Assert.That(domainObject.State, Is.EqualTo(StateType.New)); CheckNotMarkedAsChanged(domainObject); }
public void Count() { Assert.That(_order.Properties.GetPropertyCount(), Is.EqualTo(6)); OrderItem orderItem = _transaction.ExecuteInScope(() => OrderItem.NewObject()); Assert.That(orderItem.Properties.GetPropertyCount(), Is.EqualTo(3)); ClassWithAllDataTypes cwadt = _transaction.ExecuteInScope(() => ClassWithAllDataTypes.NewObject()); Assert.That(cwadt.Properties.GetPropertyCount(), Is.EqualTo(48)); }
private ClassWithAllDataTypes CreateClassWithAllDataTypes() { ClassWithAllDataTypes newObject = ClassWithAllDataTypes.NewObject(); newObject.DateProperty = DateTime.Now; newObject.DateTimeProperty = DateTime.Now; newObject.StringProperty = "value"; newObject.StringPropertyWithoutMaxLength = "value"; newObject.TransactionOnlyStringProperty = "value"; newObject.BinaryProperty = new byte[10]; newObject.TransactionOnlyBinaryProperty = new byte[10]; return newObject; }
public void CommitRootNewSubNotLoaded() { ClassWithAllDataTypes obj = GetNewUnchanged(); Assert.That(obj.State, Is.EqualTo(StateType.New)); using (TestableClientTransaction.CreateSubTransaction().EnterDiscardingScope()) { Assert.That(obj.State, Is.EqualTo(StateType.NotLoadedYet)); ClientTransactionScope.CurrentTransaction.Commit(); } Assert.That(obj.State, Is.EqualTo(StateType.New)); }
public void ParentTransactionStillReadOnlyAfterCommit() { using (_subTransaction.EnterDiscardingScope()) { Assert.That(TestableClientTransaction.IsWriteable, Is.False); ClassWithAllDataTypes classWithAllDataTypes = ClassWithAllDataTypes.NewObject(); Assert.That(classWithAllDataTypes.Int32Property, Is.Not.EqualTo(7)); classWithAllDataTypes.Int32Property = 7; _subTransaction.Commit(); Assert.That(TestableClientTransaction.IsWriteable, Is.False); } }
public void OnLoadedInSubTransaction() { var id = new ObjectID("ClassWithAllDataTypes", new Guid("{3F647D79-0CAF-4a53-BAA7-A56831F8CE2D}")); using (TestableClientTransaction.CreateSubTransaction().EnterDiscardingScope()) { ClassWithAllDataTypes classWithAllDataTypes = id.GetObject <ClassWithAllDataTypes> (); Assert.That(classWithAllDataTypes.OnLoadedCalled, Is.True); Assert.That(classWithAllDataTypes.OnLoadedCallCount, Is.EqualTo(2)); Assert.That(classWithAllDataTypes.OnLoadedLoadMode, Is.EqualTo(LoadMode.DataContainerLoadedOnly)); } }