Example #1
0
        public void bool2_ToString_PrintPair_ReturnExpectedFormat(
            [Values(false, true)] bool firstArgument,
            [Values(false, true)] bool secondArgument)
        {
            string expectedString = "bool2(" + firstArgument + ", " + secondArgument + ")";
            bool2  testValue      = new bool2(firstArgument, secondArgument);

            Assert.AreEqual(testValue.ToString(), expectedString);
        }
Example #2
0
        public void StringInterop()
        {
            var v = new bool2(false, true);

            var s0 = v.ToString();
            var s1 = v.ToString("#");

            var v0 = bool2.Parse(s0);
            var v1 = bool2.Parse(s1, "#");

            Assert.AreEqual(v, v0);
            Assert.AreEqual(v, v1);

            var b0 = bool2.TryParse(s0, out v0);
            var b1 = bool2.TryParse(s1, "#", out v1);

            Assert.That(b0);
            Assert.That(b1);
            Assert.AreEqual(v, v0);
            Assert.AreEqual(v, v1);

            b0 = bool2.TryParse(null, out v0);
            Assert.False(b0);
            b0 = bool2.TryParse("", out v0);
            Assert.False(b0);
            b0 = bool2.TryParse(s0 + ", 0", out v0);
            Assert.False(b0);

            Assert.Throws <NullReferenceException>(() => { bool2.Parse(null); });
            Assert.Throws <FormatException>(() => { bool2.Parse(""); });
            Assert.Throws <FormatException>(() => { bool2.Parse(s0 + ", 0"); });

            var s2 = v.ToString(";", CultureInfo.InvariantCulture);

            Assert.That(s2.Length > 0);
        }