コード例 #1
0
        public void Copy_construct_deep_copies_instance()
        {
            DateTime    startTime = new DateTime(2000, 1, 2, 3, 4, 5, 6);
            EventWindow window    = new EventWindow(startTime);

            Assert.Equal(startTime, window.StartTime);

            int  eventIdA    = 1;
            int  eventIdB    = 2;
            Guid instanceIdA = new Guid(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
            Guid instanceIdB = new Guid(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2);

            window.Add(eventIdA, instanceIdA);
            window.Complete(eventIdA, instanceIdA);
            window.Add(eventIdB, instanceIdB);

            DateTime    newStartTime = new DateTime(2001, 2, 3, 4, 5, 6, 7);
            EventWindow copiedWindow = new EventWindow(window, newStartTime);

            Assert.Equal(newStartTime, copiedWindow.StartTime);
            Assert.Equal(1, copiedWindow.GetCompletedCount(eventIdA));

            copiedWindow.Complete(eventIdB, instanceIdB);

            Assert.Equal(1, window.GetPendingCount(eventIdB));
            Assert.Equal(0, window.GetCompletedCount(eventIdB));

            window.ClearCompleted();

            Assert.Equal(1, copiedWindow.GetCompletedCount(eventIdA));
        }
コード例 #2
0
        public void Clear_completed_resets_completed_counts()
        {
            EventWindow window      = new EventWindow(DateTime.MinValue);
            int         eventIdA    = 1;
            int         eventIdB    = 2;
            Guid        instanceIdA = new Guid(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
            Guid        instanceIdB = new Guid(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2);

            window.Add(eventIdA, instanceIdA);
            window.Complete(eventIdA, instanceIdA);
            window.Add(eventIdB, instanceIdB);

            window.ClearCompleted();

            Assert.Equal(0, window.GetPendingCount(eventIdA));
            Assert.Equal(1, window.GetPendingCount(eventIdB));
            Assert.Equal(0, window.GetCompletedCount(eventIdA));
        }
コード例 #3
0
        public void Copy_construct_deep_copies_instance()
        {
            DateTime startTime = new DateTime(2000, 1, 2, 3, 4, 5, 6);
            EventWindow window = new EventWindow(startTime);

            Assert.Equal(startTime, window.StartTime);

            int eventIdA = 1;
            int eventIdB = 2;
            Guid instanceIdA = new Guid(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
            Guid instanceIdB = new Guid(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2);

            window.Add(eventIdA, instanceIdA);
            window.Complete(eventIdA, instanceIdA);
            window.Add(eventIdB, instanceIdB);

            DateTime newStartTime = new DateTime(2001, 2, 3, 4, 5, 6, 7);
            EventWindow copiedWindow = new EventWindow(window, newStartTime);

            Assert.Equal(newStartTime, copiedWindow.StartTime);
            Assert.Equal(1, copiedWindow.GetCompletedCount(eventIdA));
            
            copiedWindow.Complete(eventIdB, instanceIdB);

            Assert.Equal(1, window.GetPendingCount(eventIdB));
            Assert.Equal(0, window.GetCompletedCount(eventIdB));

            window.ClearCompleted();

            Assert.Equal(1, copiedWindow.GetCompletedCount(eventIdA));
        }
コード例 #4
0
        public void Clear_completed_resets_completed_counts()
        {
            EventWindow window = new EventWindow(DateTime.MinValue);
            int eventIdA = 1;
            int eventIdB = 2;
            Guid instanceIdA = new Guid(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
            Guid instanceIdB = new Guid(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2);

            window.Add(eventIdA, instanceIdA);
            window.Complete(eventIdA, instanceIdA);
            window.Add(eventIdB, instanceIdB);

            window.ClearCompleted();

            Assert.Equal(0, window.GetPendingCount(eventIdA));
            Assert.Equal(1, window.GetPendingCount(eventIdB));
            Assert.Equal(0, window.GetCompletedCount(eventIdA));
        }