Esempio n. 1
0
        private static T CreateAssertionComponent <T>(out IAssertionComponentConfigurator configurator, CheckMethod checkOnMethods, GameObject gameObject, string propertyPath) where T : ActionBase
        {
            var ac = gameObject.AddComponent <AssertionComponent>();

            ac.checkMethods = checkOnMethods;
            var comparer = ScriptableObject.CreateInstance <T>();

            ac.Action    = comparer;
            ac.Action.go = gameObject;
            ac.Action.thisPropertyPath = propertyPath;
            configurator = ac;

#if !UNITY_METRO
            var stackTrace   = new StackTrace(true);
            var thisFileName = stackTrace.GetFrame(0).GetFileName();
            for (int i = 1; i < stackTrace.FrameCount; i++)
            {
                var stackFrame = stackTrace.GetFrame(i);
                if (stackFrame.GetFileName() != thisFileName)
                {
                    string filePath = stackFrame.GetFileName().Substring(Application.dataPath.Length - "Assets".Length);
                    ac.m_CreatedInFilePath = filePath;
                    ac.m_CreatedInFileLine = stackFrame.GetFileLineNumber();
                    break;
                }
            }
#endif  // if !UNITY_METRO
            return(comparer);
        }
Esempio n. 2
0
        private static T CreateAssertionComponent <T>(out IAssertionComponentConfigurator configurator, CheckMethod checkOnMethods, GameObject gameObject, string propertyPath) where T : ActionBase
        {
            AssertionComponent assertionComponent = gameObject.AddComponent <AssertionComponent>();

            assertionComponent.checkMethods = checkOnMethods;
            T result = (T)(assertionComponent.Action = ScriptableObject.CreateInstance <T>());

            assertionComponent.Action.go = gameObject;
            assertionComponent.Action.thisPropertyPath = propertyPath;
            configurator = assertionComponent;
            StackTrace stackTrace = new StackTrace(fNeedFileInfo: true);
            string     fileName   = stackTrace.GetFrame(0).GetFileName();

            for (int i = 1; i < stackTrace.FrameCount; i++)
            {
                StackFrame frame = stackTrace.GetFrame(i);
                if (frame.GetFileName() != fileName)
                {
                    string text = (assertionComponent.m_CreatedInFilePath = frame.GetFileName().Substring(Application.dataPath.Length - "Assets".Length));
                    assertionComponent.m_CreatedInFileLine = frame.GetFileLineNumber();
                    break;
                }
            }
            return(result);
        }
Esempio n. 3
0
        public static T Create <T>(out IAssertionComponentConfigurator configurator, CheckMethod checkOnMethods, GameObject gameObject, string propertyPath, GameObject gameObject2, string propertyPath2) where T : ComparerBase
        {
            var comparer = CreateAssertionComponent <T>(out configurator, checkOnMethods, gameObject, propertyPath);

            comparer.compareToType     = ComparerBase.CompareToType.CompareToObject;
            comparer.other             = gameObject2;
            comparer.otherPropertyPath = propertyPath2;
            return(comparer);
        }
Esempio n. 4
0
        public static T Create <T>(out IAssertionComponentConfigurator configurator, CheckMethod checkOnMethods, GameObject gameObject, string propertyPath, object constValue) where T : ComparerBase
        {
            var comparer = CreateAssertionComponent <T>(out configurator, checkOnMethods, gameObject, propertyPath);

            if (constValue == null)
            {
                comparer.compareToType = ComparerBase.CompareToType.CompareToNull;
                return(comparer);
            }
            comparer.compareToType = ComparerBase.CompareToType.CompareToConstantValue;
            comparer.ConstValue    = constValue;
            return(comparer);
        }
Esempio n. 5
0
 public static T Create <T>(out IAssertionComponentConfigurator configurator, CheckMethod checkOnMethods, GameObject gameObject, string propertyPath) where T : ActionBase
 {
     return(CreateAssertionComponent <T>(out configurator, checkOnMethods, gameObject, propertyPath));
 }