Esempio n. 1
0
        public void Method_ExpressionBodied_Test()
        {
            //1
            Check.That(ExpressionBodied(10)).IsEqualTo(20);
            //2
            var instance = new CSharp6Class();

            instance.ExpressionBodied("un message");
            Check.That(instance.Recorder).IsEqualTo("un message");
        }
Esempio n. 2
0
        public void Constructor_Test()
        {
            //1 : Constructor : Object initializer
            var cSharp6Class = new CSharp6Class {
                Version = 6, DateSortie = new DateTime(2015, 1, 1)
            };

            Check.That(cSharp6Class.DateSortie).IsInSameYearAs(new DateTime(2015, 12, 12));
            Check.That(cSharp6Class.Version).IsEqualTo(6);

            //2 : Constructor : Optional parameters & params
            var cSharp6Class2 = new CSharp6Class(date: new DateTime(2015, 1, 1), name: "C#6");

            Check.That(cSharp6Class2.DateSortie).IsEqualTo(new DateTime(2015, 1, 1));
            Check.That(cSharp6Class2.Version).IsEqualTo(6);
            Check.That(cSharp6Class2.Name).IsEqualTo("C#6");
        }
Esempio n. 3
0
        public void Methods_Test()
        {
            //default values
            var cSharp6Class = new CSharp6Class();

            cSharp6Class.MethodWithDefaultValues();
            Check.That(cSharp6Class.Param1).IsEqualTo("param1 default value");
            Check.That(cSharp6Class.Param2).IsEqualTo("param2 default value");
            Check.That(cSharp6Class.Param3).IsEqualTo("param3 default value");
            Check.That(cSharp6Class.Param4).IsEqualTo("param4 default value");
            //optional parameters
            cSharp6Class.MethodWithOptionalParameter("parameter 0", "parameter 1");
            Check.That(cSharp6Class.Param0).IsEqualTo("parameter 0");
            Check.That(cSharp6Class.Param1).IsEqualTo("parameter 1");
            Check.That(cSharp6Class.Param2).IsEqualTo("param2 default value");
            Check.That(cSharp6Class.Param3).IsEqualTo("param3 default value");
            Check.That(cSharp6Class.Param4).IsEqualTo("param4 default value");
            //named parameters
            cSharp6Class.MethodWithOptionalParameter(param3: "Paramètre 3", param1: "Paramètre 1", param0: "Paramètre 0");
            Check.That(cSharp6Class.Param0).IsEqualTo("Paramètre 0");
            Check.That(cSharp6Class.Param1).IsEqualTo("Paramètre 1");
            Check.That(cSharp6Class.Param2).IsEqualTo("param2 default value");
            Check.That(cSharp6Class.Param3).IsEqualTo("Paramètre 3");
            Check.That(cSharp6Class.Param4).IsEqualTo("param4 default value");
            //by reference
            var    point1 = new PointC();
            PointC point2 = cSharp6Class.MethodParameterByRef(ref point1);

            Check.That(point1).IsEqualTo(point2).And.IsNull();
            //by value
            var    point3 = new PointC();
            PointC point4 = cSharp6Class.MethodParameterByValue(point3);

            Check.That(point4).IsNotEqualTo(point3).And.IsNull();
            Check.That(point3).IsNotNull();
            //out : if point5 is not changed by method, then a compilation error is raised
            var point5 = new PointC();

            cSharp6Class.MethodParameterOut(out point5);
            Check.That(point5).IsNull();
        }