public void ReturnParameterWithValidationAndParameterFromService([ThingParameter(Minimum = 0, Maximum = 100)] int value,
                                                                  [FromServices] ISomething logger)
 {
     logger.DoSomething();
     Values.AddLast(value.ToString());
     Values.AddLast(nameof(ReturnParameterWithValidationAndParameterFromService));
 }
Пример #2
0
        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();
        }
Пример #3
0
 public void SetUp()
 {
     _fluentSomething = Substitute.For<IFluentSomething>();
     _something = Substitute.For<ISomething>();
     _fluentSomething.ReturnsForAll<IFluentSomething>(_fluentSomething);
     _fluentSomething.ReturnsForAll<ISomething>(_something);
 }
Пример #4
0
 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());
 }
Пример #5
0
        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();
        }
Пример #6
0
        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();
        }
Пример #7
0
 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
    }
Пример #9
0
        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());
        }
Пример #10
0
 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;
 }
Пример #12
0
        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>());
        }
Пример #13
0
        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;
 }
Пример #15
0
 public static ISomething Instance()
 {
     lock (privateObject)
     {
         if (privateObject == null)
         {
             privateObject = new Class1();
         }
     }
     return(privateObject);
 }
Пример #16
0
        public void TestMethod1()
        {
            ServiceDomain.Enter(new ServiceConfig());

            ISomething something = MockRepository.Mock <ISomething>();

            something.VerifyAllExpectations();

            ContextUtil.SetAbort();
            ServiceDomain.Leave();
        }
Пример #17
0
        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();
        }
Пример #18
0
 public static ISomething Instance(int param)
 {
     lock (privateObject)
     {
         if (privateObject == null)
         {
             privateObject = FactoryClass.CreationObject(param);
         }
     }
     return(privateObject);
 }
Пример #19
0
        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);
        }
Пример #20
0
        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));
 }
Пример #22
0
        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();
        }
Пример #23
0
        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;
 }
Пример #27
0
 public Hello2(ISomething something)
 {
     this.something = something;
 }
Пример #28
0
 public void TearDown()
 {
     _something = null;
 }
Пример #29
0
 public ObjectTakingASomething(ISomething something)
 {
     MySomething = something;
 }
Пример #30
0
 public ParentClass(ISomething something)
 {
     this.someVar = something.DoSomething(someVar);
 }
Пример #31
0
 public ObjectTakingASomething(ISomething something)
 {
     MySomething = something;
 }
Пример #32
0
 public Decorator(ISomething innerSomething, string id)
 {
     _innerSomething = innerSomething;
     _id = id;
 }
Пример #33
0
 private void StatusAspect(ISomething something,
                           Record record)
 {
     something.DoSomethingStatus("");
     something.DoSomethingStatus(record);
 }
Пример #34
0
        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));
            }
        }
Пример #35
0
 public Subject(ISomething something)
 {
     Something = something;
 }
Пример #36
0
 public void SetUp()
 {
     _something = Substitute.For<ISomething>();
 }
Пример #37
0
 public void SetSomething <T>(ISomething <T> s) where T : ISomeObject
 {
     Something = (ISomething <ISomeObject>)s;
 }
 public SomeClass(ISomething something, string someParam)
 {
     _something = something;
 }
Пример #39
0
 public void SetUp()
 {
     _something = Substitute.For <ISomething>();
 }
 public static System.Reflection.ParameterInfo [] WithInterface([Freeze] ISomething _)
 {
     return(Array.Empty <System.Reflection.ParameterInfo> ( ));
 }
Пример #41
0
 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;
 }