Пример #1
0
        private static void Configure()
        {
            var services = Injector.StartConsole(new ServiceCollection());

            _serviceProvider = services.BuildServiceProvider(true);
            _starshipService = _serviceProvider.GetService <IStarshipService>();
        }
Пример #2
0
        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);
        }
Пример #3
0
        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);
        }
Пример #4
0
        /// <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>();
        }
Пример #5
0
        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);
        }
Пример #6
0
 public MainPresenter(IStarshipService starshipService)
 {
     this.starshipService = starshipService;
     this.headerResource  = new ResourceManager(typeof(HeaderResource));
     this.appResource     = new ResourceManager(typeof(ApplicationResource));
 }
Пример #7
0
 public Runner(ILogger logger, ICalculator calculator, IStarshipService starshipService)
 {
     this.logger          = logger;
     this.calculator      = calculator;
     this.starshipService = starshipService;
 }
Пример #8
0
 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;
 }
Пример #11
0
 public WriteStarshipHandler(IStarshipService service, IMapper mapper)
 {
     _service = service;
     _mapper  = mapper;
 }
Пример #12
0
 public StarshipApp(IStarshipService starshipService) => _starshipService = starshipService;
Пример #13
0
 /// <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;
 }
Пример #16
0
 public StarshipController(ILogger <CharacterController> logger, IStarshipService starshipService, ISearchService searchService)
 {
     _logger          = logger;
     _starshipService = starshipService;
     _searchService   = searchService;
 }
Пример #17
0
 public StarshipServiceTest()
 {
     starshipService = new StarshipService();
 }
Пример #18
0
 public Executor(IStarshipService starshipService, ICalculator calculator)
 {
     this.starshipService = starshipService;
     this.calculator      = calculator;
 }
Пример #19
0
 public void Setup()
 {
     logger          = Substitute.For <ILogger>();
     calculator      = Substitute.For <ICalculator>();
     starshipService = Substitute.For <IStarshipService>();
 }