Exemplo n.º 1
0
        public void QuantityInvalidMissingTest()
        {
            var qd = new QuantDescr <Type>(3);

            qd.SetQuantity(typeof(int), 1);
            qd.SetQuantity(typeof(string), 1);
            var result = qd.Complete();

            Assert.IsInstanceOfType(result, typeof(ResultQuantityError <Type>));
            Assert.AreEqual(1, (result as ResultQuantityError <Type>).Quantity);
        }
Exemplo n.º 2
0
        public void QuantityValidTest()
        {
            var qd = new QuantDescr <Type>(3);

            // Describe a list with two ints and one string.
            qd.SetQuantity(typeof(int), 2);
            qd.SetQuantity(typeof(string), 1);
            var result = qd.Complete();

            Assert.IsInstanceOfType(result, typeof(ResultComplete));
        }
Exemplo n.º 3
0
        public void Mixed1Valid2Test()
        {
            var qd = new QuantDescr <Type>(2);

            qd.SetPosition(1, typeof(int));
            qd.SetPosition(2, typeof(int));
            qd.SetQuantity(typeof(int), 2);
            // Once again, for each quantity condition, a position condition satisfies that.
            var result = qd.Complete();

            Assert.IsInstanceOfType(result, typeof(ResultComplete));
        }
Exemplo n.º 4
0
        public void PositionValidTest()
        {
            var qd = new QuantDescr <Type>(3);

            // Describe a tuple of int, string, double.
            qd.SetPosition(1, typeof(int));
            qd.SetPosition(2, typeof(string));
            qd.SetPosition(3, typeof(double));
            var result = qd.Complete();

            Assert.IsInstanceOfType(result, typeof(ResultComplete));
        }
Exemplo n.º 5
0
        public void PositionInvalidMissingTest()
        {
            var qd = new QuantDescr <Type>(3);

            qd.SetPosition(1, typeof(int));
            qd.SetPosition(2, typeof(string));
            qd.SetPosition(2, typeof(double));
            var result = qd.Complete();

            Assert.IsInstanceOfType(result, typeof(ResultPositionMissing <Type>));
            Assert.AreEqual(3, (result as ResultPositionMissing <Type>).Position);
        }
Exemplo n.º 6
0
        public void Mixed1Valid1Test()
        {
            var qd = new QuantDescr <Type>(2);

            // Describe a list with an int in the first position plus existence of an int
            qd.SetPosition(1, typeof(int));
            qd.SetQuantity(typeof(int), 1);
            // Coexistant position and existence conditions reduce to the position condition only,
            // as satisfying one position for a type satisfies one existence for that type.
            var result = qd.Complete();

            Assert.IsInstanceOfType(result, typeof(ResultComplete));
        }
Exemplo n.º 7
0
        public void Mixed1InvalidMissingTest()
        {
            var qd = new QuantDescr <Type>(2);

            qd.SetPosition(1, typeof(int));
            qd.SetPosition(2, typeof(string));
            qd.SetQuantity(typeof(int), 2);
            // There is a quantity missing (int).
            var result = qd.Complete();

            Assert.IsInstanceOfType(result, typeof(ResultQuantityError <Type>));
            Assert.AreEqual(typeof(int), (result as ResultQuantityError <Type>).Quality);
            Assert.AreEqual(-1, (result as ResultQuantityError <Type>).Quantity);
        }
Exemplo n.º 8
0
        public void QuantityInvalidSizeTest()
        {
            var qd = new QuantDescr <Type>(3);

            Assert.ThrowsException <SizeException>(() => { qd.SetQuantity(typeof(int), 4); });
        }
Exemplo n.º 9
0
        public void PositionInvalidSizeTest()
        {
            var qd = new QuantDescr <Type>(3);

            Assert.ThrowsException <SizeException>(() => { qd.SetPosition(4, typeof(int)); });
        }