コード例 #1
0
        public void RomComparer_CompareTwoNullObjects_ReturnsEqual()
        {
            object x = null;
            object y = null;

            Assert.Equal(0, RomComparer.GetDefaultComparerForMode(RomComparer.DefaultCompareMode).Compare(x, y));
        }
コード例 #2
0
        public void RomComparer_CompareTwoNonRoms_ThrowsArgumentException()
        {
            var x = new object();
            var y = Array.CreateInstance(typeof(int), 1);

            Assert.Throws <ArgumentException>(() => RomComparer.GetDefaultComparerForMode(RomComparer.DefaultCompareMode).Compare(x, y));
        }
コード例 #3
0
        /// <summary>
        /// Compares the instance to another <see cref="IProgramDescription"/>.
        /// </summary>
        /// <param name="other">The other <see cref="IProgramDescription"/> to compare against.</param>
        /// <returns>If this instance and <paramref name="other"/> are considered equivalent, returns zero. A non-zero value indicates inequality.</returns>
        /// <remarks>Consider implementing the IComparable / IComparer / IEquatable / IEqualityComparer interfaces on ProgramDescription instead?
        /// Deficiency noted here: https://github.com/intvsteve/VINTage/issues/239 </remarks>
        private int CompareToIProgramDescription(IProgramDescription other)
        {
            var result = 1;

            if (other != null)
            {
                // Always use strict comparer.
                result = RomComparer.GetDefaultComparerForMode(RomComparison.Strict).Compare(Rom, ProgramInformation, other.Rom, other.ProgramInformation);
            }
            return(result);
        }
コード例 #4
0
        public void RomComparer_GetDefaultComparerForMode_BehavesAsExpected(RomComparison comparisonMode, RomComparer expectedComparer, bool shouldThrowArgumentException)
        {
            if (shouldThrowArgumentException)
            {
                Assert.Throws <ArgumentException>(() => RomComparer.GetDefaultComparerForMode(comparisonMode));
            }
            else
            {
                var comparer = RomComparer.GetDefaultComparerForMode(comparisonMode);

                Assert.NotNull(comparer);
                Assert.True(object.ReferenceEquals(expectedComparer, comparer));
            }
        }
コード例 #5
0
        public void RomComparer_FirstNullRomSecondNotRom_ThrowsArgumentException()
        {
            var y = new object();

            Assert.Throws <ArgumentException>(() => RomComparer.GetDefaultComparerForMode(RomComparer.DefaultCompareMode).Compare(null, y));
        }