public void ReturnParameterWithValidationAndParameterFromService([ThingParameter(Minimum = 0, Maximum = 100)] int value, [FromServices] ISomething logger) { logger.DoSomething(); Values.AddLast(value.ToString()); Values.AddLast(nameof(ReturnParameterWithValidationAndParameterFromService)); }
public void TestOverrideReturnValue() { //Create and mock the interceptor. MockRepository mock = new MockRepository(); IAspect hmock = mock.StrictMock <IAspect>(); Expect.Call(hmock.PreCall(null)) .Return(MethodVoteOptions.Continue) .IgnoreArguments(); hmock.PostCall(null, null); LastCall.Callback(delegate(CastleIInvocation ii, AspectReturnValue retval) { retval.WrappedReturnValue = "1234567890"; return(retval.Original.Equals("12")); }); mock.ReplayAll(); using (TestContainer container = new TestContainer(@"Concrete\Castle\AOP\TestSuite1\Configs\ConfigSample2.config")) { //Set the mock into the kernel. container.Kernel.RemoveComponent("interceptor"); container.Kernel.AddComponentInstance("interceptor", hmock); ISomething something = container.Resolve <ISomething>(); String retvalue = something.OtherMethod("1", "2"); Assert.That(retvalue, Is.EqualTo("1234567890")); } mock.VerifyAll(); }
public void SetUp() { _fluentSomething = Substitute.For<IFluentSomething>(); _something = Substitute.For<ISomething>(); _fluentSomething.ReturnsForAll<IFluentSomething>(_fluentSomething); _fluentSomething.ReturnsForAll<ISomething>(_something); }
private static void TryInterface(ISomething smth) { VT vt = new VT(11, "11"); smth.DoSomething(new VT(0, "-"), ref vt); vt = smth.RetSomething(vt); Console.WriteLine("Got : " + vt.ToString()); }
public void TestIgnoreExeptionReturnValue() { //Create and mock the interceptor. MockRepository mock = new MockRepository(); IAspect hmock = mock.StrictMock <IAspect>(); Expect.Call(hmock.PreCall(null)) .Return(MethodVoteOptions.Continue) .IgnoreArguments(); Expect.Call(() => hmock.PostCall(null, null)) .IgnoreArguments(); Expect.Call(() => hmock.OnException(null, null, null)) .Callback(delegate(CastleIInvocation ii, Exception e, AspectExceptionAction action) { action.IgnoreException = true; return(true); }); mock.ReplayAll(); using (TestContainer container = new TestContainer(@"Concrete\Castle\AOP\TestSuite1\Configs\ConfigSample2.config")) { //Set the mock into the kernel. container.Kernel.RemoveComponent("interceptor"); container.Kernel.AddComponentInstance("interceptor", hmock); ISomething something = container.Resolve <ISomething>("throwclass"); String retvalue = something.OtherMethod("1", "2"); Assert.That(retvalue, Is.Null); //Default value is returned } mock.VerifyAll(); }
public void TestMultiplePointCut() { //Create and mock the interceptor. MockRepository mock = new MockRepository(); IAspect hmock = mock.CreateMock <IAspect>(); Expect.Call(hmock.PreCall(null)) .Repeat.Twice() .Return(MethodVoteOptions.Continue) .IgnoreArguments(); Expect.Call(() => hmock.PostCall(null, null)) .Repeat.Twice() .IgnoreArguments(); mock.ReplayAll(); using (TestContainer container = new TestContainer(@"Concrete\Castle\AOP\TestSuite1\Configs\ConfigSample3.config")) { //Set the mock into the kernel. container.Kernel.RemoveComponent("interceptor"); container.Kernel.AddComponentInstance("interceptor", hmock); ISomething something = container.Resolve <ISomething>(); something.AMethod("TEST"); something.OtherMethod("1", "2"); } mock.VerifyAll(); }
public void SetUp() { _fluentSomething = Substitute.For <IFluentSomething>(); _something = Substitute.For <ISomething>(); _fluentSomething.ReturnsForAll <IFluentSomething>(_fluentSomething); _fluentSomething.ReturnsForAll <ISomething>(_something); }
public void DoSomething() { ISomething s = _somethingFactory.MakeSomething(); int i = s.Run(); //do things with i that I want to test }
public void TestBasicInterception() { using (IWindsorContainer container = new WindsorContainer(@"Concrete\Castle\AOP\TestSuite1\Configs\ConfigSample1.config")) { ISomething someth = container.Resolve <ISomething>(); someth.AMethod("Test"); someth.OtherMethod("Test", "otherTEst"); } }
public TestClassWithInterface(TestClass testClass, ISomething something, string text, int value) { _testClass = testClass; _something = something; _text = text; _value = value; }
public void TestTestContainerBasic() { TestContainer container = new TestContainer(@"Concrete\Castle\AOP\HelperClasses\ConfigSample1.config"); SomeClass sc = new SomeClass(); ISomething smth = container.Resolve <ISomething>(); Assert.AreNotEqual(sc, smth); container.AddServiceOverride(typeof(ISomething), sc); Assert.AreEqual(sc, container.Resolve <ISomething>()); }
private void TestLogAspect(ISomething something, Record record) { m_Bus.SubscribeAsync <StatusMessage>(GetType().FullName, StatusHandler); something.DoSomething(""); m_Logger.Debug("Augment 10 returns {0}".Inject(something.Augment(10))); something.DoSomething(record); }
public TestClassTwoConstructors(TestClass testClass, ISomething something, string text, int value) { _testClass = testClass; _something = something; _text = text; _value = value; }
public static ISomething Instance() { lock (privateObject) { if (privateObject == null) { privateObject = new Class1(); } } return(privateObject); }
public void TestMethod1() { ServiceDomain.Enter(new ServiceConfig()); ISomething something = MockRepository.Mock <ISomething>(); something.VerifyAllExpectations(); ContextUtil.SetAbort(); ServiceDomain.Leave(); }
public void TestMethod1() { ServiceDomain.Enter(new ServiceConfig()); MockRepository mocks = new MockRepository(); ISomething something = (ISomething)mocks.StrictMock(typeof(ISomething)); mocks.ReplayAll(); mocks.VerifyAll(); ContextUtil.SetAbort(); ServiceDomain.Leave(); }
public static ISomething Instance(int param) { lock (privateObject) { if (privateObject == null) { privateObject = FactoryClass.CreationObject(param); } } return(privateObject); }
private static long TimeInterface(int count, ISomething test) { var sw = Stopwatch.StartNew(); for (int i = 0; i < count; i++) { test.InterfaceMethod(); } sw.Stop(); return(sw.ElapsedMilliseconds); }
public void TestMethod1() { ServiceDomain.Enter(new ServiceConfig()); ISomething something = MockRepository.Mock <ISomething>(); something.SetUnexpectedBehavior(UnexpectedCallBehaviors.BaseOrDefault); something.VerifyAllExpectations(); ContextUtil.SetAbort(); ServiceDomain.Leave(); }
public TestClassWithInterfaceAndGuard([NotNull] TestClass testClass, [NotNull] ISomething something, [NotNull] string text, int value) : base(testClass, something, text, value) { Guard.ArgumentNotNull(text, nameof(text)); Guard.ArgumentNotNull(testClass, nameof(testClass)); Guard.ArgumentNotNull(something, nameof(something)); }
public static void run() { ClassSomething some = new ClassSomething(); some.doSomething(); some.Num = 123; ISomething some1 = (ISomething)some; some1.doSomething(); some1.Num = 456; ISomething2 some2 = (ISomething2)some; some2.doSomething2(); }
public void DefaultConvention_MostUsualTypes_Registered() { var container = new Container(cfg => cfg .Scan(scanner => { scanner.AssemblyContainingType <AutoWiringTester>(); scanner.WithDefaultConventions(); })); ISomething something = container.TryGetInstance <ISomething>(); // not null since it conforms to default convention Assert.That(something, Is.InstanceOf <Something>()); ISomethingElse somethingElse = container.TryGetInstance <ISomethingElse>(); // null since "NotSomethingElse" is not converered by the default convention Assert.That(somethingElse, Is.Null); }
public TestClass(ISomething something) { Something = something; }
public TestClassTwoConstructors(TestClass testClass, ISomething something) : this(testClass, something, string.Empty, 0) { }
public HomeController(ISomething something) { _something = something; }
public Hello2(ISomething something) { this.something = something; }
public void TearDown() { _something = null; }
public ObjectTakingASomething(ISomething something) { MySomething = something; }
public ParentClass(ISomething something) { this.someVar = something.DoSomething(someVar); }
public Decorator(ISomething innerSomething, string id) { _innerSomething = innerSomething; _id = id; }
private void StatusAspect(ISomething something, Record record) { something.DoSomethingStatus(""); something.DoSomethingStatus(record); }
private void TestPublishExceptionAspect(ISomething something, Record record) { try { m_Bus.SubscribeAsync <ExceptionThrownMessage>(GetType().FullName, ExceptionThrownHandler); something.DoSomethingThrows(record); } catch ( Exception exception ) { m_Logger.Debug("Try/Catch {0}".Inject(exception.Message)); } }
public Subject(ISomething something) { Something = something; }
public void SetUp() { _something = Substitute.For<ISomething>(); }
public void SetSomething <T>(ISomething <T> s) where T : ISomeObject { Something = (ISomething <ISomeObject>)s; }
public SomeClass(ISomething something, string someParam) { _something = something; }
public void SetUp() { _something = Substitute.For <ISomething>(); }
public static System.Reflection.ParameterInfo [] WithInterface([Freeze] ISomething _) { return(Array.Empty <System.Reflection.ParameterInfo> ( )); }
public SomethingDecorator(ISomething <T> decorated) { Decorated = decorated; }
public Pear(ISomething something) { // Please note that this is NOT needed to cause the issue, but will increase the number of times the issue occurs _something = something; }