public WeatherForecastController(ILogger <WeatherForecastController> logger, IServiceOne serviceOne, IServiceTwo serviceTwo, IServiceProvider serviceProvider)
 {
     _logger          = logger;
     _serviceOne      = serviceOne;
     _serviceTwo      = serviceTwo;
     _serviceProvider = serviceProvider;
 }
Пример #2
0
 public ScopesController(IServiceOne testingServiceOne, IServiceTwo testingServiceTwo, ISingleton singleton, IScoped scoped, ITransient transient)
 {
     this.testingServiceOne = testingServiceOne;
     this.testingServiceTwo = testingServiceTwo;
     this.singleton         = singleton;
     this.scoped            = scoped;
     this.transient         = transient;
 }
Пример #3
0
        private void CanMockGenericMethodOnClass(Mock <IParentInterface> mock)
        {
            Mock <IServiceOne> serviceOneMock = Factory.CreateMock <IServiceOne>();
            Mock <IServiceTwo> serviceTwoMock = Factory.CreateMock <IServiceTwo>();

            // That works only with Expect and if the order of calls to Get match the order of the expectations:
            mock.Expects.One.Method(_ => _.Method <IServiceOne>()).WillReturn(serviceOneMock.MockObject);
            mock.Expects.One.Method(_ => _.Method <IServiceTwo>()).Will(Return.Value(serviceTwoMock.MockObject));

            serviceOneMock.Expects.One.Method(_ => _.ServiceOneGetsName()).Will(Return.Value("ServiceOne"));
            serviceTwoMock.Expects.One.Method(_ => _.ServiceTwoSaves()).Will(Return.Value(true));

            // real call now; only works in same order as the expectations
            IServiceOne serviceOne = mock.MockObject.Method <IServiceOne>();
            string      name       = serviceOne.ServiceOneGetsName();

            Assert.AreEqual("ServiceOne", name, "Service one returned wrong name.");

            IServiceTwo serviceTwo = mock.MockObject.Method <IServiceTwo>();
            bool        res        = serviceTwo.ServiceTwoSaves();

            Assert.AreEqual(true, res, "Service two returned wrong boolean value.");
        }
Пример #4
0
 public ValuesController(IServiceOne serviceOne, ILogger <ValuesController> log)
 {
     _serviceOne = serviceOne;
 }
 public ServiceOneController(IServiceOne serviceOne, ILogger <ServiceOne> logger)
 {
     _serviceOne = serviceOne;
     _logger     = logger;
 }
Пример #6
0
 public Controller(IServiceOne service_one, IServiceTwo service_two, ServiceThree service_three)
 {
     ServiceOne   = service_one;
     ServiceTwo   = service_two;
     ServiceThree = service_three;
 }
 public Foo(IServiceOne one, IServiceTwo two, string parameter)
 {
Пример #8
0
 public Controller(IServiceOne service_one, IServiceTwo service_two, ServiceThree service_three)
 {
     ServiceOne = service_one;
     ServiceTwo = service_two;
     ServiceThree = service_three;
 }
 public QuestionController(IServiceOne serviceOne, [KeyFilter("secondX")] IRepositoryX repositoryX)
 {
     _serviceOne  = serviceOne;
     _repositoryX = repositoryX;
 }