Пример #1
0
        public void ByteAndSByteConvertToStringTest()
        {
            byte  val0 = 0;
            byte  val1 = 1;
            sbyte val2 = -1;
            sbyte val3 = 0;
            sbyte val4 = 1;

            val0.CastToString().ShouldBe("0");
            val1.CastToString().ShouldBe("1");
            val2.CastToString().ShouldBe("-1");
            val3.CastToString().ShouldBe("0");
            val4.CastToString().ShouldBe("1");

            val0.CastToString("---").ShouldBe("0");
            val1.CastToString("---").ShouldBe("1");
            val2.CastToString("---").ShouldBe("-1");
            val3.CastToString("---").ShouldBe("0");
            val4.CastToString("---").ShouldBe("1");

            val0.CastToString(NumericConvOptions.ZeroAsEmpty).ShouldBe("0");
            val1.CastToString(NumericConvOptions.ZeroAsEmpty).ShouldBe("1");
            val2.CastToString(NumericConvOptions.ZeroAsEmpty).ShouldBe("-1");
            val3.CastToString(NumericConvOptions.ZeroAsEmpty).ShouldBe("0");
            val4.CastToString(NumericConvOptions.ZeroAsEmpty).ShouldBe("1");

            val0.CastToString(NumericConvOptions.ZeroAsEmpty, "---").ShouldBe("---");
            val1.CastToString(NumericConvOptions.ZeroAsEmpty, "---").ShouldBe("1");
            val2.CastToString(NumericConvOptions.ZeroAsEmpty, "---").ShouldBe("-1");
            val3.CastToString(NumericConvOptions.ZeroAsEmpty, "---").ShouldBe("---");
            val4.CastToString(NumericConvOptions.ZeroAsEmpty, "---").ShouldBe("1");
        }