Ejemplo n.º 1
0
 public void UnitOfWorkWithRefDependency(
     out ISomeDependency param,
     ISomeDependency other)
 {
     _ = other ?? throw new ArgumentNullException();
     throw new NotImplementedException();
 }
Ejemplo n.º 2
0
        public async Task Invoke(HttpContext context)
        {
            ISomeDependency getDependencyFromAspNetCoreHttpContext = context.RequestServices.GetService <ISomeDependency>();

            // do what ever you want using context.Request & context.Response
            await Next.Invoke(context);
        }
Ejemplo n.º 3
0
 public SomeClass(ISomeDependency someDependency)
 {
     if (someDependency == null)
     {
         throw new ArgumentNullException(nameof(someDependency));
     }
     this.someDependency = someDependency;
 }
 public Service(ISomeDependency dep)
 {
     if (dep == null)
     {
         throw new ArgumentNullException("dep");
     }
     this.dep = dep;
 }
        public void AutoData_create_mocks_for_me(ISomeDependency dependency, ISomeOtherDependency otherDependency, ISomeArg exampleArgs, ILog log)
        {
            var sut = new SystemUnderTest(dependency, otherDependency, log);

            sut.MethodToTest(exampleArgs);

            dependency.Received(1).Hello(exampleArgs);
            otherDependency.Received(1).Hello(exampleArgs);
        }
        public async override Task Invoke(IOwinContext context)
        {
            // You've access to asp.net core http context in your owin middlewares, asp.net web api odata controllers, signalr hubs, etc.

            HttpContext aspNetCoreContext = (HttpContext)context.Environment["Microsoft.AspNetCore.Http.HttpContext"];

            // do what ever you want using context.Request & context.Response

            ISomeDependency getDependencyFromAspNetCoreHttpContext = aspNetCoreContext.RequestServices.GetService <ISomeDependency>();
            ISomeDependency getDependencyFromOwinContext           = context.GetAutofacLifetimeScope().Resolve <ISomeDependency>();

            await Next.Invoke(context);
        }
        public AggregateServiceInheritanceFixture()
        {
            _someDependencyMock = new Mock<ISomeDependency>().Object;
            _someOtherDependencyMock = new Mock<ISomeOtherDependency>().Object;

            var builder = new ContainerBuilder();
            builder.RegisterAggregateService<ISubService>();
            builder.RegisterInstance(_someDependencyMock);
            builder.RegisterInstance(_someOtherDependencyMock);
            _container = builder.Build();

            _aggregateService = _container.Resolve<ISubService>();
        }
        public Worker(
            ILogger <Worker> logger,
            ISomeDependency dep,
            IHostApplicationLifetime appLifetime,
            IOptions <WorkerOptions> options)
        {
            _logger  = logger;
            _dep     = dep;
            _options = options.Value;

            appLifetime.ApplicationStarted.Register(OnStarted);
            appLifetime.ApplicationStopping.Register(OnStopping);
            appLifetime.ApplicationStopped.Register(OnStopped);
        }
Ejemplo n.º 9
0
        public void Setup()
        {
            _someDependencyMock      = new Mock <ISomeDependency>().Object;
            _someOtherDependencyMock = new Mock <ISomeOtherDependency>().Object;

            var builder = new ContainerBuilder();

            builder.RegisterAggregateService <ISubService>();
            builder.RegisterInstance(_someDependencyMock);
            builder.RegisterInstance(_someOtherDependencyMock);
            _container = builder.Build();

            _aggregateService = _container.Resolve <ISubService>();
        }
        public AggregateServiceFixture()
        {
            _someDependencyMock = new Mock<ISomeDependency>().Object;

            var builder = new ContainerBuilder();
            builder.RegisterAggregateService<IMyContext>();
            builder.RegisterType<MyServiceImpl>()
                .As<IMyService>()
                .InstancePerDependency();
            builder.RegisterInstance(_someDependencyMock);
            _container = builder.Build();

            _aggregateService = _container.Resolve<IMyContext>();
        }
Ejemplo n.º 11
0
        public AggregateServiceFixture()
        {
            _someDependencyMock = new Mock <ISomeDependency>().Object;

            var builder = new ContainerBuilder();

            builder.RegisterAggregateService <IMyContext>();
            builder.RegisterType <MyServiceImpl>()
            .As <IMyService>()
            .InstancePerDependency();
            builder.RegisterInstance(_someDependencyMock);
            _container = builder.Build();

            _aggregateService = _container.Resolve <IMyContext>();
        }
 public FooWebService(ISomeDependency dependency)
 {
     //this is what you call during your testing
     this.dependency = dependency;
 }
Ejemplo n.º 13
0
 public ReservationsController(ISomeDependency someDependency)
 {
     this.someDependency = someDependency;
 }
Ejemplo n.º 14
0
 public MyServiceImpl(DateTime someDate, int someInt, ISomeDependency someDependency)
 {
     SomeDateValue  = someDate;
     SomeIntValue   = someInt;
     SomeDependency = someDependency;
 }
Ejemplo n.º 15
0
 public MyService(ISomeDependency dependency)
 {
     this.dependency = dependency;
 }
 public MyServiceImpl(string someStringValue, ISomeDependency someDependency)
 {
     SomeStringValue = someStringValue;
     SomeDependency = someDependency;
 }
 public SomeImplementation(ISomeDependency someDependency)
 {
     _someDependency = someDependency;
 }
 public ClassUnderTest(ISomeDependency someRepository, IWebServiceDependency webServiceRepository)
 {
     _someRepository = someRepository;
     _webServiceRepository = webServiceRepository;
 }
Ejemplo n.º 19
0
 public SignalRHub(ISomeDependency someDependency)
 {
 }
Ejemplo n.º 20
0
 public void UnitOfWorkWithRefDependency(ref ISomeDependency param)
 {
     Guard.AgainstNull(param, nameof(param));
     throw new NotImplementedException();
 }
 public SystemUnderTest(ISomeDependency dependency, ISomeOtherDependency otherDependency, ILog log)
 {
     _dependency      = dependency;
     _otherDependency = otherDependency;
     _log             = log;
 }
Ejemplo n.º 22
0
 public DoSomethingWithDependency(ISomeDependency someDependency)
 {
     SomeDependency = someDependency;
 }
Ejemplo n.º 23
0
 public SomeClassMultipleCtors(ISomeDependency someDependency)
 {
 }
Ejemplo n.º 24
0
 public ChangedHandler(
     ISomeDependency someDependency
     )
 {
 }
Ejemplo n.º 25
0
 public ProductsController(ISomeDependency someDependency)
 {
 }
Ejemplo n.º 26
0
 public MultipleConstructorsCommand(ISomeDependency command)
 {
 }
 public SeoncdViewModel(ISomeDependency dependency)
 {
     _injectedDependency = dependency;
 }
Ejemplo n.º 28
0
 public MultipleConstructorsCommand(ILogger logger, ISomeDependency command)
 {
     this.ConstructorType = MostParametersConstructor;
 }
 public MultipleConstructorsCommand(ILogger logger, ISomeDependency command)
 {
     this.ConstructorType = MostParametersConstructor;
 }
Ejemplo n.º 30
0
 public ClassUnderTest(ISomeDependency a, IOtherDependency b)
 {
     this.a = a;
     this.b = b;
 }
 public MultipleConstructorsCommand(ISomeDependency command)
 {
 }
Ejemplo n.º 32
0
 public SampleAspNetCoreController(ISomeDependency someDependency)
 {
     _someDependency = someDependency;
 }
Ejemplo n.º 33
0
 public MyFunctions(ISomeDependency dependency)
 {
     _dependency = dependency;
 }
Ejemplo n.º 34
0
 /// <summary>
 /// Needs both - IService as well as a dependency instance.
 /// Should not be a problem, since IService instance has been pre-resolved and should be already available in Autofac lifetime scope -
 /// should be simple passing of that IService instance, as well as using same IService instance when creating an instance of ISomeDependency
 /// </summary>
 public MyWorker(IService service, ISomeDependency dependency)
 {
     this.service    = service;
     this.dependency = dependency;
 }
Ejemplo n.º 35
0
 public MonkeyController(ISomeDependency someDependency)
 {
     _someDependency = someDependency;
 }
 public MyServiceImpl(DateTime someDate, int someInt, ISomeDependency someDependency)
 {
     SomeDateValue = someDate;
     SomeIntValue = someInt;
     SomeDependency = someDependency;
 }
 public SomeImplementation(ISomeDependency someDependency)
 {
     _someDependency = someDependency;
 }
 public MyService()
 {
     this.dependency = kernel.Get <ISomeDependency>();
 }
Ejemplo n.º 39
0
 public MyServiceImpl(string someStringValue, ISomeDependency someDependency)
 {
     SomeStringValue = someStringValue;
     SomeDependency  = someDependency;
 }