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); }
public void StructTest() { DuckTyping.AllowStaticMembers = true; TestInterface duck = DuckTyping.Implement <TestInterface> (new TestStruct()); Assert.AreEqual(43, duck.Method(40)); }
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)); }
public void InvalidArgTest1() { TestInterface o = null; TestInterface duck1 = DuckTyping.Implement <TestInterface>(o); TestInterface duck2 = (TestInterface)DuckTyping.Implement(typeof(TestInterface), o); }
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); }
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)); }
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(); }
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)); }
public static void Main() { TestInterface testInterface = new TestInterface(); TestDelegates testDelegates = new TestDelegates(); testInterface.StartMenu(); testDelegates.StartMenu(); }
public void TestInterfaceProxy() { TestInterface proxy = (TestInterface)Reflection.DispatchProxy.DispatchProxy.Create(typeof(TestInterface), typeof(Reflection.DispatchProxy.InterfaceProxy)); proxy.TestProp = "test"; Assert.AreEqual(proxy.TestProp, "test"); }
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); } }
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)); }
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)); }
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); }
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)); }
public static void Main() { TestInterface mainMenuInterface = new TestInterface(); mainMenuInterface.Run(); TestDelegates mainMenuDelegates = new TestDelegates(); mainMenuDelegates.Run(); }
public static void Initialize(TestContext ctx) { _interface = new TestInterface(); _app = new CommandLineApplicationBuilder() .RegisterCommand <TestExecute>() .RegisterCommand <TestExecuteAsync>() .RegisterCommand <TestExecuteCancel>() .UsingInterface(_interface) .Build(); }
public static int Main() { Console.WriteLine("test"); TestClass tst = new TestClass(); tst.test("test"); TestInterface ti = (TestInterface)tst; ti.test("test"); return(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); }
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); }
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); }
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"); }
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)); }
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 }
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); }
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); }
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自身接口 }
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 }
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)); }
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); }
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); }
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"); }
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); }
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); }
public TestClass2(TestInterface face) { }
public TestClassWithInterfaceDependencies(TestInterface dependency) { this.dependency = dependency; }
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); }
public OurEventListener(TestInterface.Client client) { myClient = client; }
public void When(TestInterface arg) { }
static void Main() { myInterface Interfaces = new TestInterface(); Interfaces.Read(); }
public static void OutputInterface(TestInterface ti) { ti.TestMethod(); }
public ClassWithInterfaceInConstructor(TestInterface member) { this.member = member; }