Beispiel #1
0
        private void CheckSend(int trackMessagesCount, int engageMessagesCount)
        {
            // Track
            var trackSplits          = GetSplits(trackMessagesCount, BatchMessageWrapper.MaxBatchSize);
            var trackHttpPostEntries = HttpPostEntries.Where(x => x.Endpoint == TrackUrl).ToList();

            Assert.That(trackHttpPostEntries.Count, Is.EqualTo(trackSplits.Count));
            for (int i = 0; i < trackHttpPostEntries.Count; i++)
            {
                JArray msg = ParseBatchMessageData(trackHttpPostEntries[i].Data);
                Assert.That(msg.Count, Is.EqualTo(trackSplits[i]));
                foreach (JObject msgPart in msg.Cast <JObject>())
                {
                    AssertTrackJson(msgPart);
                }
            }

            // Engage
            var engageSplits          = GetSplits(engageMessagesCount, BatchMessageWrapper.MaxBatchSize);
            var engageHttpPostEntries = HttpPostEntries.Where(x => x.Endpoint == EngageUrl).ToList();

            Assert.That(engageHttpPostEntries.Count, Is.EqualTo(engageSplits.Count));
            for (int i = 0; i < engageHttpPostEntries.Count; i++)
            {
                JArray msg = ParseBatchMessageData(engageHttpPostEntries[i].Data);
                Assert.That(msg.Count, Is.EqualTo(engageSplits[i]));
                foreach (JObject msgPart in msg.Cast <JObject>())
                {
                    AssertPeopleSetJson(msgPart);
                }
            }

            Assert.That(HttpPostEntries.Count, Is.EqualTo(trackSplits.Count + engageSplits.Count));
        }
Beispiel #2
0
        public async Task When_SendAsync_Then_CorrectDataSent()
        {
            bool result = await Client.SendJsonAsync(MixpanelMessageEndpoint.Track, CreateJsonMessage());

            Assert.That(result, Is.True);
            Assert.That(HttpPostEntries.Single().Endpoint, Is.EqualTo(TrackUrl));
            CheckSendJsonMessage();
        }
Beispiel #3
0
        private void AssertSentData(object expectedDistinctId)
        {
            var(endpoint, data) = HttpPostEntries.Single();

            Assert.That(endpoint, Is.EqualTo(EngageUrl));

            var msg = ParseMessageData(data);

            AssertJson(msg, expectedDistinctId);
        }
Beispiel #4
0
        private void CheckSendJsonMessage()
        {
            var msg = ParseMessageData(HttpPostEntries.Single().Data);

            Assert.That(msg.Count, Is.EqualTo(2));
            Assert.That(msg["event"].Value <string>(), Is.EqualTo(Event));
            var props = (JObject)msg["properties"];

            Assert.That(props.Count, Is.EqualTo(3));
            Assert.That(props["token"].Value <string>(), Is.EqualTo(Token));
            Assert.That(props["distinct_id"].Value <string>(), Is.EqualTo(DistinctId));
            Assert.That(props[StringPropertyName].Value <string>(), Is.EqualTo(StringPropertyValue));
        }