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);
        }
Exemplo n.º 3
0
        public void AdvancedDataCoreRevertTest( )
        {
            TAdc dto = DtoCreator.New <TAdc>( );

            dto.Prop = 42;
            dto.RevertChanges( );

            Assert.IsFalse(dto.HasChanges);
            Assert.IsNull(dto.Prop);
        }
Exemplo n.º 4
0
        public void AdvancedDataCoreAcceptTest( )
        {
            TAdc dto = DtoCreator.New <TAdc>( );

            dto.Prop = 42;
            dto.AcceptChanges( );

            Assert.AreEqual(42, dto.Prop);
            Assert.IsFalse(dto.HasChanges);
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
        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);
        }
Exemplo n.º 9
0
        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);
        }
Exemplo n.º 10
0
        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);
        }
Exemplo n.º 11
0
        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);
        }