public ShellViewModel(ISomeRepository repository, IConfirmer confirmer) { if (confirmer == null) { throw new ArgumentNullException("confirmer"); } _confirmer = confirmer;
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, ISomeRepository someRepository) { app.UseIISPlatformHandler(); app.Run(async(context) => { await context.Response.WriteAsync($"Hello World from {nameof(someRepository)}!"); }); }
public void DoStuff_GivenStuff_ExpectedStuff() { //Arrange ISomeRepository repository = A.Fake <ISomeRepository>(); ISomeClient client = A.Fake <ISomeClient>(); ISomeLogger logger = A.Fake <ISomeLogger>(); IImprovedSomeService service = new DependencyInjectionMakesUnitTestingSimple.ImprovedSomeService(repository, client, logger); //Act var result = service.DoStuff(); //Assert A.CallTo(() => repository.WriteStuffToDb()).MustHaveHappened(); A.CallTo(() => client.SomeCallToWebService()).MustHaveHappened(); A.CallTo(() => logger.LogStuff()).MustHaveHappened(); Assert.True(result); }
public ImprovedSomeService(ISomeRepository someRepository, ISomeClient someClient, ISomeLogger someLogger) { if (someRepository == null) { throw new ArgumentNullException(nameof(someRepository)); } if (someClient == null) { throw new ArgumentNullException(nameof(someClient)); } if (someLogger == null) { throw new ArgumentNullException(nameof(someLogger)); } this.SomeRepository = someRepository; this.SomeClient = someClient; this.SomeLogger = someLogger; }
public SomeService(ISomeRepository someRepository, IDependency1 dependency1, IDependency2 dependency2) { SomeRepository = someRepository; Dependency1 = dependency1; Dependency2 = dependency2; }
public RepositoryUsingService(ISomeRepository repository, ILogger <RepositoryUsingService> logger) { _repository = repository; _logger = logger; }
public SomeService([BeanReference] ISomeRepository repo) { repo.Init("myConnection"); _repo = repo; }
public SomeService(ISomeRepository iaRepository, IMapper mapper, ILogger <SomeService> logger) { _iaRepository = iaRepository ?? throw new ArgumentNullException(nameof(iaRepository)); _mapper = mapper ?? throw new ArgumentNullException(nameof(mapper)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); }
public SomeService(ISomeRepository repository) { }
public GreeterServiceImpl(ISomeRepository someRepository) { _someRepository = someRepository; }
public SomeController(ISomeRepository repository) { this.repository = repository; }