コード例 #1
0
        private static void TestInterfaceWithBuildInMethod()
        {
            var theClass = new ClassWithMethod();

            var castClass = (InterfaceWithMethod)theClass;

            var value = castClass.Equals(castClass);

            Assert(true, value);
        }
コード例 #2
0
        private static void TestInterfaceWithMethod()
        {
            var theClass = new ClassWithMethod();

            var castClass = (InterfaceWithMethod)theClass;

            var value = castClass.Method("str");

            Assert("strX", value);
        }
コード例 #3
0
ファイル: MainTests.cs プロジェクト: MixolydianBY/MEFLight
        private void DelegateHasImportedSuccessfully()
        {
            string testString = "Hello!";

            Assert.IsTrue(TestMethodFunc != null);

            ClassWithMethod initializedObj = TestMethodFunc.Invoke(testString);

            Assert.IsTrue(initializedObj.Data.Equals(testString));
        }
コード例 #4
0
        public async Task InvokeMethod_Invokes_Underlying_Async_Method()
        {
            //arrange.
            var target = new ClassWithMethod();
            var sut    = MethodInfoWrapper.FromMethodInfo(target.GetType().GetMethod(nameof(ClassWithMethod.MethodToCallAsync)), target);

            //act.
            await sut.InvokeMethodAsync(null);

            //assert.
            Assert.True(target.Called);
        }
コード例 #5
0
        public void GetMethodName_Returns_Wrapped_Method_Name()
        {
            //arrange.
            var target = new ClassWithMethod();
            var sut    = MethodInfoWrapper.FromMethodInfo(target.GetType().GetMethod(nameof(ClassWithMethod.MethodToCall)), target);

            //act.
            var name = sut.GetMethodName();

            //assert.
            Assert.Equal(nameof(ClassWithMethod.MethodToCall), name);
        }
コード例 #6
0
        public void IsSameAs_Identifies_Similar_Instances()
        {
            //arrange.
            var target = new ClassWithMethod();
            var sut    = MethodInfoWrapper.FromMethodInfo(target.GetType().GetMethod(nameof(ClassWithMethod.MethodToCall)), target);
            var other  = MethodInfoWrapper.FromMethodInfo(target.GetType().GetMethod(nameof(ClassWithMethod.MethodToCall)), target);

            //act.
            var same = sut.IsSameAs(other) && other.IsSameAs(sut);

            //assert.
            Assert.True(same);
        }
コード例 #7
0
        static void Main(string[] args)
        {
            ClassWithMethod classWithMethod = new ClassWithMethod();

            Console.WriteLine("Enter a number:");
            int x = Convert.ToInt32(Console.ReadLine());

            Console.WriteLine("Enter a second optional number");
            string y = Console.ReadLine();

            if (String.IsNullOrEmpty(y))
            {
                Console.WriteLine(classWithMethod.Method(x));
            }
            else
            {
                int y_int = Convert.ToInt32(y);
                Console.WriteLine(classWithMethod.Method(x, y_int)); // return x/(y+1)
            }
        }