コード例 #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 Add_and_complete_multiple_event_types_moves_to_completed()
        {
            EventWindow window       = new EventWindow(DateTime.MinValue);
            int         eventIdA     = 1;
            int         eventIdB     = 2;
            int         eventIdC     = 3;
            Guid        instanceIdA1 = new Guid(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
            Guid        instanceIdB1 = new Guid(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2);
            Guid        instanceIdB2 = new Guid(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3);
            Guid        instanceIdC1 = new Guid(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4);
            Guid        instanceIdC2 = new Guid(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5);
            Guid        instanceIdC3 = new Guid(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6);

            window.Add(eventIdA, instanceIdA1);
            window.Add(eventIdB, instanceIdB1);
            window.Add(eventIdB, instanceIdB2);
            window.Add(eventIdC, instanceIdC1);
            window.Add(eventIdC, instanceIdC2);
            window.Add(eventIdC, instanceIdC3);

            window.Complete(eventIdA, instanceIdA1);
            window.Complete(eventIdB, instanceIdB2);
            window.Complete(eventIdC, instanceIdC2);
            window.Complete(eventIdC, instanceIdC3);

            Assert.Equal(0, window.GetPendingCount(eventIdA));
            Assert.Equal(1, window.GetPendingCount(eventIdB));
            Assert.Equal(1, window.GetPendingCount(eventIdC));
            Assert.Equal(1, window.GetCompletedCount(eventIdA));
            Assert.Equal(1, window.GetCompletedCount(eventIdB));
            Assert.Equal(2, window.GetCompletedCount(eventIdC));
        }
コード例 #3
0
        public void Complete_no_existing_event_does_nothing()
        {
            EventWindow window     = new EventWindow(DateTime.MinValue);
            int         eventId    = 1;
            Guid        instanceId = new Guid(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);

            window.Complete(eventId, instanceId);

            Assert.Equal(0, window.GetCompletedCount(eventId));
        }
コード例 #4
0
        public void Complete_pending_event_with_same_type_and_ID_moves_to_completed()
        {
            EventWindow window     = new EventWindow(DateTime.MinValue);
            int         eventId    = 1;
            Guid        instanceId = new Guid(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);

            window.Add(eventId, instanceId);
            window.Complete(eventId, instanceId);

            Assert.Equal(0, window.GetPendingCount(eventId));
            Assert.Equal(1, window.GetCompletedCount(eventId));
        }
コード例 #5
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));
        }
コード例 #6
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));
        }
コード例 #7
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));
        }
コード例 #8
0
        public void Add_and_complete_multiple_event_types_moves_to_completed()
        {
            EventWindow window = new EventWindow(DateTime.MinValue);
            int eventIdA = 1;
            int eventIdB = 2;
            int eventIdC = 3;
            Guid instanceIdA1 = new Guid(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);
            Guid instanceIdB1 = new Guid(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2);
            Guid instanceIdB2 = new Guid(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3);
            Guid instanceIdC1 = new Guid(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4);
            Guid instanceIdC2 = new Guid(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5);
            Guid instanceIdC3 = new Guid(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6);

            window.Add(eventIdA, instanceIdA1);
            window.Add(eventIdB, instanceIdB1);
            window.Add(eventIdB, instanceIdB2);
            window.Add(eventIdC, instanceIdC1);
            window.Add(eventIdC, instanceIdC2);
            window.Add(eventIdC, instanceIdC3);

            window.Complete(eventIdA, instanceIdA1);
            window.Complete(eventIdB, instanceIdB2);
            window.Complete(eventIdC, instanceIdC2);
            window.Complete(eventIdC, instanceIdC3);

            Assert.Equal(0, window.GetPendingCount(eventIdA));
            Assert.Equal(1, window.GetPendingCount(eventIdB));
            Assert.Equal(1, window.GetPendingCount(eventIdC));
            Assert.Equal(1, window.GetCompletedCount(eventIdA));
            Assert.Equal(1, window.GetCompletedCount(eventIdB));
            Assert.Equal(2, window.GetCompletedCount(eventIdC));
        }
コード例 #9
0
        public void Complete_pending_event_with_same_type_and_ID_moves_to_completed()
        {
            EventWindow window = new EventWindow(DateTime.MinValue);
            int eventId = 1;
            Guid instanceId = new Guid(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);

            window.Add(eventId, instanceId);
            window.Complete(eventId, instanceId);

            Assert.Equal(0, window.GetPendingCount(eventId));
            Assert.Equal(1, window.GetCompletedCount(eventId));
        }
コード例 #10
0
        public void Complete_no_existing_event_does_nothing()
        {
            EventWindow window = new EventWindow(DateTime.MinValue);
            int eventId = 1;
            Guid instanceId = new Guid(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1);

            window.Complete(eventId, instanceId);

            Assert.Equal(0, window.GetCompletedCount(eventId));
        }