Exemple #1
0
        public void CanAddUserIdentifyEvent()
        {
            // given
            var beacon  = new Beacon(logger, new BeaconCache(), new TestConfiguration(), "127.0.0.1", threadIdProvider, timingProvider);
            var userTag = "myTestUser";

            // when
            beacon.IdentifyUser(userTag);
            var target = beacon.EventDataList;

            // then
            Assert.That(target, Is.EquivalentTo(new[] { $"et=60&na={userTag}&it=0&pa=0&s0=1&t0=0" }));
        }
Exemple #2
0
        public void CannotAddSentBytesWithInvalidValueSmallerZeroToWebRequestTracer()
        {
            //given
            var target     = new Beacon(logger, new BeaconCache(), new TestConfiguration(), "127.0.0.1", threadIdProvider, timingProvider);
            var action     = new Action(logger, target, "TestRootAction", new SynchronizedQueue <IAction>());
            var testURL    = "127.0.0.1";
            var webRequest = new WebRequestTracerStringURL(target, action, testURL);

            //when
            webRequest.Start().SetBytesSent(-1).Stop(); //stop will add the web request to the beacon

            //then
            Assert.That(target.EventDataList, Is.EquivalentTo(new[] { $"et=30&na={testURL}&it=0&pa=1&s0=2&t0=0&s1=3&t1=0" }));
        }
        public void CanAddReceivedBytesValueZeroToWebRequestTracer()
        {
            //given
            var target        = new Beacon(Substitute.For <ILogger>(), new BeaconCache(), new TestConfiguration(), "127.0.0.1", threadIdProvider, timingProvider);
            var action        = new Action(target, "TestRootAction", new SynchronizedQueue <IAction>());
            var testURL       = "127.0.0.1";
            var webRequest    = new WebRequestTracerStringURL(target, action, testURL);
            var bytesReceived = 0;

            //when
            webRequest.Start().SetBytesReceived(bytesReceived).Stop(); //stop will add the web request to the beacon

            //then
            Assert.That(target.EventDataList, Is.EquivalentTo(new[] { $"et=30&na={testURL}&it=0&pa=1&s0=2&t0=0&s1=3&t1=0&br={bytesReceived}" }));
        }
Exemple #4
0
        public void CannotAddRootActionIfCaptureIsOff()
        {
            // given
            var configuration = new TestConfiguration();

            configuration.DisableCapture();

            var target = new Beacon(logger, new BeaconCache(),
                                    configuration, "127.0.0.1", threadIdProvider, timingProvider);

            // when adding the root action
            const string RootActionName = "TestRootAction";

            target.AddAction(new RootAction(logger, target, RootActionName, new SynchronizedQueue <IAction>()));

            // then
            Assert.That(target.ActionDataList, Is.Empty);
        }
Exemple #5
0
        public void ClearDataClearsActionAndEventData()
        {
            // given
            var target = new Beacon(logger, new BeaconCache(), new TestConfiguration(), "127.0.0.1", threadIdProvider, timingProvider);
            var action = new Action(logger, target, "TestAction", new SynchronizedQueue <IAction>());

            action.ReportEvent("TestEvent").ReportValue("TheAnswerToLifeTheUniverseAndEverything", 42);
            target.AddAction(action);

            // then check data both lists are not empty
            Assert.That(target.ActionDataList, Is.Not.Empty);
            Assert.That(target.EventDataList, Is.Not.Empty);

            // and when clearing the data
            target.ClearData();

            // then check data both lists are emtpy
            Assert.That(target.ActionDataList, Is.Empty);
            Assert.That(target.EventDataList, Is.Empty);
        }
Exemple #6
0
        public void CanAddRootActionIfCaptureIsOn()
        {
            // given
            var configuration = new TestConfiguration();

            configuration.EnableCapture();

            var target = new Beacon(logger, new BeaconCache(),
                                    configuration, "127.0.0.1", threadIdProvider, timingProvider);
            const string RootActionName = "TestRootAction";


            // when adding the root action
            var action = new RootAction(logger, target, RootActionName, new SynchronizedQueue <IAction>()); // the action is added to the beacon in the constructor

            action.LeaveAction();

            // then
            Assert.That(target.ActionDataList, Is.EquivalentTo(new[] { $"et=1&na={RootActionName}&it=0&ca=1&pa=0&s0=1&t0=0&s1=2&t1=0" }));
        }