public void AdvancedDataCore_AcceptChanges( ) { Queue <Change> changes = new Queue <Change>( ); ITestInterfaceAdcNpc dto = DtoCreator.New <ITestInterfaceAdcNpc>( ); dto.PropertyChanged += (sender, args) => { changes.Enqueue( GetChange(dto, args.PropertyName)); }; dto.Prop = 42; dto.Prop = 23; dto.AcceptChanges( ); Assert.AreEqual(4, changes.Count); Change change = changes.Dequeue( ); Assert.AreEqual(nameof(ITestInterfaceAdcNpc.HasChanges), change.PropertyName); Assert.AreEqual(true, change.Value); change = changes.Dequeue( ); Assert.AreEqual(nameof(ITestInterfaceAdcNpc.Prop), change.PropertyName); Assert.AreEqual(42, change.Value); change = changes.Dequeue( ); Assert.AreEqual(nameof(ITestInterfaceAdcNpc.Prop), change.PropertyName); Assert.AreEqual(23, change.Value); change = changes.Dequeue( ); Assert.AreEqual(nameof(ITestInterfaceAdcNpc.HasChanges), change.PropertyName); Assert.AreEqual(false, change.Value); }
public void SimpleDataCore( ) { Queue <Change> changes = new Queue <Change>( ); ITestInterfaceSdcNpc dto = DtoCreator.New <ITestInterfaceSdcNpc>( ); dto.PropertyChanged += (sender, args) => { changes.Enqueue( GetChange(dto, args.PropertyName)); }; dto.Prop = 42; dto.Prop = 23; dto.MarkNotDirty( ); Assert.AreEqual(4, changes.Count); Change change = changes.Dequeue( ); Assert.AreEqual(nameof(ITestInterfaceSdcNpc.IsDirty), change.PropertyName); Assert.AreEqual(true, change.Value); change = changes.Dequeue( ); Assert.AreEqual(nameof(ITestInterfaceSdcNpc.Prop), change.PropertyName); Assert.AreEqual(42, change.Value); change = changes.Dequeue( ); Assert.AreEqual(nameof(ITestInterfaceSdcNpc.Prop), change.PropertyName); Assert.AreEqual(23, change.Value); change = changes.Dequeue( ); Assert.AreEqual(nameof(ITestInterfaceSdcNpc.IsDirty), change.PropertyName); Assert.AreEqual(false, change.Value); }
public void AdvancedDataCoreRevertTest( ) { TAdc dto = DtoCreator.New <TAdc>( ); dto.Prop = 42; dto.RevertChanges( ); Assert.IsFalse(dto.HasChanges); Assert.IsNull(dto.Prop); }
public void AdvancedDataCoreAcceptTest( ) { TAdc dto = DtoCreator.New <TAdc>( ); dto.Prop = 42; dto.AcceptChanges( ); Assert.AreEqual(42, dto.Prop); Assert.IsFalse(dto.HasChanges); }
public void SimpleDataCoreTest( ) { TSdc dto = DtoCreator.New <TSdc>( ); Assert.IsFalse(dto.IsDirty); Assert.IsNull(dto.Prop); dto.Prop = 42; Assert.AreEqual(42, dto.Prop); Assert.IsTrue(dto.IsDirty); }
public void AdvancedDataCoreTest( ) { TAdc dto = DtoCreator.New <TAdc>( ); Assert.IsFalse(dto.HasChanges); Assert.IsNull(dto.Prop); dto.Prop = 42; Assert.AreEqual(42, dto.Prop); Assert.IsTrue(dto.HasChanges); }
public void VersionedDataCoreTest( ) { TVdc dto = DtoCreator.New <TVdc>( ); Assert.IsNull(dto.Prop); Assert.IsFalse(dto.HasChanges); Assert.AreEqual(0, dto.CurrentVersion); dto.Prop = 42; Assert.AreEqual(42, dto.Prop); Assert.IsTrue(dto.HasChanges); Assert.AreEqual(1, dto.CurrentVersion); }
public void VersionedDataCore_ResetToSquashed( ) { Queue <Change> changes = new Queue <Change>( ); ITestInterfaceVdcNpc dto = DtoCreator.New <ITestInterfaceVdcNpc>( ); dto.PropertyChanged += (sender, args) => { changes.Enqueue( GetChange(dto, args.PropertyName)); }; dto.Prop = 42; dto.Prop = 23; dto.ResetToSquashed( ); Assert.AreEqual(8, changes.Count); Change change = changes.Dequeue( ); Assert.AreEqual(nameof(ITestInterfaceVdcNpc.CurrentVersion), change.PropertyName); Assert.AreEqual(1, change.Value); change = changes.Dequeue( ); Assert.AreEqual(nameof(ITestInterfaceVdcNpc.HasChanges), change.PropertyName); Assert.AreEqual(true, change.Value); change = changes.Dequeue( ); Assert.AreEqual(nameof(ITestInterfaceVdcNpc.Prop), change.PropertyName); Assert.AreEqual(42, change.Value); change = changes.Dequeue( ); Assert.AreEqual(nameof(ITestInterfaceVdcNpc.CurrentVersion), change.PropertyName); Assert.AreEqual(2, change.Value); change = changes.Dequeue( ); Assert.AreEqual(nameof(ITestInterfaceVdcNpc.Prop), change.PropertyName); Assert.AreEqual(23, change.Value); change = changes.Dequeue( ); Assert.AreEqual(nameof(ITestInterfaceVdcNpc.CurrentVersion), change.PropertyName); Assert.AreEqual(0, change.Value); change = changes.Dequeue( ); Assert.AreEqual(nameof(ITestInterfaceVdcNpc.HasChanges), change.PropertyName); Assert.AreEqual(false, change.Value); change = changes.Dequeue( ); Assert.AreEqual(nameof(ITestInterfaceVdcNpc.Prop), change.PropertyName); Assert.AreEqual(null, change.Value); }
public void AdvancedDataCoreRevertToAcceptedTest( ) { TAdc dto = DtoCreator.New <TAdc>( ); dto.Prop = 42; dto.AcceptChanges( ); dto.Prop = 23; Assert.AreEqual(23, dto.Prop); Assert.IsTrue(dto.HasChanges); dto.RevertChanges( ); Assert.AreEqual(42, dto.Prop); Assert.IsFalse(dto.HasChanges); }
public void VersionedDataCoreResetToVersionTest( ) { TVdc dto = DtoCreator.New <TVdc>( ); dto.Prop = 1; dto.Prop = 42; dto.Prop = 2; dto.Prop = 3; Assert.AreEqual(4, dto.CurrentVersion); dto.ResetToVersion(2); Assert.AreEqual(42, dto.Prop); Assert.IsTrue(dto.HasChanges); Assert.AreEqual(2, dto.CurrentVersion); }
public void VersionedDataCoreResetToSquashedTest( ) { TVdc dto = DtoCreator.New <TVdc>( ); dto.Prop = 1; dto.Prop = 42; dto.SquashChanges( ); dto.Prop = 2; dto.Prop = 3; dto.ResetToSquashed( ); Assert.AreEqual(42, dto.Prop); Assert.IsFalse(dto.HasChanges); Assert.AreEqual(2, dto.CurrentVersion); }