Example #1
0
 public void AddKeyboardEvent(MonitorEvent ev)
 {
     Debug.Assert(WorkTime != null);
     SetEventEnd(ev);
     if (GetEventBuilder(ev.Executable).KeyboardEventBuilder.AddEvent(ev, out var created))
     {
         WorkTime.AddKeyboardAction(created);
         SaveIfBufferSz();
         _allKeyboardBuilder.AddEvent(ev, out created);
     }
     else if (_allKeyboardBuilder.AddEvent(ev, out created))
     {
         SaveIfBufferSz();
     }
 }
        public void g()
        {
            MouseKeyboardEvent empty = null;
            var now = DateTime.Now;

            var e1 = new MonitorEvent()
            {
                EventStart  = now,
                TotalTimeMs = 1200
            };

            _service.AddEvent(e1, out empty).Should().BeFalse();
            empty.Should().BeNull();

            var e2 = new MonitorEvent()
            {
                EventStart  = now.AddMilliseconds(2000),
                TotalTimeMs = 2000
            };

            _service.AddEvent(e2, out empty).Should().BeFalse();
            empty.Should().BeNull();


            var created = _service.Flush();

            created.Should().NotBeNull();

            created.EventsTimeline.Should().BeEquivalentTo(new[] { 0, 1200, 2000, 4000 });
            created.TotalTime.Should().Be(1200 + 2000);
            created.End.Should().Be(e1.EventStart.AddMilliseconds(4000));
        }