Exemplo n.º 1
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!");
        }
Exemplo n.º 2
0
 public Cookie GetCookie(string name, CookieAccessInfo accessInfo)
 {
     if (!cookies.ContainsKey(name))
     {
         return(null);
     }
     for (int index = 0; index < cookies[name].Count; ++index)
     {
         Cookie cookie = cookies[name][index];
         if (cookie.Matches(accessInfo))
         {
             AssertV2.IsTrue(cookie.expirationDate.ToUnixTimestampUtc() > 0, "cookie.expirationDate.toUnixTimestamp()=" + cookie.expirationDate.ToUnixTimestampUtc());
             if (cookie.expirationDate.IsAfter(DateTimeV2.UtcNow))
             {
                 return(cookie);
             }
             else
             {
                 Log.w("Matching but expired cookie found, expirationDate=" + cookie.expirationDate.ToReadableString() + "; cookie=" + cookie);
             }
         }
     }
     return(null);
 }
Exemplo n.º 3
0
 public static Task <ImageResult> LoadImageInBackground(FileEntry imgFile)
 {
     AssertV2.IsTrue(imgFile.Exists, "!imgFile.Exists: " + imgFile);
     return(TaskV2.Run(() => LoadAndDispose(imgFile.Open(FileMode.Open, FileAccess.Read, FileShare.Read))));
 }
Exemplo n.º 4
0
 private static string GetKeyFromBsonDoc(BsonDocument x)
 {
     AssertV2.IsTrue(x.Keys.Any(k => k == "_id"), "No '_id' key found: " + x.Keys.ToStringV2(k => "" + k));
     return(x["_id"].AsString);
 }