コード例 #1
0
        protected override void Given()
        {
            instance = MockRepository.GenerateStub<TestInterface>();

            instance.Expect(
                x => x.BeginMethod(
                        Arg<string>.Is.Anything,
                        Arg<AsyncCallback>.Is.Anything,
                        Arg<object>.Is.Anything))
                    .Return(null)
                    .WhenCalled(x => ((AsyncCallback)x.Arguments[1])(null));

            instance.Expect(x => x.EndMethod(null))
                    .Throw(exception);

            instance.Expect(
                x => x.BeginFunction(
                        Arg<string>.Is.Anything,
                        Arg<AsyncCallback>.Is.Anything,
                        Arg<object>.Is.Anything))
                    .Return(null)
                    .WhenCalled(x => ((AsyncCallback)x.Arguments[1])(null));

            instance.Expect(x => x.EndFunction(null))
                    .Throw(exception);

            command = new AsyncCommand(() => instance.Method(null), true);
            query = new AsyncQuery<string>(() => instance.Function(null), true);
        }
コード例 #2
0
        public void StructTest()
        {
            DuckTyping.AllowStaticMembers = true;
            TestInterface duck = DuckTyping.Implement <TestInterface> (new TestStruct());

            Assert.AreEqual(43, duck.Method(40));
        }
コード例 #3
0
        protected override void Given()
        {
            instance = MockRepository.GenerateStrictMock <TestInterface>();
            ar       = MockRepository.GenerateStub <IAsyncResult>();

            instance.Expect(
                x => x.BeginMethod(
                    Arg <string> .Is.Equal(parameter),
                    Arg <AsyncCallback> .Is.NotNull,
                    Arg <object> .Is.Null))
            .Return(null)
            .WhenCalled(x => ((AsyncCallback)x.Arguments[1])(ar));

            instance.Expect(x => x.EndMethod(ar));

            instance.Expect(
                x => x.BeginFunction(
                    Arg <string> .Is.Equal(parameter),
                    Arg <AsyncCallback> .Is.NotNull,
                    Arg <object> .Is.Null))
            .Return(null)
            .WhenCalled(x => ((AsyncCallback)x.Arguments[1])(ar));

            instance.Expect(x => x.EndFunction(ar)).Return(result);

            command = new AsyncPatternCommand(() => instance.Method(parameter));
            query   = new AsyncPatternQuery <string>(() => instance.Function(parameter));
        }
コード例 #4
0
        public void InvalidArgTest1()
        {
            TestInterface o = null;

            TestInterface duck1 = DuckTyping.Implement <TestInterface>(o);
            TestInterface duck2 = (TestInterface)DuckTyping.Implement(typeof(TestInterface), o);
        }
コード例 #5
0
        protected override void Given()
        {
            instance = MockRepository.GenerateStrictMock<TestInterface>();
            ar = MockRepository.GenerateStub<IAsyncResult>();

            instance.Expect(
                x => x.BeginMethod(
                        Arg<string>.Is.Equal(parameter),
                        Arg<AsyncCallback>.Is.NotNull,
                        Arg<object>.Is.Null))
                    .Return(null)
                    .WhenCalled(x => ((AsyncCallback)x.Arguments[1])(ar));

            instance.Expect(x => x.EndMethod(ar));

            instance.Expect(
                x => x.BeginFunction(
                        Arg<string>.Is.Equal(parameter),
                        Arg<AsyncCallback>.Is.NotNull,
                        Arg<object>.Is.Null))
                    .Return(null)
                    .WhenCalled(x => ((AsyncCallback)x.Arguments[1])(ar));

            instance.Expect(x => x.EndFunction(ar)).Return(result);

            command = new AsyncCommand(() => instance.Method(parameter), true);
            query = new AsyncQuery<string>(() => instance.Function(parameter), true);
        }
コード例 #6
0
        public void Test()
        {
            TestInterface  duck  = DuckTyping.Implement <TestInterface> (new TestClass());
            TestInterface  same  = DuckTyping.Implement <TestInterface> (duck);
            TestInterface2 duck2 = DuckTyping.Implement <TestInterface2>(same);

            Assert.AreSame(duck, same);

            int value;

            duck.Method(33, out value);

            Assert.AreEqual(33, value);
            Assert.AreEqual(42, duck.Method(40));
            Assert.AreEqual(22, duck.Prop);

            duck.Event += duck_Event;

            duck.CallEvent();

            Assert.AreEqual(55, eventValue);

            duck2.I2Method(33, out value);

            Assert.AreEqual(33, value);
            Assert.AreEqual(42, duck2.Method(40));
        }
コード例 #7
0
        static void Main(string[] args)
        {
            Console.Write("Enter name (Player1/Player2): ");
            string     name    = Console.ReadLine();
            TcpChannel channel = new TcpChannel();

            ChannelServices.RegisterChannel(channel);
            Type          type = typeof(TestInterface);
            TestInterface ti   = (TestInterface)Activator.GetObject(type,
                                                                    "tcp://localhost:1008/" + name + "");

            if (name == "Player1")
            {
                Console.WriteLine(ti.TestProcedure("Player 1 is online") + name);
            }
            else
            {
                Console.WriteLine(ti.TestProcedure("Player 2 is online") + name);
            }
            bool kt = ti.ban(10, 23, name);

            if (!kt)
            {
                Console.WriteLine("Cho ben kia ban.");
            }
            Console.WriteLine("Xong");
            Console.ReadLine();
        }
コード例 #8
0
        protected override void Given()
        {
            instance = MockRepository.GenerateStub <TestInterface>();

            instance.Expect(
                x => x.BeginMethod(
                    Arg <string> .Is.Anything,
                    Arg <AsyncCallback> .Is.Anything,
                    Arg <object> .Is.Anything))
            .Return(null)
            .WhenCalled(x => ((AsyncCallback)x.Arguments[1])(null));

            instance.Expect(x => x.EndMethod(null))
            .Throw(exception);

            instance.Expect(
                x => x.BeginFunction(
                    Arg <string> .Is.Anything,
                    Arg <AsyncCallback> .Is.Anything,
                    Arg <object> .Is.Anything))
            .Return(null)
            .WhenCalled(x => ((AsyncCallback)x.Arguments[1])(null));

            instance.Expect(x => x.EndFunction(null))
            .Throw(exception);

            command = new AsyncPatternCommand(() => instance.Method(null));
            query   = new AsyncPatternQuery <string>(() => instance.Function(null));
        }
コード例 #9
0
        public static void Main()
        {
            TestInterface testInterface = new TestInterface();
            TestDelegates testDelegates = new TestDelegates();

            testInterface.StartMenu();
            testDelegates.StartMenu();
        }
コード例 #10
0
        public void TestInterfaceProxy()
        {
            TestInterface proxy = (TestInterface)Reflection.DispatchProxy.DispatchProxy.Create(typeof(TestInterface), typeof(Reflection.DispatchProxy.InterfaceProxy));

            proxy.TestProp = "test";

            Assert.AreEqual(proxy.TestProp, "test");
        }
コード例 #11
0
 public void test_against_interface()
 {
     ti = new TestClass() { ID = 1 };
     var q = ctx.GetQuery<ObjectReferenceProperty>().Where(orp => orp.ID == ti.ID);
     foreach (var orp in q)
     {
         Assert.That(orp, Is.Not.Null);
     }
 }
コード例 #12
0
        public void InheritanceTest2()
        {
            TestInterface duck1 = DuckTyping.Implement <TestInterface, TestClass> (new Child1());
            TestInterface duck2 = DuckTyping.Implement <TestInterface, TestClass> (new Child2());

            Assert.AreNotSame(duck1, duck2);
            Assert.AreEqual(42, duck1.Method(40));
            Assert.AreEqual(42, duck2.Method(40));
        }
コード例 #13
0
        protected override void Given()
        {
            instance = MockRepository.GenerateStub <TestInterface>();

            instance.Expect(x => x.Method(null)).Throw(exception);
            instance.Expect(x => x.Function(null)).Throw(exception);

            command = new AsyncCommand(() => instance.Method(null));
            query   = new AsyncQuery <string>(() => instance.Function(null));
        }
コード例 #14
0
        public void MakeShallowCopyTest2()
        {
            TestClass TestObject1 = new TestClass();

            TestObject1.Value = 3;
            TestInterface TestObject2 = TestObject1.MakeShallowCopy <TestInterface>();

            Assert.Equal(TestObject1.Value, TestObject2.Value);
            Assert.Equal(TestObject1.Value2, TestObject2.Value2);
        }
コード例 #15
0
        protected override void Given()
        {
            instance = MockRepository.GenerateStub<TestInterface>();

            instance.Expect(x => x.Method(null)).Throw(exception);
            instance.Expect(x => x.Function(null)).Throw(exception);

            command = new AsyncCommand(()=> instance.Method(null));
            query = new AsyncQuery<string>(()=> instance.Function(null));
        }
コード例 #16
0
        public static void Main()
        {
            TestInterface mainMenuInterface = new TestInterface();

            mainMenuInterface.Run();

            TestDelegates mainMenuDelegates = new TestDelegates();

            mainMenuDelegates.Run();
        }
コード例 #17
0
        public static void Initialize(TestContext ctx)
        {
            _interface = new TestInterface();

            _app = new CommandLineApplicationBuilder()
                   .RegisterCommand <TestExecute>()
                   .RegisterCommand <TestExecuteAsync>()
                   .RegisterCommand <TestExecuteCancel>()
                   .UsingInterface(_interface)
                   .Build();
        }
コード例 #18
0
    public static int Main()
    {
        Console.WriteLine("test");
        TestClass tst = new TestClass();

        tst.test("test");
        TestInterface ti = (TestInterface)tst;

        ti.test("test");
        return(0);
    }
コード例 #19
0
        public void ShouldUseProxyCallbackValueOnMethodWithReferenceTypeReturnValue()
        {
            const string  ReturnValue = "Test string";
            TestInterface proxy       = Proxifier.WithoutBaseClass(new FuncProxyAction((instance, method, args) => {
                return(ReturnValue);
            }))
                                        .WithInterfaces(typeof(TestInterface))
                                        .Build <TestInterface>();
            String result = proxy.MethodWithReferenceTypeReturnValue();

            Assert.Equal(ReturnValue, result);
        }
コード例 #20
0
        public void GetItem_ReturnsProxyClassOfInterface()
        {
            //Assign
            TestInterface inter = null;

            //Act
            inter = _sitecore.GetItem <TestInterface>("/sitecore/content/Glass/Test1");

            //Assert
            Assert.IsNotNull(inter);
            Assert.AreEqual(_test1.ID.Guid, inter.Id);
        }
コード例 #21
0
        public void ShouldUseProxyCallbackValueOnMethodWithValueTypeReturnValue()
        {
            const int     ReturnValue = 1234;
            TestInterface proxy       = Proxifier.WithoutBaseClass(new FuncProxyAction((instance, method, args) => {
                return(1234);
            }))
                                        .WithInterfaces(typeof(TestInterface))
                                        .Build <TestInterface>();
            int result = proxy.MethodWithValueTypeReturnValue();

            Assert.Equal(ReturnValue, result);
        }
コード例 #22
0
        public void ShouldWireCallback()
        {
            bool          proxyCalled = false;
            TestInterface proxy       = Proxifier.WithoutBaseClass(new FuncProxyAction((instance, method, args) => {
                proxyCalled = true;
                return(null);
            }))
                                        .WithInterfaces(typeof(TestInterface))
                                        .Build <TestInterface>();

            proxy.Method();
            Assert.True(proxyCalled, "The proxy callback was not invoked");
        }
コード例 #23
0
        protected override void Given()
        {
            instance = MockRepository.GenerateStrictMock <TestInterface>();

            instance.Expect(x => x.Method(parameter))
            .WhenCalled(x => callThreadId = CurrentThreadId());

            instance.Expect(x => x.Function(parameter)).Return(result)
            .WhenCalled(x => callThreadId = CurrentThreadId());;

            command = new AsyncCommand(() => instance.Method(parameter));
            query   = new AsyncQuery <string>(() => instance.Function(parameter));
        }
コード例 #24
0
        public void TestImplementedBy()
        {
            context.ScannedPackages = new string[] {
                "strange.unittests.annotated.testImplBy"                 //Namespace is the only true difference. Same tests as above for the same action done by a different method
            };
            context.Start();

            TestInterface testImpl = context.injectionBinder.GetInstance <TestInterface>() as TestInterface;

            Assert.IsNotNull(testImpl);
            Assert.IsTrue(typeof(TestInterface).IsAssignableFrom(testImpl.GetType())); //Check that this objects type implements test interface.
            Assert.AreEqual(testImpl.GetType(), typeof(TestImpl));                     //Check that its the type we added below
        }
コード例 #25
0
        public void Interface_DropLinkField()
        {
            //Assign
            TestInterface inter = null;

            //Act
            inter = _sitecore.GetItem <TestInterface>("/sitecore/content/Glass/Test1");

            //Assert
            Assert.IsNotNull(inter);

            Assert.AreEqual(_test1.ID.Guid, inter.DropLink.Id);
        }
コード例 #26
0
        public void Interface_MultiList()
        {
            //Assign
            TestInterface inter = null;

            //Act
            inter = _sitecore.GetItem <TestInterface>("/sitecore/content/Glass/Test1");

            //Assert
            Assert.IsNotNull(inter);

            Assert.AreEqual(_test1.ID.Guid, inter.MultiList.First().Id);
        }
コード例 #27
0
ファイル: HotHelloWorld.cs プロジェクト: qq21/XIL
        static void Start(HelloWorld world)
        {
            UnityEngine.Debug.LogFormat("Hot Start(HelloWorld world)");
            RefType refType = new RefType((object)world);

            refType.GetField <List <string> >("onTexts").Add("HotHelloWorld Start");

            ITestInterface hti = new TestInterface();

            hti.Test();

            __Hotfix_Start.Invoke(world); // 调回HelloWorld.Start自身接口
        }
コード例 #28
0
        public void TestImplementsToInterface()
        {
            context.ScannedPackages = new string[] {
                "strange.unittests.annotated.testImplements"
            };
            context.Start();

            TestInterface testImpl = context.injectionBinder.GetInstance <TestInterface>() as TestInterface;

            Assert.IsNotNull(testImpl);
            Assert.IsTrue(typeof(TestInterface).IsAssignableFrom(testImpl.GetType())); //Check that this objects type implements test interface.
            Assert.AreEqual(testImpl.GetType(), typeof(TestImpl));                     //Check that its the type we added below
        }
コード例 #29
0
        protected override void Given()
        {
            instance = MockRepository.GenerateStrictMock<TestInterface>();

            instance.Expect(x => x.Method(parameter))
                    .WhenCalled(x => callThreadId = CurrentThreadId());

            instance.Expect(x => x.Function(parameter)).Return(result)
                    .WhenCalled(x => callThreadId = CurrentThreadId()); ;

            command = new AsyncCommand(()=> instance.Method(parameter));
            query = new AsyncQuery<string>(()=> instance.Function(parameter));
        }
コード例 #30
0
        public void TestParamsScannedPackages()
        {
            context.Start();
            context.ScanForAnnotatedClasses("strange.unittests.annotated.testConcrete", "strange.unittests.annotated.testImplTwo", "strange.unittests.annotated.testImplBy");

            var testConcrete = context.injectionBinder.GetInstance <TestConcreteClass>();

            Assert.IsNotNull(testConcrete);

            TestInterface testInterface = context.injectionBinder.GetInstance <TestInterface>();

            Assert.True(testInterface is TestImplTwo);
        }
コード例 #31
0
        public void TestImplementsOverridesImplementedBy()
        {
            context.ScannedPackages = new string[] {
                "strange.unittests.annotated.testImplTwo",
                "strange.unittests.annotated.testImplBy",
            };

            context.Start();


            TestInterface testInterface = context.injectionBinder.GetInstance <TestInterface>() as TestInterface;

            Assert.True(testInterface is TestImplTwo);
        }
コード例 #32
0
            public void Run()
            {
                Console.WriteLine($"Expected {CharacterString}");
                var bytes  = ParseEncodedRepresentation();
                var result = TestInterface.DecodeString(SpecificCharacterSets, VR, bytes);

                Console.WriteLine($"     Got {result}");
                if (result != CharacterString)
                {
                    Console.WriteLine($"         Failed");
                    throw new Exception("Actual result differs from expected result");
                }
                Console.WriteLine($"         OK");
            }
コード例 #33
0
        public void ShouldConstruct()
        {
            var container = new Container();

            container.Register <TestInterface, TestClass>(Lifecycle.HttpContextOrExecutionContextLocal);


            TestInterface instance = null;

            Task.Run(() => instance = container.Resolve <TestInterface>()).Wait();

            Assert.IsNotNull(instance);
            Assert.IsInstanceOf <TestClass>(instance);
        }
コード例 #34
0
        public void Interface_Children()
        {
            //Assign
            TestInterface inter = null;

            //Act
            inter = _sitecore.GetItem <TestInterface>("/sitecore/content/Glass/Test1");

            //Assert
            Assert.IsNotNull(inter);

            Assert.AreEqual(_test1.Children.Count, inter.Children.Count());
            Assert.AreEqual(_test3.ID.Guid, inter.Children.First().Id);
        }
コード例 #35
0
ファイル: CustomCtors.cs プロジェクト: trullock/NanoIoC
 public TestClass2(TestInterface face)
 {
 }
コード例 #36
0
		public TestClassWithInterfaceDependencies(TestInterface dependency)
		{
			this.dependency = dependency;
		}
コード例 #37
0
 public void TestResolver()
 {
     Resolver.GetConfigurator().Bind<ITestInterface<long>>().To<TestInterface<long>>().SetRequestResponseScope();
     Resolver.GetConfigurator().Bind<string>().To<string>().SetRequestResponseScope();
     Resolver.GetConfigurator().Bind<Int32>().To<Int32>().SetRequestResponseScope();
     ContainerFactory.Current.Bind(typeof(string),"test",Scope.Context);
     ContainerFactory.Current.Bind(typeof(Int32), 10, Scope.Context);
     var actual = Resolver.Activate<ITestInterface<long>>() as TestInterface<long>;
     var expected = new TestInterface<long>("test", 10);
     Assert.AreEqual(expected.Test, actual.Test);
     Assert.AreEqual(expected.Test2, actual.Test2);
 }
コード例 #38
0
ファイル: QueryTranslatorTests.cs プロジェクト: daszat/zetbox
 public void test_against_interface()
 {
     ti = new TestClass() { ID = 1 };
     var q = ctx.GetQuery<ObjectReferenceProperty>().Where(orp => orp.ID == ti.ID);
     foreach (var orp in q)
     {
         Assert.That(orp, Is.Not.Null);
     }
 }
コード例 #39
0
 public OurEventListener(TestInterface.Client client)
 {
     myClient = client;
 }
コード例 #40
0
        public void When(TestInterface arg)
        {

        }
コード例 #41
0
ファイル: Program.cs プロジェクト: kernkin/CMP-129
 static void Main()
 {
     myInterface Interfaces = new TestInterface();
     Interfaces.Read();
 }
コード例 #42
0
ファイル: Interface.cs プロジェクト: Noob536/LS2Test
 public static void OutputInterface(TestInterface ti)
 {
     ti.TestMethod();
 }
コード例 #43
0
 public ClassWithInterfaceInConstructor(TestInterface member)
 {
     this.member = member;
 }