コード例 #1
0
        public void TestSwapWithString()
        {
            string first  = "Nancy";
            string second = "Judy";

            NonGenericClass.Swap(ref first, ref second);

            first.Should().Be("Judy");
            second.Should().Be("Nancy");
        }
コード例 #2
0
        public void TestSwapWithInteger()
        {
            int first  = 23;
            int second = 42;

            NonGenericClass.Swap(ref first, ref second);

            first.Should().Be(42);
            second.Should().Be(23);
        }
コード例 #3
0
        public void TestSwapWithObject()
        {
            object first  = new object();
            object second = new object();

            object saveFirst  = first;
            object saveSecond = second;

            NonGenericClass.Swap(ref first, ref second);

            first.Should().Be(saveSecond);
            second.Should().Be(saveFirst);
        }