Example #1
0
        public void TestExplicitNoRef()
        {
            var     expected = 100;
            short   x        = 500;
            short   w        = 35;
            Casting sut      = new Casting();

            sut.Explicit(w, x);

            Assert.False(w == expected);
            Assert.False(x == expected);
        }
Example #2
0
        public void Test_ExplicitNoRef()
        {
            var expected = 100;
            var w        = (short)10;
            var x        = (short)10;
            var sut      = new Casting();

            sut.Explicit(w, x);

            Assert.Equal(expected, w);
            Assert.Equal(expected, x);
        }
Example #3
0
        public void Test_ExplicitOut()
        {
            short x = 10;
            byte  y;
            byte? z;
            var   sut = new Casting();

            sut.Explicit(x, out y, out z);

            Assert.True(y == x);
            Assert.False(z == x);
        }
Example #4
0
        public void Test_ExplicitOut()
        {
            var  x = (short)10;
            byte y;
            byte?z;
            var  sut = new Casting();

            sut.Explicit(x, out y, out z);

            //Assert.IsType<short>(x);
            //Assert.IsType<byte>(y);
            //Assert.IsType<byte?>(z);
            Assert.True(y == x);
            Assert.False(z == x);
        }
Example #5
0
        public void Test_Explicit()
        {
            IEnumerable <byte?> expected = new byte?[2];
            var  x      = (short)10;
            byte y      = 10;
            byte?z      = null;
            var  sut    = new Casting();
            var  actual = sut.Explicit(x);

            //Assert.IsType<short>(x);
            //Assert.IsType<byte?>(actual);
            Assert.True(expected.Count() == actual.Count());
            Assert.True(y == actual.ElementAt(0));
            Assert.False(z == actual.ElementAt(1));
        }
Example #6
0
        public void Test_ExplicitRef()
        {
            //short x = 10;
            //short w = x;
            var   expected = 100;
            var   sut      = new Casting();
            byte  y;
            byte? z;
            short w = 20;
            short x = 30;


            //sut.Explicit(ref w, ref x, out y, out z);
            sut.Explicit(ref w, ref x, out y, out z);

            //Assert.True(w == x);
            Assert.Equal(expected, w);
            Assert.Equal(expected, x);
        }
Example #7
0
        public void TestExplicitOut()
        {
            short expectedX = 10;
            byte  expectedY = 10;
            byte? expectedZ = null;
            short x         = 10;
            byte  y         = 0;
            byte? z         = null;

            Casting sut = new Casting();

            sut.Explicit(x, out y, out z);

            Assert.Equal(x, expectedX);
            Assert.Equal(y, expectedY);
            Assert.Equal(z, expectedZ);
            Assert.IsType <short>(x);
            Assert.IsType <byte>(y);
            Assert.True(z == expectedZ);
        }
Example #8
0
        public void TestExplicit()
        {
            //y should be byte
            //Casting sut1 = new Casting();
            //var sut2 = sut1.Explicit(50);
            var  x = (short)10;
            byte y = 10;
            byte?z = 10;

            IEnumerable <byte?> expected = new byte?[2];
            var sut    = new Casting();
            var actual = sut.Explicit(x);

            Assert.IsType <short>(x);
            Assert.Equal(10, x);
            Assert.IsType <byte?[]>(actual);
            Assert.True(expected.Count() == actual.Count());
            Assert.True(y == actual.ElementAt(0));  //positive test
            Assert.False(z == actual.ElementAt(1)); //negative test
        }
Example #9
0
        public void Test_ExplicitRef()
        {
            var  expected = 100;
            var  w        = (short)10;
            var  x        = (short)10;
            byte y        = 10;
            byte?z        = null;

            var sut = new Casting();

            sut.Explicit(ref w, ref x, out y, out z);

            //Assert.IsType<short>(w);
            //Assert.IsType<short>(x);
            //Assert.IsType<byte>(y);
            //Assert.IsType<byte?>(z);
            Assert.Equal(expected, w);
            Assert.Equal(expected, x);
            Assert.False(z == w);
            Assert.True(y == w);
            Assert.True(w == x);
            Assert.True(x == expected);
        }