Esempio n. 1
0
 private static Transform GetNextChild(Transform parent, int currentIndex, bool loopChildren)
 {
     AssertV2.AreNotEqual(0, parent.childCount);
     if (currentIndex + 1 >= parent.childCount)
     {
         return(loopChildren ? parent.GetChild(0) : null);
     }
     return(parent.GetChild(currentIndex + 1));
 }
Esempio n. 2
0
        public static async Task <ImageResult> LoadAndDispose(Stream stream)
        {
            stream = await stream.CopyToSeekableStreamIfNeeded(disposeOriginalStream : true);

            AssertV2.AreNotEqual(0, stream.Length, "LoadAndDispose: stream.Length");
            var image = ImageResult.FromStream(stream, ColorComponents.RedGreenBlueAlpha);

            stream.Dispose();
            Conversion.stbi__vertical_flip(image.Data, image.Width, image.Height, 4);
            return(image);
        }
Esempio n. 3
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
            });
        }
Esempio n. 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!");
            });
        }
Esempio n. 5
0
        private void CollectTests(IEnumerable <Assembly> assembliesToTest, Dictionary <string, Link> links)
        {
            var allClasses = assembliesToTest.ReduceToUnion(assembly => {
                if (assembly == null)
                {
                    return(new Type[0]);
                }                                             // return emtpy list
                return(assembly.GetExportedTypes());
            });
            var allTests = XunitTestRunner.CollectAllTests(allClasses, (test) => {
                // callback before a test is executed
            });

            AssertV2.AreNotEqual(0, allTests.Count);
            StartCoroutine(ShowAllFoundTests(allTests));
            if (autoRunAllTests)
            {
                links.Get <Text>("ButtonText").text = "Now running " + allTests.Count + " tests..";
            }
            else
            {
                links.Get <Text>("ButtonText").text = "Found " + allTests.Count + " tests (click one to run it)";
            }
        }
Esempio n. 6
0
 // if the client rnd value is below the rollout % this client gets the feature:
 public static async Task <bool> IsEnabled <T>(this T self) where T : IFeatureFlag
 {
     AssertV2.AreNotEqual(0, self.localState.randomPercentage, "localState.randomPercentage");
     return(self.localState.randomPercentage <= self.rolloutPercentage && await self.IsFeatureUnlocked());
 }
Esempio n. 7
0
 // if the client rnd value is below the rollout % this client gets the feature:
 public async Task <bool> IsEnabled()
 {
     AssertV2.AreNotEqual(0, localState.randomPercentage, "localState.randomPercentage");
     return(localState.randomPercentage <= rolloutPercentage && await IsFeatureUnlocked());
 }