Example #1
0
        public void SequencialChanges(int finalInt, int iterations)
        {
            IChangeLogPlayer <SimpleItem, int> logPlayer = new ChangeLogPlayer <SimpleItem, int>();
            ICollection <ChangeLog <int> >     changes   = new LinkedList <ChangeLog <int> >();

            changes.Add(new ChangeLog <int>
            {
                Property           = "IntegerStandard",
                ChangedUtc         = DateTime.UtcNow.AddSeconds(5),
                Value              = finalInt.ToString(),
                FullTypeName       = "JSCloud.LogPlayer.Tests.SimpleItem",
                PropertySystemType = "System.Int32"
            });

            for (var i = 0; i < iterations; i++)
            {
                changes.Add(new ChangeLog <int>
                {
                    Property           = "IntegerStandard",
                    ChangedUtc         = DateTime.UtcNow,
                    Value              = i.ToString(),
                    ObjectId           = i,
                    FullTypeName       = "JSCloud.LogPlayer.Tests.SimpleItem",
                    PropertySystemType = "System.Int32"
                });
            }

            var timer = new Stopwatch();

            timer.Start();
            var SimpleItem = logPlayer.RebuildFromLogs(changes);

            timer.Stop();
            Assert.AreEqual(finalInt, SimpleItem.IntegerStandard);
            Debug.WriteLine($"{timer.ElapsedMilliseconds}ms elapsed");

            Assert.IsTrue(timer.ElapsedMilliseconds <= iterations);
        }
Example #2
0
        public void SimpleBuild(int integerStandard, string stringStandard, long longStandard, int?integerNullable,
                                long?longNullable)
        {
            IChangeLogPlayer <SimpleItem, int> logPlayer = new ChangeLogPlayer <SimpleItem, int>();
            var timer = new Stopwatch();

            timer.Start();
            for (var i = 0; i < 1000; i++)
            {
                IList <ChangeLog <int> > changes = new List <ChangeLog <int> >();
                changes.Add(new ChangeLog <int>
                {
                    ChangeLogId        = null,
                    ChangedBy          = null,
                    Property           = "IntegerStandard",
                    ChangedUtc         = DateTime.UtcNow,
                    Value              = integerStandard.ToString(),
                    FullTypeName       = "JSCloud.LogPlayer.Tests.SimpleItem",
                    PropertySystemType = "System.Int32"
                });
                changes.Add(new ChangeLog <int>
                {
                    ChangeLogId        = null,
                    ChangedBy          = null,
                    Property           = "StringStandard",
                    ChangedUtc         = DateTime.UtcNow,
                    Value              = stringStandard,
                    FullTypeName       = "JSCloud.LogPlayer.Tests.SimpleItem",
                    PropertySystemType = "System.String"
                });
                changes.Add(new ChangeLog <int>
                {
                    ChangeLogId        = null,
                    ChangedBy          = null,
                    Property           = "LongStandard",
                    ChangedUtc         = DateTime.UtcNow,
                    Value              = longStandard.ToString(),
                    FullTypeName       = "JSCloud.LogPlayer.Tests.SimpleItem",
                    PropertySystemType = "System.Int64"
                });
                changes.Add(new ChangeLog <int>
                {
                    ChangeLogId        = null,
                    ChangedBy          = null,
                    Property           = "IntegerNullable",
                    ChangedUtc         = DateTime.UtcNow,
                    Value              = integerNullable?.ToString(),
                    FullTypeName       = "JSCloud.LogPlayer.Tests.SimpleItem",
                    PropertySystemType = "System.Int32"
                });
                changes.Add(new ChangeLog <int>
                {
                    ChangeLogId        = null,
                    ChangedBy          = null,
                    Property           = "LongNullable",
                    ChangedUtc         = DateTime.UtcNow,
                    Value              = longNullable?.ToString(),
                    FullTypeName       = "JSCloud.LogPlayer.Tests.SimpleItem",
                    PropertySystemType = "System.Int32"
                });

                var SimpleItem = logPlayer.RebuildFromLogs(changes);
                Assert.AreEqual(integerStandard, SimpleItem.IntegerStandard);
            }

            timer.Stop();
            Debug.WriteLine($"{timer.ElapsedMilliseconds}ms elapsed");

            Assert.IsTrue(timer.ElapsedMilliseconds < 1000);
        }