示例#1
0
        public void WhenIconSetsHaveDifferentIcons_ShouldHaveDifferentHashCode()
        {
            var iconSet1 = new DependencyIconSet(
                icon: KnownMonikers.AboutBox,
                expandedIcon: KnownMonikers.AboutBox,
                unresolvedIcon: KnownMonikers.AbsolutePosition,
                unresolvedExpandedIcon: KnownMonikers.AbsolutePosition,
                implicitIcon: KnownMonikers.AbsolutePosition,
                implicitExpandedIcon: KnownMonikers.AbsolutePosition);
            var iconSet2 = new DependencyIconSet(
                icon: KnownMonikers.PackageReference,
                expandedIcon: KnownMonikers.AboutBox,
                unresolvedIcon: KnownMonikers.AbsolutePosition,
                unresolvedExpandedIcon: KnownMonikers.AbsolutePosition,
                implicitIcon: KnownMonikers.AbsolutePosition,
                implicitExpandedIcon: KnownMonikers.AbsolutePosition);

            Assert.False(iconSet1.GetHashCode() == iconSet2.GetHashCode());
        }
示例#2
0
        public void WhenIconSetsHaveSameIcons_ShouldBeEqual()
        {
            var iconSet1 = new DependencyIconSet(
                icon: KnownMonikers.AboutBox,
                expandedIcon: KnownMonikers.AboutBox,
                unresolvedIcon: KnownMonikers.AbsolutePosition,
                unresolvedExpandedIcon: KnownMonikers.AbsolutePosition,
                implicitIcon: KnownMonikers.AbsolutePosition,
                implicitExpandedIcon: KnownMonikers.AbsolutePosition);
            var iconSet2 = new DependencyIconSet(
                icon: KnownMonikers.AboutBox,
                expandedIcon: KnownMonikers.AboutBox,
                unresolvedIcon: KnownMonikers.AbsolutePosition,
                unresolvedExpandedIcon: KnownMonikers.AbsolutePosition,
                implicitIcon: KnownMonikers.AbsolutePosition,
                implicitExpandedIcon: KnownMonikers.AbsolutePosition);

            Assert.True(iconSet1.Equals(iconSet2));
        }
        public void GetOrAddIconSet()
        {
            var cache = new DependencyIconSetCache();

            ImageMoniker icon1 = KnownMonikers.AboutBox;
            ImageMoniker icon2 = KnownMonikers.ZoomToggle;

            var iconSet1a = new DependencyIconSet(icon1, icon1, icon1, icon1);
            var iconSet1b = new DependencyIconSet(icon1, icon1, icon1, icon1);

            Assert.Equal(iconSet1a, iconSet1b);
            Assert.NotSame(iconSet1a, iconSet1b);

            Assert.Same(iconSet1a, cache.GetOrAddIconSet(iconSet1a));
            Assert.Same(iconSet1a, cache.GetOrAddIconSet(iconSet1b));
            Assert.Same(iconSet1a, cache.GetOrAddIconSet(icon1, icon1, icon1, icon1));

            var iconSet2 = new DependencyIconSet(icon2, icon2, icon2, icon2);

            Assert.NotEqual(iconSet1a, iconSet2);

            Assert.Same(iconSet2, cache.GetOrAddIconSet(iconSet2));
            Assert.Same(iconSet2, cache.GetOrAddIconSet(icon2, icon2, icon2, icon2));
        }