<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Infinity Code Forum — destroying instances during unit and integration tests]]></title>
		<link>https://forum.infinity-code.com/viewtopic.php?id=869</link>
		<atom:link href="https://forum.infinity-code.com/extern.php?action=feed&amp;tid=869&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in destroying instances during unit and integration tests.]]></description>
		<lastBuildDate>Tue, 31 Jul 2018 12:54:07 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: destroying instances during unit and integration tests]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=3741#p3741</link>
			<description><![CDATA[<p>Thanks for taking a look, Alex. Turns out that my problem was not instantiating the map GameObject after loading it as a resource. I&#039;ve been using Zenject for loading prefabs and forgot how to do it the standard way. For posterity, here&#039;s how to load the map as part of a Unity play mode test:</p><div class="codebox"><pre><code>        [UnityTest]
        public IEnumerator TestMapLoaded()
        {
            var mapObj = Resources.Load(&quot;Prefabs/UI/Map&quot;) as GameObject;
            Assert.IsNotNull(mapObj);

            var mapInstance = GameObject.Instantiate(mapObj);
            var camera = mapInstance.AddComponent&lt;Camera&gt;();
            Assert.True(mapInstance.activeInHierarchy);
            var maps = mapInstance.GetComponent&lt;OnlineMaps&gt;();
            Assert.IsNotNull(maps);
            var tileset = mapInstance.GetComponent&lt;OnlineMapsTileSetControl&gt;();
            Assert.IsNotNull(tileset);
            tileset.activeCamera = camera;
            Assert.IsNotNull(tileset);
            Assert.True(maps.isActiveAndEnabled);
            Assert.IsNotNull(OnlineMaps.instance);
            Assert.IsNotNull(tileset.activeCamera);
            yield return null;
        }</code></pre></div><p>Tim</p>]]></description>
			<author><![CDATA[null@example.com (movestill)]]></author>
			<pubDate>Tue, 31 Jul 2018 12:54:07 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=3741#p3741</guid>
		</item>
		<item>
			<title><![CDATA[Re: destroying instances during unit and integration tests]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=3739#p3739</link>
			<description><![CDATA[<p>Here is the explanation:<br /><a href="https://answers.unity.com/questions/698664/is-there-a-way-to-ensure-awake-is-called-in-unit-t.html">https://answers.unity.com/questions/698 … nit-t.html</a></p><p>Unfortunately, I&#039;m not a big helper in unit testing, because I do not use it in Unity.</p>]]></description>
			<author><![CDATA[null@example.com (Alex Vertax)]]></author>
			<pubDate>Mon, 30 Jul 2018 21:30:03 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=3739#p3739</guid>
		</item>
		<item>
			<title><![CDATA[Re: destroying instances during unit and integration tests]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=3737#p3737</link>
			<description><![CDATA[<p>Thanks for the prompt reply. Any idea why Awake() isn&#039;t called after instantiating the prefab? In the prefab, the GameObject is active as is its OnlineMaps and OnlineMapsTileSetControl components. </p><p>Actually, after looking further, it seems like the instantiated prefab can&#039;t be activated for some reason.</p><p>Here&#039;s bare minimum test code using Unity 2017.3 and OnlineMaps 2.5.30.1:</p><div class="codebox"><pre><code>    [TestFixture]
    public class MapTest
    {
        [UnityTest]
        public IEnumerator TestMap()
        {
            var mapObj = Resources.Load(&quot;Prefabs/UI/Map&quot;) as GameObject;
            Assert.IsNotNull(mapObj);
            yield return null;
            mapObj.SetActive(true);
            yield return null;

// This assert fails.

            Assert.True(mapObj.activeInHierarchy);
        }
    }</code></pre></div><p>Thanks,<br />Tim</p>]]></description>
			<author><![CDATA[null@example.com (movestill)]]></author>
			<pubDate>Mon, 30 Jul 2018 18:25:06 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=3737#p3737</guid>
		</item>
		<item>
			<title><![CDATA[Re: destroying instances during unit and integration tests]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=3736#p3736</link>
			<description><![CDATA[<p>Hello.</p><p>Just destroy the map GameObject, and then create a new instance from the prefab.</p>]]></description>
			<author><![CDATA[null@example.com (Alex Vertax)]]></author>
			<pubDate>Mon, 30 Jul 2018 16:26:09 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=3736#p3736</guid>
		</item>
		<item>
			<title><![CDATA[destroying instances during unit and integration tests]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=3735#p3735</link>
			<description><![CDATA[<p>Is there an easy way to destroy all the various instances to ensure each test starts with a clean state? At first glance, looks like we use the instance properties of these classes:</p><p>OnlineMaps<br />OnlneMapsControlBase3D<br />OnlineMapsTileSetControl</p><p>Thanks,<br />Tim</p>]]></description>
			<author><![CDATA[null@example.com (movestill)]]></author>
			<pubDate>Mon, 30 Jul 2018 16:21:16 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=3735#p3735</guid>
		</item>
	</channel>
</rss>
