public void PurgeUnusedImages_Remove_Only_Unused_Keys_And_Notify() { var target = new XProject(); int count = 0; target.PropertyChanged += (sender, e) => { count++; }; var key1 = XProject.ImageEntryNamePrefix + "image1.jpg"; var key2 = XProject.ImageEntryNamePrefix + "image2.jpg"; var key3 = XProject.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.Equal(1, target.Keys.Count()); Assert.Equal(4, count); }
public void PurgeUnusedImages_Remove_All_Keys_And_Notify() { var target = new XProject(); int count = 0; target.PropertyChanged += (sender, e) => { count++; }; var key1 = XProject.ImageEntryNamePrefix + "image1.jpg"; var key2 = XProject.ImageEntryNamePrefix + "image2.jpg"; var key3 = XProject.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.Equal(0, target.Keys.Count()); Assert.Equal(4, count); }
public void AddImage_Do_Not_Add_Duplicate() { var target = new XProject(); int count = 0; target.PropertyChanged += (sender, e) => { count++; }; var key = XProject.ImageEntryNamePrefix + "image.jpg"; target.AddImage(key, new byte[] { }); target.AddImage(key, new byte[] { }); Assert.Equal(key, target.Keys.First().Key); Assert.Equal(1, target.Keys.Count()); Assert.Equal(1, count); }
public void GetImage_Returns_Byte_Array() { var project = new XProject(); var key = XProject.ImageEntryNamePrefix + "image.jpg"; var data = new byte[] { 0x12, 0x34, 0x56, 0x78 }; project.AddImage(key, data); var target = project.GetImage(key); Assert.Equal(data, target); }
public void AddImage_Add_Key_And_Notify() { var target = new XProject(); string actual = null; target.PropertyChanged += (sender, e) => { actual = e.PropertyName; }; var key = XProject.ImageEntryNamePrefix + "image.jpg"; target.AddImage(key, new byte[] { }); Assert.Equal(key, target.Keys.First().Key); Assert.Equal(1, target.Keys.Count()); Assert.Equal("Keys", actual); }
public void RemoveImage_Remove_Key_And_Notify() { var target = new XProject(); int count = 0; target.PropertyChanged += (sender, e) => { count++; }; var key = XProject.ImageEntryNamePrefix + "image.jpg"; target.AddImage(key, new byte[] { }); target.RemoveImage(key); Assert.Equal(0, target.Keys.Count()); Assert.Equal(2, count); }