示例#1
0
            public async Task OnLoad(ActionMenu menu)
            {
                AssertV2.IsNull(taskComplSource, "taskComplSource");
                taskComplSource = new TaskCompletionSource <Entry>();
                map             = targetView.GetLinkMap();
                menu.viewMode   = await menu.persistedSettings.Get(menu.menuId + " viewMode", menu.viewMode);

                SetupForViewMode(menu);
                await taskComplSource.Task;
            }
示例#2
0
        public void TestAssertV2Methods()
        {
            AssertV2.ThrowExeptionIfAssertionFails(() => {
                AssertV2.IsTrue(1 + 1 == 2, "This assertion must not fail");
                var s1 = "a";
                AssertV2.AreEqual(s1, s1);
                AssertV2.IsNull(null, "myVarX");
                AssertV2.AreEqual(1, 1);
                AssertV2.AreNotEqual(1, 2);
            });

            var stopWatch = AssertV2.TrackTiming();
            var res       = 1f;

            for (float i = 1; i < 500000; i++)
            {
                res = i / res + i;
            }
            Assert.NotEqual(0, res);

            stopWatch.Stop();
            AssertV2.ThrowExeptionIfAssertionFails(() => { stopWatch.AssertUnderXms(200); });
            Assert.True(stopWatch.IsUnderXms(200), "More time was needed than expected!");

            AssertV2.AreEqual("abcd", "abce");
            AssertV2.AreEqual(new int[4] {
                1, 2, 2, 4
            }, new int[4] {
                1, 2, 3, 4
            });
            AssertV2.AreEqual(new int[2] {
                1, 2
            }, new int[2] {
                1, 3
            });
            AssertV2.AreEqual(new int[6] {
                1, 2, 3, 4, 5, 6
            }, new int[6] {
                1, 2, 3, 4, 5, 7
            });
            AssertV2.AreEqual(new int[2] {
                1, 2
            }, new int[1] {
                1
            });
            AssertV2.AreEqual(new int[1] {
                1
            }, new int[2] {
                1, 2
            });
        }
示例#3
0
            public async Task OnLoad(ActionMenu menu)
            {
                AssertV2.IsNull(taskComplSource, "taskComplSource");
                taskComplSource = new TaskCompletionSource <Entry>();
                map             = targetView.GetLinkMap();
                menu.viewMode   = await menu.persistedSettings.Get(menu.menuId + " viewMode", menu.viewMode);

#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
                menu.SetupFavoriteLogic();
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed

                showOnlyFavorites = menu.entries.Any(x => x.isFavorite);
                SetupForViewMode(menu);
                await taskComplSource.Task;
            }
示例#4
0
        public void TestAssertV2Methods()
        {
            AssertV2.ThrowExeptionIfAssertionFails(() => {
                AssertV2.IsTrue(AssertV2.throwExeptionIfAssertionFails, "AssertV2.throwExeptionIfAssertionFails");

                AssertV2.IsTrue(1 + 1 == 2, "This assertion must not fail");
                AssertV2.Throws <Exception>(() => {
                    AssertV2.IsTrue(1 + 1 == 4, "This assertion has to fail");
                    Log.e("This line should never be printed since throwExeptionIfAssertionFails is true");
                });

                var s1 = "a";
                AssertV2.AreEqual(s1, s1);

                AssertV2.IsTrue(AssertV2.throwExeptionIfAssertionFails, "AssertV2.throwExeptionIfAssertionFails");
                AssertV2.Throws <Exception>(() => { AssertV2.AreNotEqual(s1, s1, "s1"); });

                string myVarX = null;
                AssertV2.IsNull(null, "myVarX");
                myVarX = "Now myVarX is not null anymore";
                AssertV2.Throws <Exception>(() => { AssertV2.IsNull(myVarX, "myVarX"); });

                AssertV2.AreEqual(1, 1);
                AssertV2.Throws <Exception>(() => { AssertV2.AreEqual(1, 2); });

                AssertV2.AreNotEqual(1, 2);
                AssertV2.Throws <Exception>(() => { AssertV2.AreNotEqual(1, 1); });

                var stopWatch = AssertV2.TrackTiming();
                Thread.Sleep(10);
                stopWatch.Stop();
                AssertV2.Throws <Exception>(() => { stopWatch.AssertUnderXms(1); }); // This should always fail

                stopWatch.AssertUnderXms(50);
                AssertV2.IsTrue(stopWatch.IsUnderXms(50), "More time was needed than expected!");
            });
        }