public void NativePlatformAddAndRemoveListener() { var platform = new Platform.Platform(m_NativePlatformMock.Object, m_BannerMock.Object, m_CoroutineExecutorMock.Object); var testListener = new UnityAdsTestListener(null, null, null, null); Assert.That(platform.Listeners, Is.Not.Null, "The list of Listeners should not be null if the platform has been created"); platform.AddListener(testListener); Assert.That(platform.Listeners.Count, Is.EqualTo(1), "Incorrect number of listeners"); platform.RemoveListener(testListener); Assert.That(platform.Listeners.Count, Is.EqualTo(0), "Incorrect number of listeners"); }
public IEnumerator UnityAdsDidError(string testPlacementId) { var hasCalledListener = false; var platform = new Platform.Platform(m_NativePlatformMock.Object, m_BannerMock.Object, m_CoroutineExecutorMock.Object); platform.AddListener(new UnityAdsTestListener(null, (placementId) => { Assert.That(placementId, Is.EqualTo(testPlacementId), "The placementId under test should have been the placement id that is returned in Error"); hasCalledListener = true; }, null, null)); platform.UnityAdsDidError(testPlacementId); while (!hasCalledListener) { yield return(null); } Assert.That(hasCalledListener, Is.True, "The OnUnityAdsDidError callback should have 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"); }
public IEnumerator OnStartCallbackSetsIsShowingOnAdStart(string testPlacementId) { var hasCalledListener = false; var platform = new Platform.Platform(m_NativePlatformMock.Object, m_BannerMock.Object, m_CoroutineExecutorMock.Object); platform.AddListener(new UnityAdsTestListener(null, null, (placementId) => { Assert.That(placementId, Is.EqualTo(testPlacementId), "The placementId under test should have been the placement id that is returned Starting"); hasCalledListener = true; }, null)); platform.Initialize("1234567", false, false, null); platform.UnityAdsDidStart(testPlacementId); while (!hasCalledListener) { yield return(null); } Assert.That(hasCalledListener, Is.True, "The OnUnityAdsDidStart callback should have called"); Assert.That(platform.IsShowing, Is.True, "IsShowing should be set to true after starting to show an ad"); 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"); }