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); }
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); }
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); }
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); }
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)); }
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); }
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); }
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 }
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); }