Beispiel #1
0
        public void NativePlatformShow(string placementId)
        {
            m_NativePlatformMock.Setup(x => x.Show(It.IsAny <string>(), null));
            var platform = new Platform.Platform(m_NativePlatformMock.Object, m_BannerMock.Object, m_CoroutineExecutorMock.Object);

            platform.Show(placementId, null, null);
            m_NativePlatformMock.Verify(x => x.Show(It.IsAny <string>(), null), Times.Once(), "NativePlatform.Show() was not called as expected");
        }
Beispiel #2
0
        public IEnumerator ShowOptionsGamerSid(string expectedGamerSid)
        {
            var setMetaDataCalled = false;
            var platform          = new Platform.Platform(m_NativePlatformMock.Object, m_BannerMock.Object, m_CoroutineExecutorMock.Object);

            m_NativePlatformMock.Setup(x => x.SetMetaData(It.IsAny <MetaData>())).Callback <MetaData>(result => {
                Assert.That(result.category, Is.EqualTo("player"), "The category player should exist if gamerSid was stored properly");
                Assert.That(result.Get("server_id"), Is.EqualTo(expectedGamerSid), "GamerSid was not stored properly in MetaData");
                setMetaDataCalled = true;
            });

            var showOptions = new ShowOptions();

            showOptions.gamerSid += expectedGamerSid;
            platform.Show("placementId", showOptions, null);
            m_NativePlatformMock.Verify(x => x.SetMetaData(It.IsAny <MetaData>()), Times.Once(), "Set MetaData should have been called with the gamerSid");
            while (!setMetaDataCalled)
            {
                yield return(null);
            }
            Assert.That(setMetaDataCalled, Is.True, "The SetMetaData function should have been called");
        }
Beispiel #3
0
        public IEnumerator UnityAdsDidFinishShowOptionsInvoked(string expectedPlacementId, ShowResult expectedShowResult)
        {
            var hasCalledListener = false;
            var platform          = new Platform.Platform(m_NativePlatformMock.Object, m_BannerMock.Object, m_CoroutineExecutorMock.Object);

            m_NativePlatformMock.Setup(x => x.Show(It.IsAny <string>(), null)).Callback(() => {
                platform.UnityAdsDidFinish(expectedPlacementId, expectedShowResult);
            });

            var showOptions = new ShowOptions();

            showOptions.resultCallback += result => {
                Assert.That(result, Is.EqualTo(expectedShowResult), "resultCallback showOption should match the expected value.");
                hasCalledListener = true;
            };
            platform.Show(expectedPlacementId, showOptions, null);
            while (!hasCalledListener)
            {
                yield return(null);
            }
            Assert.That(hasCalledListener, Is.True, "The hideCallback should have been called");
            m_CoroutineExecutorMock.Verify(x => x.Post(It.IsAny <Action>()), Times.Once(), "Calls should happen on the main thread and should all batched together as 1 call");
        }