コード例 #1
0
ファイル: HWLua.cs プロジェクト: hahoyer/factorio
        public void Push(IRootObject rootObject, params string[] path)
        {
            var index = rootObject.BeginAccess(this);

            Kernel.LuaPushValue(index + 1);
            foreach (var key in path)
            {
                Stack.GetTable(key, 0);
                Kernel.LuaRemove(-2);
            }
            rootObject.EndAccess(this, index);
        }
コード例 #2
0
ファイル: MainWindow.xaml.cs プロジェクト: srkeshav/Cricket
 //Is this Pattern Expression/Contravariance?
 void UpdateCricInfo(IRootObject IRO)
 {
     if (IRO is RootObject scoreboardBO)
     {
         ModifyScoreboardBO(ref scoreboardBO);
         dgMatches.ItemsSource = scoreboardBO.data;
     }
     else if (IRO is RootObjectScore rscoreboardBO)
     {
         ModifyScoreboardBO(ref rscoreboardBO);
         ((Datum)dgMatches.SelectedItem).description = rscoreboardBO.description;
     }
 }
コード例 #3
0
ファイル: HWLua.cs プロジェクト: hahoyer/factorio
        public string GetNextKey(IRootObject rootObject, string currentKey, params string[] path)
        {
            Push(rootObject, path);
            Stack.Push(currentKey);
            var result = Kernel.LuaNext(-2) != 0;

            Stack.Drop();
            var newKey = Stack.Top[0].Materialize().AsString;

            Stack.Drop();
            Stack.Drop();
            return(result? newKey:null);
        }
コード例 #4
0
ファイル: HWLua.cs プロジェクト: hahoyer/factorio
        public void Set(IRootObject rootObject, object value, params string[] path)
        {
            if (path.Length < 1)
            {
                throw new Exception("key required");
            }

            Push(rootObject, path.Take(path.Length - 1).ToArray());

            Stack.Push(path.Last());
            Stack.Push(value);
            Kernel.LuaSetTable(-3);
            Stack.Drop();
        }
コード例 #5
0
ファイル: HWLua.cs プロジェクト: hahoyer/factorio
        public IEnumerable <string> GetKeys(IRootObject rootObject, params string[] path)
        {
            Push(rootObject, path);
            Kernel.LuaPushNil();
            var result = new List <string>();

            while (Kernel.LuaNext(-2) != 0)
            {
                Stack.Drop();
                var key = Stack.Top[0].Materialize().AsString;
                result.Add(key);
            }

            Stack.Drop();
            Stack.Drop();
            return(result.ToArray());
        }
コード例 #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="UIObjectInterfaceResolver"/> class.
 /// </summary>
 /// <param name="rootObject">The process object.</param>
 public UIObjectInterfaceResolver(IRootObject rootObject) => this.rootObject = rootObject;
コード例 #7
0
 /// <summary>
 /// コンストラクタ
 /// </summary>
 public SelectableElementBase(IRootObject root)
     : base(root)
 {
 }
コード例 #8
0
 /// <summary>
 /// コンストラクタ
 /// </summary>
 /// <param name='root'>
 /// ルートオブジェクト
 /// </param>
 public DiagramElementBase(IRootObject root)
 {
     this.root = root;
 }
コード例 #9
0
 /// <summary>
 /// コンストラクタ
 /// </summary>
 public NodeElementBase(IRootObject root)
     : base(root)
 {
 }
コード例 #10
0
 public VirtualObjectView(HWLua parent, IRootObject rootObject, params string[] path)
     : base(parent, rootObject, path)
 {
 }
コード例 #11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PageObjectLocator"/> class.
 /// </summary>
 /// <param name="processObject">The process object.</param>
 internal PageObjectLocator(IRootObject processObject)
 {
     Clear();
     rootObject = processObject;
 }
コード例 #12
0
 public HomeController(IRootObject root)
 {
     _root = root;
 }
コード例 #13
0
 public UserDataObject(HWLua parent, IRootObject rootObject, string[] path)
     : base(parent, rootObject, path)
 {
 }
コード例 #14
0
 public FunctionObject(HWLua parent, IRootObject rootObject, string[] path)
     : base(parent, rootObject, path)
 {
 }
コード例 #15
0
        /// <summary>
        /// Run tests for this page object.
        /// </summary>
        /// <param name="source">The source page object.</param>
        /// <param name="methodFilter">The test method filter predicate.</param>
        /// <param name="pageTestClassFilter">The page test class filter predicate.</param>
        /// <returns>This page object.</returns>
        public static IPageObject Test(this IPageObject source, Predicate <MethodInfo> methodFilter = null, Predicate <IPageObjectTests> pageTestClassFilter = null)
        {
            methodFilter        = methodFilter ?? (_ => true);
            pageTestClassFilter = pageTestClassFilter ?? (_ => true);

            foreach (Type classWithTests in source.TestClasses())
            {
                // create and initialize page test class
                IPageObjectTestsInternal instance;
                IRootObject root          = GetRoot(source);
                var         configuration = root.Configuration;
                configuration.LogAction("Found page test class for current class " + source.GetType().ToString() + ": " + classWithTests.ToString());

                try
                {
                    configuration
                    .DependencyRegistrator
                    .Register(classWithTests);

                    instance = (IPageObjectTestsInternal)configuration.resolver.Resolve(classWithTests);
                }
                catch (Stashbox.Exceptions.ResolutionFailedException exception)
                {
                    throw new TypeResolutionFailedException(exception, $"Configure the resolver via '{nameof(Configuration.DependencyRegistrator)}' in class '{root.GetType().FullName}'.");
                }

                // init page test class
                instance.Init(source);

                // check if tests should be executed according to the page test filter
                if (pageTestClassFilter(instance))
                {
                    configuration.LogAction("Page test class filter returned true; running tests...");
                }
                else
                {
                    configuration.LogAction("Page test class filter returned true; skipping tests...");
                    continue;
                }

                // check if tests should be executed according to the runnable predicate
                if (instance.Runnable)
                {
                    configuration.LogAction("Runnable returned true; running tests...");
                }
                else
                {
                    configuration.LogAction("Runnable returned false; skipping tests");
                    continue;
                }

                // get page test methods, and order them from top to bottom
                // ordering does not respect inheritence
                var methods               = classWithTests.GetMethods().Where(method => method.GetCustomAttributes(typeof(PageTestAttribute), false).Length > 0);
                var methodsByLine         = methods.OrderBy(method => method.GetCustomAttribute <PageTestAttribute>(true).Line);
                var matchingMethodsByLine = methodsByLine.Where(method => methodFilter(method));

                int testMethodsCount = matchingMethodsByLine.Count();
                if (testMethodsCount > 0)
                {
                    configuration.LogAction("Found " + testMethodsCount + " test methods");
                }
                else
                {
                    configuration.LogAction("No test method found; skipping test class");
                    continue;
                }

                configuration.LogAction($"Execute function {nameof(IPageObjectTests.BeforeFirstTest)}...");
                instance.BeforeFirstTest();

                // check if tests should be executed
                if (!instance.ReadyToRun)
                {
                    throw new TestNotReadyToRunException(classWithTests.FullName);
                }
                else
                {
                    configuration.LogAction("Tests are ready to run...");
                }

                // create class statistics object
                TestClassStatistic testClassStatistic = new TestClassStatistic(classWithTests);

                // execute test methods
                try
                {
                    foreach (var testMethod in matchingMethodsByLine)
                    {
                        if (instance.IsTestRunnable(testMethod))
                        {
                            Test(testClassStatistic, instance, testMethod, configuration.LogAction);
                        }
                        else
                        {
                            configuration.LogAction($"Skipping test: '{nameof(instance.IsTestRunnable)}' returned false for test method '{testMethod.Name}'.");
                        }
                    }

                    configuration.LogAction($"Execute function {nameof(IPageObjectTests.AfterLastTest)}...");
                    instance.AfterLastTest();
                }
                finally
                {
                    var pageObjectStatistic = PageObjectStatistic(source);
                    pageObjectStatistic += testClassStatistic;
                }
            }

            return(source);
        }
コード例 #16
0
 /// <summary>
 /// コンストラクタ
 /// </summary>
 public EdgeElementBase(IRootObject root)
     : base(root)
 {
 }