public static void TestMyParentPrivateComponentsArray(GameObject obj, bool inactive = false)
        {
            Assert.IsTrue(obj != null);
            var test = obj.GetComponent <ProcessorTestComponent>();

            Assert.IsTrue(test != null);
            var list            = test.GetComponentsInParent <Renderer>(inactive);
            SerializedObject so = new SerializedObject(test);

            Assert.IsNotNull(so);
            var propArray = inactive ? so.FindProperty("parentPrivateComponentsArrayInactive") : so.FindProperty("parentPrivateComponentsArray");

            Assert.IsNotNull(propArray);
            var propList = inactive ? so.FindProperty("parentPrivateComponentsListInactive") : so.FindProperty("parentPrivateComponentsList");

            Assert.IsNotNull(propList);

            if (list == null)
            {
                Assert.IsNull(propArray.objectReferenceValue);
                Assert.IsNull(propList.objectReferenceValue);
            }
            else
            {
                Assert.IsTrue(propArray.arraySize == list.Length);
                Assert.IsTrue(propList.arraySize == list.Length);
                for (var index = 0; index < list.Length; index++)
                {
                    Assert.AreEqual(list[index], propArray.GetArrayElementAtIndex(index).objectReferenceValue);
                    Assert.AreEqual(list[index], propArray.GetArrayElementAtIndex(index).objectReferenceValue);
                }
            }
        }
        public static void TestMyPublicComponentsArray(GameObject obj)
        {
            Assert.IsTrue(obj != null);
            var test = obj.GetComponent <ProcessorTestComponent>();

            Assert.IsTrue(test != null);
            var list = test.GetComponents <Renderer>();

            if (list == null)
            {
                Assert.IsNull(test.myPublicComponentsArray);
                Assert.IsNull(test.myPublicComponentsList);
            }
            IList arr = test.myPublicComponentsArray;
            IList lis = test.myPublicComponentsList;

            if (list == null)
            {
                Assert.IsNull(arr);
                Assert.IsNull(lis);
            }
            else
            {
                Assert.IsTrue(arr.Count == list.Length);
                Assert.IsTrue(lis.Count == list.Length);
                for (var index = 0; index < list.Length; index++)
                {
                    Assert.AreEqual(list[index], arr[index]);
                    Assert.AreEqual(list[index], lis[index]);
                }
            }
        }
        public static void TestMyParentPublicComponentsArray(GameObject obj, bool inactive = false)
        {
            Assert.IsTrue(obj != null);
            var test = obj.GetComponent <ProcessorTestComponent>();

            Assert.IsTrue(test != null);
            var list = test.GetComponentsInParent <Renderer>(inactive);

            IList arr = inactive ? test.parentPublicComponentsArrayInactive : test.parentPublicComponentsArray;
            IList lis = inactive ? test.parentPublicComponentsListInactive : test.parentPublicComponentsList;

            if (list == null)
            {
                Assert.IsNull(arr);
                Assert.IsNull(lis);
            }
            else
            {
                Assert.IsTrue(arr.Count == list.Length);
                Assert.IsTrue(lis.Count == list.Length);
                for (var index = 0; index < list.Length; index++)
                {
                    Assert.AreEqual(list[index], arr[index]);
                    Assert.AreEqual(list[index], lis[index]);
                }
            }
        }
        public void NestedSourceScope()
        {
            var       registry = new UTinyRegistry();
            var       builtInCount = registry.Count;
            var       sourceId = "outer";
            var       nestedSourceId = "inner";
            UTinyType testType, testType2;

            using (registry.SourceIdentifierScope(sourceId))
            {
                testType = registry.CreateType(UTinyId.New(), "TestType", UTinyTypeCode.Component);
                using (registry.SourceIdentifierScope(nestedSourceId))
                {
                    testType2 = registry.CreateType(UTinyId.New(), "TestType2", UTinyTypeCode.Component);
                }
            }

            var testTypeRef  = (UTinyType.Reference)testType;
            var testType2Ref = (UTinyType.Reference)testType2;

            Assert.AreEqual(builtInCount + 2, registry.Count);

            registry.UnregisterAllBySource(sourceId);
            Assert.AreEqual(builtInCount + 1, registry.Count);

            Assert.IsNull(testTypeRef.Dereference(registry));
            Assert.IsNotNull(testType2Ref.Dereference(registry));

            registry.UnregisterAllBySource(nestedSourceId);
            Assert.AreEqual(builtInCount, registry.Count);
            Assert.IsNull(testTypeRef.Dereference(registry));
            Assert.IsNull(testType2Ref.Dereference(registry));
        }
Ejemplo n.º 5
0
        public void TestInstanceCreate(bool result, bool required)
        {
            Loader.DisableValidationChecksOnEnteringPlaymode = true;
            bool instanceCreated      = false;
            bool hookInstanceProcAddr = false;
            bool other = false;

            MockRuntime.Instance.TestCallback = (methodName, param) =>
            {
                switch (methodName)
                {
                case nameof(OpenXRFeature.OnInstanceCreate):
                    instanceCreated = true;
                    return(result);

                case nameof(OpenXRFeature.HookGetInstanceProcAddr):
                    hookInstanceProcAddr = true;
                    break;

                default:
                    other = true;
                    break;
                }

                return(true);
            };

            MockRuntime.Instance.required = required;
            base.InitializeAndStart();

            Assert.IsTrue(instanceCreated);
            Assert.IsTrue(hookInstanceProcAddr);

            if (required && !result)
            {
                Assert.IsNull(OpenXRLoaderBase.Instance);
            }
            else
            {
                Assert.IsNotNull(OpenXRLoaderBase.Instance);
            }

            // A feature that fails that is not required should be disabled
            if (!result && !required)
            {
                Assert.IsFalse(MockRuntime.Instance.enabled);
            }

            base.StopAndShutdown();

            if (result)
            {
                Assert.IsTrue(other);
            }
            else
            {
                // A feature that fails initialize should have no further callbacks
                Assert.IsFalse(other);
            }
        }
Ejemplo n.º 6
0
        public void UnknownFeatureSetRerturnNull()
        {
            OpenXRFeatureSetManager.InitializeFeatureSets();
            var foundFeatureSet = OpenXRFeatureSetManager.GetFeatureSetWithId(BuildTargetGroup.iOS, k_TestFeatureSetId);

            Assert.IsNull(foundFeatureSet);
            foundFeatureSet = OpenXRFeatureSetManager.GetFeatureSetWithId(BuildTargetGroup.Standalone, "BAD FEATURE SET ID");
            Assert.IsNull(foundFeatureSet);
        }
        public IEnumerator AutoDeleteDuplicateInstance()
        {
            DummySingletonA singleton     = DummySingletonA.GetOrCreateInstance();
            DummySingletonA fakeSingleton = new GameObject("FakeSingleton").AddComponent <DummySingletonA>();

            yield return(null);

            Assert.IsNotNull(singleton);
            Assert.IsNull(fakeSingleton);
        }
Ejemplo n.º 8
0
        public IEnumerator SmokeTest()
        {
            Assert.IsNull(BlockPooler.Request());
            var instance = Object.FindObjectOfType <BlockPooler>();

            Assert.IsNotNull(instance);
            Assert.AreEqual(instance.transform.childCount, 0);

            yield return(null);
        }
Ejemplo n.º 9
0
        public IEnumerator LoadNotExistAudio(string fileName)
        {
            var func = MusicLoader.LoadAudioClipAsync($"{Application.dataPath}/Tests/Resources/{fileName}");

            while (func.MoveNext())
            {
                yield return(null);
            }
            Assert.IsNull(func.Current, "楽曲がnullであること。");
        }
        public void UnknownFeatureSetRerturnNull()
        {
            // For this test we do not want the test features enabled so rerun the initilization with
            InitializeFeatureSets(false);
            var foundFeatureSet = GetFeatureSetWithId(BuildTargetGroup.iOS, k_TestFeatureSetId);

            Assert.IsNull(foundFeatureSet);
            foundFeatureSet = GetFeatureSetWithId(BuildTargetGroup.Standalone, "BAD FEATURE SET ID");
            Assert.IsNull(foundFeatureSet);
        }
Ejemplo n.º 11
0
        public void GetFeatureByUnknownFeatureIdReturnsNull()
        {
            var feature = FeatureHelpers.GetFeatureWithIdForActiveBuildTarget("some.unknown.feature.id");

            Assert.IsNull(feature);

            feature = FeatureHelpers.GetFeatureWithIdForActiveBuildTarget("");
            Assert.IsNull(feature);

            feature = FeatureHelpers.GetFeatureWithIdForActiveBuildTarget(null);
            Assert.IsNull(feature);
        }
Ejemplo n.º 12
0
        public IEnumerator MultipleValuesDestroyed()
        {
            var k1 = new GameObject("K1").AddComponent <TestSingleton>();
            var k2 = new GameObject("K2").AddComponent <TestSingleton>();

            yield return(null);

            Assert.AreEqual(TestSingleton.AwakeCount, 2);
            Assert.AreEqual(TestSingleton.DestroyCount, 1);

            Assert.IsNull(k2);
            Assert.IsNotNull(k1);
            yield return(null);
        }
        public void Clear()
        {
            var registry     = new UTinyRegistry();
            var builtInCount = registry.Count;

            var type    = registry.CreateType(UTinyId.New(), "TestType", UTinyTypeCode.Component);
            var typeRef = (UTinyType.Reference)type;

            Assert.AreEqual(builtInCount + 1, registry.Count);

            registry.Clear();
            Assert.AreEqual(builtInCount, registry.Count);
            Assert.IsNull(typeRef.Dereference(registry));
        }
        public static void TestMyParentPrivateComponent(GameObject obj)
        {
            Assert.IsTrue(obj != null);
            var test = obj.GetComponent <ProcessorTestComponent>();

            Assert.IsTrue(test != null);
            SerializedObject so = new SerializedObject(test);
            var prop            = so.FindProperty("parentPrivateComponent");
            var result          = test.GetComponentInParent <Renderer>();

            if (result == null)
            {
                Assert.IsNull(prop.objectReferenceValue);
            }
            Assert.AreEqual(result, prop.objectReferenceValue);
        }
        public static void TestMyParentPublicComponent(GameObject obj)
        {
            Assert.IsTrue(obj != null);
            var test = obj.GetComponent <ProcessorTestComponent>();

            Assert.IsTrue(test != null);
            var result = test.GetComponentInParent <Renderer>();

            if (result == null)
            {
                Assert.IsNull(test.parentPublicComponent);
            }
            else
            {
                Assert.AreEqual(result, test.parentPublicComponent);
            }
        }
        public IEnumerator AddSingletonByAwake()
        {
            DummySingletonB singleton = new GameObject("TrueSingleton").AddComponent <DummySingletonB>();

            yield return(null);

            DummySingletonB secondSingleton = DummySingletonB.GetOrCreateInstance();

            DummySingletonB thirdSingleton = new GameObject("FakeSingleton").AddComponent <DummySingletonB>();

            yield return(null);

            Assert.IsNotNull(singleton);
            Assert.IsNotNull(secondSingleton);
            Assert.IsNull(thirdSingleton);
            Assert.AreEqual(singleton, secondSingleton);
        }
Ejemplo n.º 17
0
        public IEnumerator AfterInitialize()
        {
            MockRuntimeFeature.Instance.TestCallback = (methodName, param) => true;

            Assert.IsNull(OpenXRLoaderBase.Instance);

            base.InitializeAndStart();

            // Perform a domain reload and wait for it to complete
            EditorUtility.RequestScriptReload();
            yield return(new WaitForDomainReload());

            Assert.IsNotNull(OpenXRLoaderBase.Instance);

            base.StopAndShutdown();

            Assert.IsNull(OpenXRLoaderBase.Instance);

            yield return(null);
        }
Ejemplo n.º 18
0
        public void Test()
        {
            var parent = new GameObject();

            parent.transform.localPosition = Random.insideUnitSphere;
            parent.transform.localRotation = Random.rotation;
            parent.transform.localScale    = Vector3.one + Random.insideUnitSphere;
            var child = new GameObject();

            child.transform.SetParent(parent.transform, false);
            child.transform.localPosition = Random.insideUnitSphere;
            child.transform.localRotation = Random.rotation;
            child.transform.localScale    = Vector3.one + Random.insideUnitSphere;
            var childClone = Object.Instantiate(child.transform);

            Assert.IsNull(childClone.parent);
            Assert.AreEqual(child.transform.localPosition, childClone.transform.localPosition);
            Assert.AreEqual(child.transform.localRotation, childClone.transform.localRotation);
            Assert.AreEqual(child.transform.localScale, childClone.transform.localScale);
        }
Ejemplo n.º 19
0
        public IEnumerator IntegrationTest()
        {
            SceneManager.LoadScene(SCENE_NAME);
            yield return(null);

            var helper          = Object.FindObjectOfType <ProductionTestHelper>();
            var resourceManager = Object.FindObjectOfType <ResourceManager>();

            Assert.IsNotNull(helper);
            Assert.IsNotNull(resourceManager);

            var unit = helper.NormalFactory.ProduceUnit(0);

            unit.GetComponent <UnitMovementController>().MoveToPoint(helper.Scrapyard.GetComponent <Node>().UnitSlots[0].transform.position);
            yield return(new WaitForSeconds(5.0f));

            helper.Scrapyard.ScrapUnit(unit);
            yield return(null);

            Assert.IsNull(unit);
        }
Ejemplo n.º 20
0
 public void GetEmpty_Should_ReturnNull_When_FieldWasNotConfigured()
 {
     Assert.IsNull(ScriptUnderTest.Empty);
 }
Ejemplo n.º 21
0
        /// <summary>
        /// Gets all captures that would happen when moving the piece currently at "from" to "to".
        /// </summary>
        private HashSet <Piece> GetCaptures(Vector2i from, Vector2i to)
        {
            Piece           p    = theBoard[from.x, from.y];
            HashSet <Piece> caps = new HashSet <Piece>();

            Assert.IsNotNull(p);
            Assert.IsNull(theBoard[to.x, to.y]);

            //Imagine the board after the move is completed.
            Func <Vector2i, Piece> getPiece = (tile) =>
            {
                if (tile == from)
                {
                    return(null);
                }
                else if (tile == to)
                {
                    return(p);
                }
                else
                {
                    return(theBoard[tile.x, tile.y]);
                }
            };
            Func <Piece, Vector2i, bool> isAllyAtPos = (piece, pos) =>
            {
                Piece piece2 = getPiece(pos);
                return(piece2 != null && piece2.Owner.Value == piece.Owner.Value);
            };
            Func <Piece, Vector2i, bool, bool> isEnemyAtPos = (piece, pos, includeKing) =>
            {
                Piece piece2 = getPiece(pos);
                return(piece2 != null && piece2.Owner.Value != piece.Owner.Value &&
                       (includeKing || !piece2.IsKing));
            };
            Func <Vector2i, bool> isKingAtPos = (pos) =>
            {
                Piece piece = getPiece(pos);
                return(piece != null && piece.IsKing);
            };
            Func <Vector2i, bool> isKingThreatenedByPos = (pos) =>
            {
                //The king is threatened by attackers *and* by the throne space itself.
                if (pos.x == (BoardSize / 2) && pos.y == (BoardSize / 2))
                {
                    return(true);
                }
                Piece piece = getPiece(pos);
                return(piece != null && piece.Owner.Value == Player_Attacker);
            };

            //See if any normal (i.e. non-king) enemies were captured.
            if (to.x > 1 && isEnemyAtPos(p, to.LessX, false) && isAllyAtPos(p, to.LessX.LessX))
            {
                caps.Add(getPiece(to.LessX));
            }
            if (to.x < BoardSize - 2 && isEnemyAtPos(p, to.MoreX, false) && isAllyAtPos(p, to.MoreX.MoreX))
            {
                caps.Add(getPiece(to.MoreX));
            }
            if (to.y > 1 && isEnemyAtPos(p, to.LessY, false) && isAllyAtPos(p, to.LessY.LessY))
            {
                caps.Add(getPiece(to.LessY));
            }
            if (to.y < BoardSize - 2 && isEnemyAtPos(p, to.MoreY, false) && isAllyAtPos(p, to.MoreY.MoreY))
            {
                caps.Add(getPiece(to.MoreY));
            }

            //See if the King was captured.
            if (p.Owner.Value == Player_Attacker)
            {
                //First, see if the king is adjacent to the new position.
                Vector2i kingPos = new Vector2i(-1, -1);
                if (to.x > 0 && isKingAtPos(to.LessX))
                {
                    kingPos = to.LessX;
                }
                else if (to.y > 0 && isKingAtPos(to.LessY))
                {
                    kingPos = to.LessY;
                }
                else if (to.x < BoardSize - 1 && isKingAtPos(to.MoreX))
                {
                    kingPos = to.MoreX;
                }
                else if (to.y < BoardSize - 1 && isKingAtPos(to.MoreY))
                {
                    kingPos = to.MoreY;
                }

                //If he is, see if he is now surrounded on all sides by threats.
                if (kingPos != new Vector2i(-1, -1))
                {
                    if (kingPos.x > 0 && isKingThreatenedByPos(kingPos.LessX) &&
                        kingPos.y > 0 && isKingThreatenedByPos(kingPos.LessY) &&
                        kingPos.x < BoardSize - 1 && isKingThreatenedByPos(kingPos.MoreX) &&
                        kingPos.y < BoardSize - 1 && isKingThreatenedByPos(kingPos.MoreY))
                    {
                        caps.Add(getPiece(kingPos));
                    }
                }
            }

            return(caps);
        }
Ejemplo n.º 22
0
 public void GetColors_Should_ReturnNull_When_FieldWasNotConfigured()
 {
     Assert.IsNull(ScriptUnderTest.Colors);
 }
Ejemplo n.º 23
0
 public static void IsNull(Object value, string message) => UnityAssert.IsNull(value, message);
Ejemplo n.º 24
0
 public static void IsNull <T>(T value, string message) where T : class => UnityAssert.IsNull(value, message);
Ejemplo n.º 25
0
 public static void IsNull <T>(T value) where T : class => UnityAssert.IsNull(value);