コード例 #1
0
            public void DummyClassMethod_RequestMustBeCachedButNotRetrievedFromCache()
            {
                ResetConfiguration();

                string id = new Random().Next(0, int.MaxValue).ToString();


                DummyClass firstResult = FindById(id, true);

                Assert.IsFalse(firstResult.GetLastApiResponse().IsFromCache);
            }
コード例 #2
0
            public void DummyClassMethod_RequestMustBeRetrievedFromCacheButItsNotThere()
            {
                ResetConfiguration();

                Random random = new Random();
                string id1    = (random.Next(0, int.MaxValue) - 78).ToString();
                string id2    = (random.Next(0, int.MaxValue) - 3).ToString();

                DummyClass firstResult = FindById(id1, true);

                Thread.Sleep(1000);

                DummyClass notRetrievedFromCacheResult = FindById(id2, true);

                Assert.IsFalse(notRetrievedFromCacheResult.GetLastApiResponse().IsFromCache);
            }
コード例 #3
0
            public void DummyClassMethod_SeveralRequestAreNotRetrievedFromCacheInFirstAttempt()
            {
                ResetConfiguration();

                Random random = new Random();
                string id1    = (random.Next(0, int.MaxValue) - 15).ToString();
                string id2    = (random.Next(0, int.MaxValue) - 666).ToString();
                string id3    = (random.Next(0, int.MaxValue) - 71).ToString();

                DummyClass firstResult  = FindById(id1, true);
                DummyClass secondResult = DummyClass.FindById(id2, true);
                DummyClass thirdResult  = DummyClass.FindById(id3, true);

                Assert.IsFalse(firstResult.GetLastApiResponse().IsFromCache);
                Assert.IsFalse(secondResult.GetLastApiResponse().IsFromCache);
                Assert.IsFalse(thirdResult.GetLastApiResponse().IsFromCache);
            }
コード例 #4
0
            public void DummyClassMethod_SeveralRequestsMustBeCached()
            {
                ResetConfiguration();

                Random random = new Random();
                string id1    = (random.Next(0, int.MaxValue) - 5).ToString();
                string id2    = (random.Next(0, int.MaxValue) - 88).ToString();
                string id3    = (random.Next(0, int.MaxValue) - 9).ToString();

                DummyClass firstResult  = FindById(id1, true);
                DummyClass secondResult = DummyClass.FindById(id2, true);
                DummyClass thirdResult  = DummyClass.FindById(id3, true);

                Thread.Sleep(1000);

                DummyClass firstCachedResult  = DummyClass.FindById(id1, true);
                DummyClass secondCachedResult = DummyClass.FindById(id2, true);
                DummyClass thirdCachedResult  = DummyClass.FindById(id3, true);

                Assert.IsTrue(firstCachedResult.GetLastApiResponse().IsFromCache);
                Assert.IsTrue(secondCachedResult.GetLastApiResponse().IsFromCache);
                Assert.IsTrue(thirdCachedResult.GetLastApiResponse().IsFromCache);
            }