public void UnitOfWorkWithRefDependency( out ISomeDependency param, ISomeDependency other) { _ = other ?? throw new ArgumentNullException(); throw new NotImplementedException(); }
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); }
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); }
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>(); }
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; }
public ReservationsController(ISomeDependency someDependency) { this.someDependency = someDependency; }
public MyServiceImpl(DateTime someDate, int someInt, ISomeDependency someDependency) { SomeDateValue = someDate; SomeIntValue = someInt; SomeDependency = someDependency; }
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; }
public SignalRHub(ISomeDependency someDependency) { }
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; }
public DoSomethingWithDependency(ISomeDependency someDependency) { SomeDependency = someDependency; }
public SomeClassMultipleCtors(ISomeDependency someDependency) { }
public ChangedHandler( ISomeDependency someDependency ) { }
public ProductsController(ISomeDependency someDependency) { }
public MultipleConstructorsCommand(ISomeDependency command) { }
public SeoncdViewModel(ISomeDependency dependency) { _injectedDependency = dependency; }
public MultipleConstructorsCommand(ILogger logger, ISomeDependency command) { this.ConstructorType = MostParametersConstructor; }
public ClassUnderTest(ISomeDependency a, IOtherDependency b) { this.a = a; this.b = b; }
public SampleAspNetCoreController(ISomeDependency someDependency) { _someDependency = someDependency; }
public MyFunctions(ISomeDependency dependency) { _dependency = dependency; }
/// <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; }
public MonkeyController(ISomeDependency someDependency) { _someDependency = someDependency; }
public MyService() { this.dependency = kernel.Get <ISomeDependency>(); }