예제 #1
0
        public void ReportAction_AllInformation()
        {
            var sink = new PiwikSink(defaultOptions);

            Api.PiwikEventInfo calledEventInfo = null;
            mockApi
            .Setup(api => api.ReportEventAsync(It.IsAny <Api.PiwikEventInfo>()))
            .Returns(Task.FromResult(true))
            .Callback <Api.PiwikEventInfo>(ei => calledEventInfo = ei);

            sink.Location.CurrentUrl  = new Uri(sink.BaseAppUrl, "some/url");
            sink.Location.ReferrerUrl = new Uri(sink.BaseAppUrl, "another/url");

            var actionInfo = new Core.ActionInfo()
            {
                Name     = "Test",
                Category = "Some category",
                Verb     = "Some verb"
            };

            telemetryProvider.Activity.ReportActionAsync(actionInfo);

            Assert.IsNotNull(calledEventInfo);
            Assert.AreEqual("Some category", calledEventInfo.Category);
            Assert.AreEqual("Some verb", calledEventInfo.Action);
            Assert.AreEqual("Test", calledEventInfo.Name);
            Assert.AreEqual(sink.Location.CurrentUrl.ToString(), calledEventInfo.Url);
            Assert.AreEqual(sink.Location.ReferrerUrl.ToString(), calledEventInfo.ReferrerUrl);
            Assert.AreSame(sink.Session, calledEventInfo.Session);
            Assert.AreSame(sink.EnvironmentInfo, calledEventInfo.EnvironmentInfo);
        }
예제 #2
0
        public void ReportAction_MinimalInformation()
        {
            var sink = new PiwikSink(defaultOptions);

            Api.PiwikEventInfo calledEventInfo = null;
            mockApi
            .Setup(api => api.ReportEventAsync(It.IsAny <Api.PiwikEventInfo>()))
            .Returns(Task.FromResult(true))
            .Callback <Api.PiwikEventInfo>(ei => calledEventInfo = ei);

            var actionInfo = new Core.ActionInfo()
            {
                Name = "Test"
            };

            telemetryProvider.Activity.ReportActionAsync(actionInfo);

            Assert.IsNotNull(calledEventInfo);
            Assert.AreEqual("Unknown", calledEventInfo.Category);
            Assert.AreEqual("Test", calledEventInfo.Action);
            Assert.AreEqual("Test", calledEventInfo.Name);
            Assert.AreEqual(sink.BaseAppUrl.ToString(), calledEventInfo.Url);
            Assert.IsNull(calledEventInfo.ReferrerUrl);
            Assert.AreSame(sink.Session, calledEventInfo.Session);
            Assert.AreSame(sink.EnvironmentInfo, calledEventInfo.EnvironmentInfo);
        }