<commit_before>#if ENABLE_PLAYFABPUBSUB_API

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace PlayFab.UUnit
{
    public class PubSubTest : UUnitTestCase
    {
        static PlayFab.EventsModels.EntityKey _MyEntityKey = null;
        static string _previousTitleId = null;

        private PubSub pubSub;

        TimeSpan writeDelay = new TimeSpan(0, 0, 0, 3);
        DateTime nextWrite;

        public override void SetUp(UUnitTestContext testContext)
        {
            // specific title id for relay test
            _previousTitleId = PlayFabSettings.TitleId;
            PlayFabSettings.TitleId = "70B02F89";
            PlayFabSettings.VerticalName = "spi";
            UpdateNextWriteTime();
        }

        private void UpdateNextWriteTime()
        {
            nextWrite = DateTime.Now + writeDelay;
        }

        public override void Tick(UUnitTestContext testContext)
        {
            // this test will ping a write event continuously
            // THIS TEST THROTTLES THE TITLE. so you should NOT do this until you KNOW the object is open
            if (pubSub != null && pubSub.State == PersistentSocketState.Opened && DateTime.Now > nextWrite)
            {
                UpdateNextWriteTime();
                EventsModels.WriteEventsRequest req = new EventsModels.WriteEventsRequest();

                EventsModels.EventContents ec = new EventsModels.EventContents();

                ec.Entity = new EventsModels.EntityKey();
                ec.Entity.Id = _MyEntityKey.Id;
                ec.Entity.Type = _MyEntityKey.Type;
                ec.Name = "testevent";

                ec.EventNamespace = "com.playfab.events.test";

                req.Events = new List<EventsModels.EventContents>();
                req.Events.Add(ec);

                PlayFabEventsAPI.WriteEvents(req, null, null);
            }
        }

        public override void TearDown(UUnitTestContext testContext)
        {
            PlayFabSettings.TitleId = _previousTitleId;
            PlayFabSettings.VerticalName = null;<commit_msg>Need a PayloadJSON in an EventContents (#328)<commit_after>#if ENABLE_PLAYFABPUBSUB_API

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace PlayFab.UUnit
{
    public class PubSubTest : UUnitTestCase
    {
        static PlayFab.EventsModels.EntityKey _MyEntityKey = null;
        static string _previousTitleId = null;

        private PubSub pubSub;

        TimeSpan writeDelay = new TimeSpan(0, 0, 0, 3);
        DateTime nextWrite;

        private const string ns = "com.playfab.events.test";
        private const string testName = "testevent";

        public override void SetUp(UUnitTestContext testContext)
        {
            // specific title id for relay test
            _previousTitleId = PlayFabSettings.TitleId;
            PlayFabSettings.TitleId = "70B02F89";
            PlayFabSettings.VerticalName = "spi";
            UpdateNextWriteTime();
        }

        private void UpdateNextWriteTime()
        {
            nextWrite = DateTime.Now + writeDelay;
        }

        public override void Tick(UUnitTestContext testContext)
        {
            if (pubSub != null && pubSub.State == PersistentSocketState.Opened && DateTime.Now > nextWrite)
            {
                UpdateNextWriteTime();
                EventsModels.WriteEventsRequest req = new EventsModels.WriteEventsRequest();

                EventsModels.EventContents ec = new EventsModels.EventContents();

                ec.Entity = new EventsModels.EntityKey();
                ec.Entity.Id = _MyEntityKey.Id;
                ec.Entity.Type = _MyEntityKey.Type;
                ec.Name = testName;

                ec.EventNamespace = ns;
                ec.PayloadJSON = $"{{\"CurrentTime\" : \"{DateTime.Now}\"}}";

                req.Events = new List<EventsModels.EventContents>();
                req.Events.Add(ec);

                PlayFabEventsAPI.WriteEvents(req, null, null);
            }
        }

        public override void TearDown(UUnitTestContext testContext)
        {
            PlayFabSettings.TitleId = _previousTitleId;
            PlayFabSettings.VerticalName = null;
{'fraction_non_alphanumeric': 0.07924970691676436, 'fraction_numerical': 0.005392731535756155, 'mean_word_length': 2.051502145922747, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3138934', 'n_tokens_mistral': 1150, 'n_tokens_neox': 1071, 'n_words': 260}