public IEnumerator UnityAdsDidFinish(string testPlacementId, ShowResult testShowResult) { var hasCalledListener = false; var platform = new Platform.Platform(m_NativePlatformMock.Object, m_BannerMock.Object, m_CoroutineExecutorMock.Object); platform.AddListener(new UnityAdsTestListener(null, null, null, (placementId, showResult) => { Assert.That(placementId, Is.EqualTo(testPlacementId), "The placementId under test should have been the placement id that is returned Finishing"); Assert.That(showResult, Is.EqualTo(testShowResult), "The showResult under test should have been the showResult that is returned Finishing"); hasCalledListener = true; })); platform.UnityAdsDidFinish(testPlacementId, testShowResult); while (!hasCalledListener) { yield return(null); } Assert.That(hasCalledListener, Is.True, "The OnUnityAdsDidFinish 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 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"); }