public void MapFrom_Tests()
        {
            var obj2 = new MyClass2 { TestProp = "Test value" };

            var obj1 = _mapper.Map<MyClass1>(obj2);
            obj1.TestProp.ShouldBe("Test value");
        }
Beispiel #2
0
        public void MapFrom_Tests()
        {
            var obj2 = new MyClass2 { TestProp = "Test value" };

            var obj1 = obj2.MapTo<MyClass1>();
            obj1.TestProp.ShouldBe("Test value");
        }
Beispiel #3
0
    public void SomeMethod() {

        IXyzInterface xyz = null;
        MyClass2 c2 = new MyClass2();

        xyz = c2 as IXyzInterface;
    }
Beispiel #4
0
        public void 自定义序列化测试2()
        {
            var m   = new MyClass2(1, "zzj");
            var str = m.ToJsonString();

            //"x":{"ID":0},"y":100
            Assert.AreEqual("[1,\"zzj\"]", str);
        }
Beispiel #5
0
        public void Map_Null_Existing_Object_Tests()
        {
            MyClass1 obj1 = null;

            var obj2 = new MyClass2 { TestProp = "before map" };
            obj1.MapTo(obj2);
            obj2.TestProp.ShouldBe("before map");
        }
 public MyClass1()
 {
     p = new MyClass2();
     pp = new List<object>();
     pp.Add(new MyClass2());
     pp.Add(new MyClass3());
     pp.Add(new MyClass4());
 }
Beispiel #7
0
        public MyClass()
        {
            this.reader = new StreamReader(@"D:\testfile.txt");

            list    = new MyClass2[2];
            list[0] = new MyClass2();
            list[1] = new MyClass2();
        }
Beispiel #8
0
    static void Main(string[] args)
    {
        MyClass1 c1 = new MyClass1();

        c1.Method1().Method2();
        MyClass2 c2 = new MyClass2();

        c2.Method1().Method2().Method3();
    }
Beispiel #9
0
 public void TestThrowsConst()
 {
     // Test OK.
     Assert.Throws(
         Is.TypeOf <Exception>()
         .And.Message.EqualTo("ErrorCode:9999"),
         () => MyClass2.ThrowException()
         );
 }
Beispiel #10
0
        public void TypeOfGenericTest()
        {
            var t = typeof(List <int>);

            var t2 = new MyClass2 <int>().MyGetType();

            Assert.AreSame(t, t2);
            Assert.AreEqual(t, t2);
        }
Beispiel #11
0
 private static void AssertObjectEquality(MyClass1 class1, MyClass2 class2)
 {
     Assert.Equal(class1.MappedString, class2.MappedString);
     Assert.Equal(class1.MappedNumber, class2.MappedNumber);
     Assert.Equal(class1.MappedGuid.ToString(), class2.MappedGuid);
     Assert.Equal(class1.WrongType1, 0L);
     Assert.Equal(class1.WrongType2, 0L);
     Assert.NotEqual(class1.UnmappedString, class2.UnmappedString);
 }
Beispiel #12
0
        public void ShouldNotBeC2ExceptionTest()
        {
            var c2 = new MyClass2();

            var c1 = new MyClass1 {
                Class2 = c2
            };

            c1.On(x => x.Class2, "c1").Should().Not.Be(c2);
        }
Beispiel #13
0
    public static void MainContrVar()
    {
        IMyContrVarGenIF <Alpha2> AlphaRef = new MyClass2 <Alpha2>();
        IMyContrVarGenIF <Beta2>  BetaRef  = new MyClass2 <Beta2>();
        IMyContrVarGenIF <Beta2>  BetaRef2 = new MyClass2 <Alpha2>(); // контвариантность

        BetaRef.Show(new Beta2());
        BetaRef = AlphaRef;             // контвариантность
        BetaRef2.Show(new Beta2());
    }
Beispiel #14
0
        public void MapFrom_Tests()
        {
            var obj2 = new MyClass2 {
                TestProp = "Test value"
            };

            var obj1 = obj2.MapTo <MyClass1>();

            obj1.TestProp.ShouldBe("Test value");
        }
Beispiel #15
0
        public void IgnoreMap_Tests()
        {
            var obj2 = new MyClass2 {
                TestProp = "Test value", AnotherValue = 42
            };
            var obj3 = _mapper.Map <MyClass3>(obj2);

            obj3.TestProp.ShouldBe("Test value");
            obj3.AnotherValue.ShouldBe(0); //Ignored because of IgnoreMap attribute!
        }
Beispiel #16
0
        public void MapFrom_Tests()
        {
            var obj2 = new MyClass2 {
                TestProp = "Test value"
            };

            var obj1 = _mapper.Map <MyClass1>(obj2);

            obj1.TestProp.ShouldBe("Test value");
        }
Beispiel #17
0
        public void ShouldBeC2Test()
        {
            var c2 = new MyClass2();

            var c1 = new MyClass1 {
                Class2 = c2
            };

            c1.On(x => x.Class2, "c1").Should().Be(c2);
        }
Beispiel #18
0
    static void Main(string[] args)
    {
        MyClass1 t1       = new MyClass1();
        MyClass2 t2       = new MyClass2();
        MyClass1 t1result = t1.Test();

        Console.WriteLine(t1result.ToString());
        MyClass2 t2result = t2.Test();

        Console.WriteLine(t2result.ToString());
    }
Beispiel #19
0
    public static void Main()
    {
        MyClass      mc      = new MyClass();
        MyClass2     mc2     = new MyClass2();
        MyEventClass myEvent = new MyEventClass();

        myEvent.EventName += new MyDelegate(mc.Show);
        myEvent.EventName += new MyDelegate(mc2.Show2);

        myEvent.OnEventName();
    }
        public void Test_3()
        {
            Clock.Provider = new LocalClockProvider();

            var myClass = new MyClass2(new DateTime(2016, 04, 13, 08, 58, 10, 526, Clock.Kind));
            var str = JsonSerializationHelper.SerializeWithType(myClass);
            var result = (MyClass2)JsonSerializationHelper.DeserializeWithType(str);

            result.Date.ShouldBe(new DateTime(2016, 04, 13, 08, 58, 10, 526, Clock.Kind));
            result.Date.Kind.ShouldBe(Clock.Kind);
        }
 // Return true if ob contains the same values as the invoking object.
 public bool SameAs(MyClass2 ob)
 {
     if ((ob.alpha == alpha) & (ob.beta == beta))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
    public Window1()
    {
        // use data context instead of source
        DataContext = this;
        InitializeComponent();
        MyClass2Object = new MyClass2();
        Binding binding = new Binding();

        binding.Path = new PropertyPath("MyClass2Object.StringVar");
        TextBoxFromXaml.SetBinding(TextBox.TextProperty, binding);
    }
Beispiel #23
0
        public void Map_Null_Existing_Object_Tests()
        {
            MyClass1 obj1 = null;

            var obj2 = new MyClass2 {
                TestProp = "before map"
            };

            _mapper.Map(obj1, obj2);
            obj2.TestProp.ShouldBe("before map");
        }
        public void Test_3()
        {
            Clock.Provider = ClockProviders.Local;

            var myClass = new MyClass2(new DateTime(2016, 04, 13, 08, 58, 10, 526, Clock.Kind));
            var str     = JsonSerializationHelper.SerializeWithType(myClass);
            var result  = (MyClass2)JsonSerializationHelper.DeserializeWithType(str);

            result.Date.ShouldBe(new DateTime(2016, 04, 13, 08, 58, 10, 526, Clock.Kind));
            result.Date.Kind.ShouldBe(Clock.Kind);
        }
Beispiel #25
0
    static void Main()
    {
        MyClass  objA = new MyClass();
        MyClass2 objB = new MyClass2();

        Test <MyClass> t1 = new Test <MyClass>(objA);

        t1.Activate();

        //Test<MyClass2> t2 = new Test<MyClass2>(objB);
        //t2.Activate();
    }
        public void 测试导出插件()
        {
            var c = new MyClass();

            Assert.IsNotNull(c.Warp);
            Assert.IsNotNull(c.GetGeter);
            Assert.IsNotNull(c.GetSeter);
            Assert.IsNotNull(c.GetCaller);

            var d = new MyClass2
            {
                ID   = 1,
                Name = "blqw",
            };

            var t = c.Warp(d.GetType());

            Assert.IsNotNull(t);
            Assert.AreEqual("TypeEx", t.GetType().Name);

            var set = c.GetSeter(d.GetType().GetProperty("ID"));

            Assert.IsNotNull(set);
            set(d, 2);
            Assert.AreEqual(2, d.ID);

            var get = c.GetGeter(d.GetType().GetProperty("ID"));

            Assert.IsNotNull(get);
            Assert.AreEqual(2, get(d));

            var set2 = c.GetSeter(d.GetType().GetField("Name"));

            Assert.IsNotNull(set2);
            set2(d, "blqw2");
            Assert.AreEqual("blqw2", d.Name);

            var get2 = c.GetGeter(d.GetType().GetField("Name"));

            Assert.IsNotNull(get2);
            Assert.AreEqual("blqw2", get2(d));

            var cell = c.GetCaller(d.GetType().GetMethod("Call"));

            Assert.IsNotNull(cell);
            Assert.AreEqual(5, cell(d, new object[] { "5" }));


            var cell2 = c.GetCaller(d.GetType().GetMethod("Call2"));

            Assert.IsNotNull(cell);
            Assert.AreEqual(11, cell2(null, new object[] { "10" }));
        }
Beispiel #27
0
    public static bool CheckObjIsInterfaceNo()
    {
        bool   res = false;
        Object obj = new MyClass2();

        foreach (var iteration in Benchmark.Iterations)
        {
            using (iteration.StartMeasurement())
                res = obj is IMyInterface1;
        }
        return(res);
    }
Beispiel #28
0
        public void MapTo_Existing_Object_Tests()
        {
            var obj1 = new MyClass1 { TestProp = "Test value" };

            var obj2 = new MyClass2();
            obj1.MapTo(obj2);
            obj2.TestProp.ShouldBe("Test value");

            var obj3 = new MyClass3();
            obj2.MapTo(obj3);
            obj3.TestProp.ShouldBe("Test value");
        }
 public static bool TryParse(string s, MyClass2 result)
 {
     try
     {
         result.Prop = int.Parse(s);
         return(true);
     }
     catch
     {
         return(false);
     }
 }
        public void Core_Object_Fill()
        {
            var testItem  = new MyClass1();
            var fillItem1 = new MyClass2();
            var fillItem2 = new MyClass3();

            fillItem1.Fill(testItem);
            fillItem2.Fill(testItem);
            Assert.IsTrue(testItem.MyProperty == fillItem1.MyProperty);
            Assert.IsTrue(testItem.MyProperty == fillItem2.MyProperty);
            Assert.IsTrue(testItem.MyProperty != new MyClass2().MyProperty);
        }
Beispiel #31
0
        public void MapShouldSetNullExistingObjectTests()
        {
            MyClass1 obj1 = new MyClass1 {
                TestProp = null
            };
            var obj2 = new MyClass2 {
                TestProp = "before map"
            };

            mapper.Map(obj1, obj2);
            obj2.TestProp.ShouldBe(null);
        }
Beispiel #32
0
        static void Main(string[] args)
        {
            MyClass1 c1 = new MyClass1();

            Console.WriteLine(c1.Namespace);
            MyClass2 c2  = new MyClass2();
            MyClass2 c21 = new MyClass2();
            MyClass2 c22 = new MyClass2();
            MyClass2 c23 = new MyClass2();

            Console.WriteLine(c2.Namespace);
        }
Beispiel #33
0
    public static bool CheckArrayIsInterfaceNo()
    {
        bool res = false;

        Object[] arr = new MyClass2[5];
        foreach (var iteration in Benchmark.Iterations)
        {
            using (iteration.StartMeasurement())
                res = arr is IMyInterface1[];
        }
        return(res);
    }
Beispiel #34
0
        public void Map_Should_Set_Null_Existing_Object_Tests()
        {
            MyClass1 obj1 = new MyClass1 {
                TestProp = null
            };
            var obj2 = new MyClass2 {
                TestProp = "before map"
            };

            obj1.MapTo(obj2);
            obj2.TestProp.ShouldBe(null);
        }
Beispiel #35
0
    static void Main(string[] args)
    {
        MyClass  A  = new MyClass("Первый объект MyClass");
        MyClass  B  = new MyClass("Второй объект MyClass");
        MyClass2 A2 = new MyClass2();

        A.Event += A2.Method;
        B.Event += A2.Method;
        A.Start();
        B.Start();
        Console.ReadKey();
    }
Beispiel #36
0
        public CH0801()
        {
            MyClass mc = new MyClass();

            Show(mc);

            It it = null;
            //Show(it);  不满足new约束

            MyClass2 mc2 = new MyClass2();

            Show2(mc2); //约束传入的泛型类型只能是 MyClass2
        }
Beispiel #37
0
        public void Should_match_be_possible_to_reuse_part_of_the_chain(
            MyClass2 instance)
        {
            var m = Switch.Match<object, int>()
                .Case((MyClass c) => 1);

            var m1 = m
                .Case((MyClass2 c) => 2)
                .Case((MyClass3 c) => 3);

            Assert.Equal(2, m1.ValueOf(instance));

            Assert.Equal(-2, m
                .Case((MyClass2 c) => -2)
                .Case((MyClass3 c) => -3).ValueOf(instance));

            Assert.Equal(2, m1.ValueOf(instance));
        }
    public static void Main()
    {
        object[] myObjects = new object[6]; /* test comment 1 */
        myObjects[0] = new MyClass1();
        myObjects[1] = new MyClass2();
        myObjects[2] = "hello";
        myObjects[3] = 123;
        myObjects[4] = 123.4;
        myObjects[5] = null;

        for (int i = 0; i < myObjects.Length; ++i)
        {/* loop it */
            string s = myObjects[i] as string;
            Console.Write("{0}:", i);
            if (s != null)
                Console.WriteLine("'" + s + "'");
            else
                Console.WriteLine("not a string");
        }
    }
Beispiel #39
0
    public bool PosTest3()
    {
        bool retVal = true;

        TestLibrary.TestFramework.BeginScenario("PosTest3: The generic type is custom type");

        try
        {
            MyClass2 myclass1 = new MyClass2('h');
            MyClass2 myclass2 = new MyClass2('=');
            MyClass2 myclass3 = new MyClass2('&');
            MyClass2[] mc = new MyClass2[3] { myclass1, myclass2, myclass3 };
            List<MyClass2> listObject = new List<MyClass2>(mc);
            MyClass myClass = new MyClass();
            Action<MyClass2> action = new Action<MyClass2>(myClass.deletevalue);
            listObject.ForEach(action);
            for (int i = 0; i < 3; i++)
            {
                if (mc[i].value != null)
                {
                    TestLibrary.TestFramework.LogError("005", "The result is not the value as expected,sum is: " + myClass.sum);
                    retVal = false;
                }
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("006", "Unexpected exception: " + e);
            retVal = false;
        }

        return retVal;
    }
 public MyClass1(MyClass2 obj)
 {
 }
Beispiel #41
0
 public static void Function(MyClass2 i)
 {
 }
 public void Test_ConvertTo_WhenDestinationTypeIsSuperTypeOfSourceType_ShouldReturnValueUnchanged()
 {
     //---------------Set up test pack-------------------
     MyClass2 value = new MyClass2();
     //---------------Assert Precondition----------------
     //---------------Execute Test ----------------------
     MyClass returnedValue = TypeUtilities.ConvertTo<MyClass>(value);
     //---------------Test Result -----------------------
     Assert.AreSame(value, returnedValue);
 }
 private static void Funny(MyClass c, MyClass2 d)
 {
     d.x = 9;
     c.x = 0;
 }
Beispiel #44
0
 public void deletevalue(MyClass2 mc)
 {
     mc.value = null;
 }
 public void Map_Should_Set_Null_Existing_Object_Tests()
 {
     MyClass1 obj1 = new MyClass1 { TestProp = null };
     var obj2 = new MyClass2 { TestProp = "before map" };
     _mapper.Map(obj1, obj2);
     obj2.TestProp.ShouldBe(null);
 }
Beispiel #46
0
 public void Should_match_the_forth_case(
     MyClass2 instance)
 {
     Assert.Equal(4, MatchFields(instance));
     Assert.Equal(4, MatchProperties(instance));
 }