Exemple #1
0
        private void DuplicateComponentMemoryManagementTest()
        {
            Debug.Log(LogLevel.Display, "Starting " + MethodBase.GetCurrentMethod().Name + "...");

            try {
                Actor          actor              = new Actor();
                SceneComponent sceneComponent     = new SceneComponent(actor, setAsRoot: true);
                SceneComponent duplicateReference = actor.GetRootComponent <SceneComponent>();

                if (!sceneComponent.Equals(duplicateReference))
                {
                    Debug.Log(LogLevel.Error, "Scene component reference equality check failed!");

                    return;
                }

                sceneComponent.Destroy();

                Debug.Log(LogLevel.Display, "Triggering invalid actions after the destruction");

                duplicateReference.AddLocalOffset(default(Vector3));
                duplicateReference.Destroy();
            }

            catch (Exception exception) {
                Debug.Log(LogLevel.Display, "The exception has successfully reached: " + exception.Message);

                return;
            }

            Debug.Log(LogLevel.Error, "Test failed!");
        }
        private void HashCodesTest()
        {
            Debug.Log(LogLevel.Display, "Starting " + MethodBase.GetCurrentMethod().Name + "...");

            Actor          actorLeft           = new Actor();
            Actor          actorRight          = new Actor();
            SceneComponent sceneComponentLeft  = new SceneComponent(actorLeft);
            SceneComponent sceneComponentRight = new SceneComponent(actorRight);

            if (sceneComponentLeft.GetHashCode() == sceneComponentRight.GetHashCode() || sceneComponentLeft.GetHashCode() != sceneComponentLeft.GetHashCode())
            {
                Debug.Log(LogLevel.Error, "Scene components hash codes check failed!");

                return;
            }

            sceneComponentLeft.Destroy();

            if (sceneComponentRight.GetHashCode() == sceneComponentLeft.GetHashCode())
            {
                Debug.Log(LogLevel.Error, "Scene components hash codes check after destruction failed!");

                return;
            }

            if (actorLeft.GetHashCode() == actorRight.GetHashCode() || actorLeft.GetHashCode() != actorLeft.GetHashCode())
            {
                Debug.Log(LogLevel.Error, "Actors hash codes check failed!");

                return;
            }

            actorLeft.Destroy();

            if (actorRight.GetHashCode() == actorLeft.GetHashCode())
            {
                Debug.Log(LogLevel.Error, "Actors hash codes check after destruction failed!");

                return;
            }

            Debug.Log(LogLevel.Display, "Test passed successfully");
        }
Exemple #3
0
        private void ComponentMemoryManagementTest()
        {
            Debug.Log(LogLevel.Display, "Starting " + MethodBase.GetCurrentMethod().Name + "...");

            try {
                Actor          actor          = new Actor();
                SceneComponent sceneComponent = new SceneComponent(actor, setAsRoot: true);

                sceneComponent.Destroy();

                Debug.Log(LogLevel.Display, "Triggering invalid action after the destruction");

                sceneComponent.AddLocalOffset(default(Vector3));
            }

            catch (Exception exception) {
                Debug.Log(LogLevel.Display, "The exception has successfully reached: " + exception.Message);

                return;
            }

            Debug.Log(LogLevel.Error, "Test failed!");
        }
        private void ReferencesEqualityTest()
        {
            Debug.Log(LogLevel.Display, "Starting " + MethodBase.GetCurrentMethod().Name + "...");

            TriggerBox     actorLeft           = new TriggerBox();
            TriggerSphere  actorRight          = new TriggerSphere();
            SceneComponent sceneComponentLeft  = new SceneComponent(actorLeft);
            SceneComponent sceneComponentRight = new SceneComponent(actorRight);

            if (sceneComponentLeft.Equals(sceneComponentRight) || !sceneComponentLeft.Equals(sceneComponentLeft))
            {
                Debug.Log(LogLevel.Error, "Scene components equality check failed!");

                return;
            }

            if (actorLeft.Equals(sceneComponentRight.GetActor <TriggerSphere>()) || !actorLeft.Equals(sceneComponentLeft.GetActor <TriggerBox>()))
            {
                Debug.Log(LogLevel.Error, "Scene components owners equality check failed!");

                return;
            }

            sceneComponentLeft.Destroy();

            if (sceneComponentRight.Equals(sceneComponentLeft))
            {
                Debug.Log(LogLevel.Error, "Scene components equality check after destruction failed!");

                return;
            }

            sceneComponentRight.Destroy();

            if (sceneComponentRight.Equals(sceneComponentRight))
            {
                Debug.Log(LogLevel.Error, "Scene components equality check with null failed!");

                return;
            }

            if (actorLeft.Equals(actorRight) || !actorLeft.Equals(actorLeft))
            {
                Debug.Log(LogLevel.Error, "Actors equality check failed!");

                return;
            }

            actorLeft.Destroy();

            if (actorRight.Equals(actorLeft))
            {
                Debug.Log(LogLevel.Error, "Actors equality check after destruction failed!");

                return;
            }

            actorRight.Destroy();

            if (actorRight.Equals(actorRight))
            {
                Debug.Log(LogLevel.Error, "Actors equality check with null failed!");

                return;
            }

            Debug.Log(LogLevel.Display, "Test passed successfully");
        }