Esempio n. 1
0
        public void GetPrimes_NoExistingList_CallsGenerateTo()
        {
            var localTestGenerator = TestGenerator;

            var testCache = new PrimeNumberCache(localTestGenerator);

            testCache.GetPrimesTo(10);

            A.CallTo(() => localTestGenerator.GeneratePrimesTo(A <int> ._)).MustHaveHappened(Repeated.Exactly.Once);
        }
Esempio n. 2
0
        public void GetPrimes_ExisitngList_TargetLess_DoesNotCallGenerator()
        {
            var initialPrimes = new List <int> {
                2, 3, 5, 7, 11
            };
            var localTestGenerator = TestGenerator;

            var testCache = new PrimeNumberCache(initialPrimes, localTestGenerator);

            testCache.GetPrimesTo(5);

            A.CallTo(() => localTestGenerator.GeneratePrimesBetween(A <int> ._, A <int> ._)).MustNotHaveHappened();
            A.CallTo(() => localTestGenerator.GeneratePrimesTo(A <int> ._)).MustNotHaveHappened();
        }
Esempio n. 3
0
        public void GetPrimes_ExistingList_TargetGreater_CallsGenerateBetween()
        {
            var primes = new List <int> {
                2, 3, 5
            };
            var localTestGenerator = TestGenerator;

            var testCache = new PrimeNumberCache(primes, localTestGenerator);

            testCache.GetPrimesTo(10);

            A.CallTo(() => localTestGenerator.GeneratePrimesBetween(A <int> ._, A <int> ._)).MustHaveHappened(Repeated.Exactly.Once);
            A.CallTo(() => localTestGenerator.GeneratePrimesTo(A <int> ._)).MustNotHaveHappened();
        }