示例#1
0
        public void PurgeUnusedImages_Remove_Only_Unused_Keys_And_Notify()
        {
            var target = new ProjectContainer();
            int count  = 0;

            target.PropertyChanged += (sender, e) =>
            {
                count++;
            };

            var key1 = ProjectContainer.ImageEntryNamePrefix + "image1.jpg";
            var key2 = ProjectContainer.ImageEntryNamePrefix + "image2.jpg";
            var key3 = ProjectContainer.ImageEntryNamePrefix + "image3.jpg";

            target.AddImage(key1, new byte[] { });
            target.AddImage(key2, new byte[] { });
            target.AddImage(key3, new byte[] { });

            var used = ImmutableHashSet.Create(key2);

            target.PurgeUnusedImages(used);

            Assert.Equal(key2, target.Keys.First().Key);
            Assert.Contains(target.Keys, item => item.Key == key2);
            Assert.Equal(4, count);
        }
示例#2
0
        public void PurgeUnusedImages_Remove_All_Keys_And_Notify()
        {
            var target = new ProjectContainer();
            int count  = 0;

            target.PropertyChanged += (sender, e) =>
            {
                count++;
            };

            var key1 = ProjectContainer.ImageEntryNamePrefix + "image1.jpg";
            var key2 = ProjectContainer.ImageEntryNamePrefix + "image2.jpg";
            var key3 = ProjectContainer.ImageEntryNamePrefix + "image3.jpg";

            target.AddImage(key1, new byte[] { });
            target.AddImage(key2, new byte[] { });
            target.AddImage(key3, new byte[] { });

            var used = Enumerable.Empty <string>().ToImmutableHashSet();

            target.PurgeUnusedImages(used);

            Assert.Empty(target.Keys);
            Assert.Equal(4, count);
        }