Exemple #1
0
 private void RegisterFiles(PackageCacherImpl cacher, params string[] keys)
 {
     foreach (var key in keys)
     {
         cacher.RegisterDownloaded(key, 0);
     }
 }
Exemple #2
0
        public void SubscribersTest()
        {
            //Scenario:
            //reserve package name
            //try to get package by first subscriber
            //try to get package by second subscriber
            //register downloaded package

            //the first subscriber should get notification
            //the second subscriber should get notification

            //the third subscriber appears and get package local address
            var reservationKey = "ReservationKey";

            var cacher = new PackageCacherImpl(clearInterval, lifeTime, tempDir);

            var address = cacher.ReserveAddress(reservationKey);

            var firstSubscriberGotPackage = false;

            cacher.Get(reservationKey, (response) => { firstSubscriberGotPackage = true; });

            var secondSubscriberGotPackage = false;

            cacher.Get(reservationKey, (response) => { secondSubscriberGotPackage = true; });

            cacher.RegisterDownloaded(reservationKey, 0);

            var thirdSubscriberGotPackage = false;

            cacher.Get(reservationKey, (response) => { thirdSubscriberGotPackage = true; });

            Assert.IsTrue(firstSubscriberGotPackage);

            Assert.IsTrue(secondSubscriberGotPackage);

            Assert.IsTrue(thirdSubscriberGotPackage);
        }