예제 #1
0
        private static T CreateAssertionComponent <T> (out AssertionComponentConfigurator 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;

            var stackTrace   = new System.Diagnostics.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.createdInFilePath = filePath;
                    ac.createdInFileLine = stackFrame.GetFileLineNumber();
                    break;
                }
            }

            return(comparer);
        }
        public static T Create <T> (out AssertionComponentConfigurator 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);
        }
        public static T Create <T> (out AssertionComponentConfigurator 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);
        }
예제 #4
0
 public static T Create <T> (out AssertionComponentConfigurator configurator, CheckMethod checkOnMethods, GameObject gameObject, string propertyPath) where T :
 ActionBase
 {
     return(CreateAssertionComponent <T> (out configurator, checkOnMethods, gameObject, propertyPath));
 }