private static void Configure() { var services = Injector.StartConsole(new ServiceCollection()); _serviceProvider = services.BuildServiceProvider(true); _starshipService = _serviceProvider.GetService <IStarshipService>(); }
public BaseStarshipServiceTests() { SetupData(); var mockApiClient = new Mock <IApiClient>(); mockApiClient.Setup(x => x.GetAsync <ListResultDto <Starship> >(It.IsAny <string>(), null)).Returns(Task.FromResult(this.starships)); this.StarshipService = new StarshipService(mockApiClient.Object); }
public void Init() { var mappingConfig = AutoMapperConfig.RegisterMappings(); _mapper = mappingConfig.CreateMapper(); _starshipRepositoryMock = new Mock <IStarshipRepository>(); _starshipRepositoryMock.Setup(x => x.GetAllStarshipsAsync()) .Returns(Task.FromResult <IEnumerable <StarshipDetailsWrapper> >(new List <StarshipDetailsWrapper> { new StarshipDetailsWrapper { Name = "Name 1", MgltDistance = "40", Consumables = "15 years" } })) .Verifiable(); _service = new StarshipService(_mapper, _starshipRepositoryMock.Object); }
/// <summary> /// Setup depency injection /// </summary> private static void Bootstrap() { // setup configurations var configuration = new ConfigurationBuilder() .SetBasePath(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)) .AddJsonFile("appsettings.json") .Build(); // setup dependency injection IServiceCollection services = new ServiceCollection(); ConfigureServices(services, configuration); IServiceProvider serviceProvider = services.BuildServiceProvider(); // get instance of starshipService starshipService = serviceProvider.GetService <IStarshipService>(); }
public void TestInitialize() { // Loggers var loggerStarship = Mock.Of <ILogger <StarshipClient> >(); var loggerCharacter = Mock.Of <ILogger <CharacterClient> >(); var loggerFilm = Mock.Of <ILogger <FilmClient> >(); var loggerPlanet = Mock.Of <ILogger <PlanetClient> >(); // Settings var starWarsSettings = Options.Create(new StarWarSettings() { Url = configuration["StarWarSettings:Url"] }); // Clients var httpClient = new HttpClient(); var characterClient = new CharacterClient(httpClient, starWarsSettings, loggerCharacter); var filmClient = new FilmClient(httpClient, starWarsSettings, loggerFilm); var planetClient = new PlanetClient(httpClient, starWarsSettings, loggerPlanet); var starshipClient = new StarshipClient(httpClient, starWarsSettings, loggerStarship); _characterService = new CharacterService(characterClient, planetClient, filmClient); _starshipService = new StarshipService(starshipClient); }
public MainPresenter(IStarshipService starshipService) { this.starshipService = starshipService; this.headerResource = new ResourceManager(typeof(HeaderResource)); this.appResource = new ResourceManager(typeof(ApplicationResource)); }
public Runner(ILogger logger, ICalculator calculator, IStarshipService starshipService) { this.logger = logger; this.calculator = calculator; this.starshipService = starshipService; }
public void Init() { starshipservice = Substitute.For <IStarshipService>(); writer = Substitute.For <IWriter>(); calculator = Substitute.For <IStopsCalculator>(); }
public StopsCalculator(IStarshipService starshipService, IOptions <Settings> settings) { _starshipService = starshipService; _settings = settings.Value; }
public StarshipController(IMediator mediator, IStarshipEventService @event, IStarshipService service) { _mediator = mediator; _event = @event; _service = service; }
public WriteStarshipHandler(IStarshipService service, IMapper mapper) { _service = service; _mapper = mapper; }
public StarshipApp(IStarshipService starshipService) => _starshipService = starshipService;
/// <summary> /// Invoked when an instance is created /// This class instace will be created using the package <see href="https://github.com/simpleinjector/">SimpleInjector</see> /// Parameters will be injected automatically through simple injector DI /// </summary> /// <param name="_starshipservice">Reperesents the service to read starships from the api</param> /// <param name="_writer">Represents the class to write into the console</param> /// <param name="_calculator">Represents the class to calculate measures from the <seealso cref="StarShip"/> Model</param> public Executer(IStarshipService _starshipservice, IWriter _writer, IStopsCalculator _calculator) { this.starshipservice = _starshipservice; this.writer = _writer; this.calculator = _calculator; }
public StarshipServiceTest() { _helper = new Helper(); _starshipService = new StarshipService(_helper); }
public StarshipController(IStarshipService starshipService) { _starshipService = starshipService; }
public StarshipController(ILogger <CharacterController> logger, IStarshipService starshipService, ISearchService searchService) { _logger = logger; _starshipService = starshipService; _searchService = searchService; }
public StarshipServiceTest() { starshipService = new StarshipService(); }
public Executor(IStarshipService starshipService, ICalculator calculator) { this.starshipService = starshipService; this.calculator = calculator; }
public void Setup() { logger = Substitute.For <ILogger>(); calculator = Substitute.For <ICalculator>(); starshipService = Substitute.For <IStarshipService>(); }