Ejemplo n.º 1
0
        public void TestExcludes()
        {
            var entry = new FromToValue <byte>(1, 3);

            entry.Excludes.Add(2);
            entry.Excludes.Add(3);

            Assert.AreEqual(1, entry.Get());
            Assert.AreEqual(1, entry.Get());
            Assert.AreEqual(1, entry.Get());
            Assert.AreEqual(1, entry.Get());

            Assert.IsFalse(entry.ItsValid(0));
            Assert.IsTrue(entry.ItsValid(1));
            Assert.IsFalse(entry.ItsValid(2));
            Assert.IsFalse(entry.ItsValid(3));
        }
Ejemplo n.º 2
0
        public void GetAndValidTest <T>(T from, T to, T invalid)
            where T : IComparable, IEquatable <T>, IComparable <T>
        {
            var entry = new FromToValue <T>
            {
                From = from,
                To   = to
            };

            Assert.IsTrue(from.CompareTo(entry.Get()) <= 0);
            Assert.IsTrue(to.CompareTo(entry.Get()) >= 0);
            Assert.IsFalse(entry.ItsValid(invalid));
            Assert.IsTrue(entry.ItsValid(from));

            entry = new FromToValue <T>(from);

            Assert.AreEqual(from, entry.Get());
            Assert.IsFalse(entry.ItsValid(invalid));
            Assert.IsTrue(entry.ItsValid(from));
        }