Beispiel #1
0
        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");
        }
Beispiel #2
0
        public void GetClonedHashSet()
        {
            var testListener = new UnityAdsTestListener(null, null, null, null);
            var listeners    = new HashSet <IUnityAdsListener> {
                testListener
            };

            var listenersCopy = Platform.Platform.GetClonedHashSet(listeners);

            Assert.That(listenersCopy.Count, Is.EqualTo(listeners.Count), "Both listener HashSets counts should be equal");

            var iterator1 = listeners.GetEnumerator();
            var iterator2 = listenersCopy.GetEnumerator();

            for (var x = 0; x < listeners.Count; x++)
            {
                Assert.That(iterator1.Current, Is.EqualTo(iterator2.Current), "Cloned HashSet object does not match original");
            }

            iterator1.Dispose();
            iterator2.Dispose();
        }