private void ConstructBattleService(IHeroRepository heroRepository, IBattleFactory battleFactory) { try { try { _battleService = Activator.CreateInstance(typeof(BattleService), BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public, null, new object[] { battleFactory, heroRepository }, null) as BattleService; } catch (Exception) { _battleService = Activator.CreateInstance(typeof(BattleService), BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public, null, new object[] { heroRepository, battleFactory }, null) as BattleService; } } catch (Exception) { _battleService = null; } Assert.That(_battleService, Is.Not.Null, "Failed to instantiate a BattleService."); }
public FreeToPlayPeriodController( IHeroRepository heroRepository, ICryptographyService cryptographyService) { _heroRepository = heroRepository; _cryptographyService = cryptographyService; }
SuperPowerfulFactory Factoria = new SuperPowerfulFactory();//no implementada en esta versión #endregion #region constructures public SuperPowersfulService(ISuperPowerRepository superPowerRepository, IVillianRepository villianRepository, IHeroRepository heroReposiory) { _superPowerRepository = superPowerRepository; _villianRepository = villianRepository; _heroReposiory = heroReposiory; _flagVillian = ConfigApp.GetFlagForVillian(); }
static void Execute(IHeroRepository repo, string line) { var args = line.Split(" "); var cmd = args[0]; switch (cmd) { case "add": repo.Add(new Hero { Name = args[1], Type = args[2], Attack = UInt32.Parse(args[3]) }); break; case "remove": repo.Remove(args[1]); break; case "find": repo.Find(args[1]); break; case "power": repo.Power(int.Parse(args[1])); break; case "end": break; } }
public HeroService( IHeroRepository heroRepository, IMapper mapper) { _heroRepository = heroRepository; _mapper = mapper; }
public HeroValidator(IHeroRepository repository) { this.repository = repository; RuleFor(hero => hero.Name) .NotEmpty() .MaximumLength(80) .Must(BeUniqueName) .WithMessage("Hero with this name already exists"); RuleFor(hero => hero.AlterEgo).Length(0, 80); RuleFor(hero => hero.Age).GreaterThanOrEqualTo(0); RuleFor(hero => hero.SuperPowers) .Cascade(CascadeMode.StopOnFirstFailure) .NotNull() .Must(HaveOneSuperPower) .WithMessage("Hero should have at least one super power") .SetCollectionValidator(new SuperPowerValidator()); RuleFor(hero => hero.Lair) .Cascade(CascadeMode.StopOnFirstFailure) .NotNull() .Must(BeCorrectLairDetails) .WithMessage("Lair location should be null if LairType is None"); }
public FreeToPlayPeriodPropertiesModelBinder( IHeroRepository heroRepository, ICryptographyService cryptographyService) { _heroRepository = heroRepository; _cryptographyService = cryptographyService; }
public HeroPropertiesModelBinder( IHeroRepository heroRepository, ICryptographyService cryptographyService) { _heroRepository = heroRepository; _cryptographyService = cryptographyService; }
public CreateAndUpdateHeroValidation(IHeroRepository heroRepository, IHeroTypeRepository heroTypeRepository) { var uniqueName = new HeroHasUniqueNameSpecification(heroRepository); var validHeroType = new HeroHasValidHeroTypeSpecification(heroTypeRepository); base.Add("uniqueName", new Rule <Entities.Hero>(uniqueName, "This name was already chosen. Please chose another.")); base.Add("validHeroType", new Rule <Entities.Hero>(validHeroType, "Invalid Hero Type. Please chose another.")); }
public HeroAppServiceTests() { domainNotificationHandler = new DomainNotificationHandler(); this.subNotificationHandler = domainNotificationHandler; this.subHeroRepository = Substitute.For <IHeroRepository>(); this.smartNotification = new SmartNotification(this.subNotificationHandler); this.heroAppService = new HeroAppService(this.smartNotification, this.subHeroRepository); }
public IHttpActionResult GetHero(int id) { var heroes = new IHeroRepository(); if (heroes.Get(id) == null) { return(NotFound()); } return(Ok(heroes.Get(id))); }
public ActionResult <IEnumerable <HeroDto> > GetAllHeros([FromServices] IHeroRepository heroRepository) { var heros = _heroRepository.GetHeroes(); if (!heros.Any()) { return(BadRequest("empty data")); } return(Ok(_mapper.Map <IEnumerable <HeroDto> >(heros))); }
public CommandInterpreter( IHeroRepository heroRepository, IHeroFactory heroFactory, IItemFactory itemFactory, IRecipeFactory recipeFactory) { this.heroRepository = heroRepository; this.heroFactory = heroFactory; this.itemFactory = itemFactory; this.recipeFactory = recipeFactory; }
public HeroController(IHeroRepository repo = null) { if (repo == null) { this.heroRepo = new EFHeroRepository(); } else { this.heroRepo = repo; } }
public static void AddRepository(RepositoryType repositoryType, IHeroRepository repository) { var cachingRepository = new CachingRepository(repository); if (Repositories.ContainsKey(repositoryType)) { Repositories[repositoryType] = cachingRepository; } else { Repositories.Add(repositoryType, cachingRepository); } }
public HeroController(IHeroService heroService, IHeroRepository heroRepository, IHeroIntegrationRepository heroIntegrationRepository, IHqIntegrationRepository hqIntegrationRepository, IMapper mapper, INotificator notificator, IUser user) : base(notificator, user, mapper) { _heroRepository = heroRepository; _heroIntegrationRepository = heroIntegrationRepository; _hqIntergrationRepository = hqIntegrationRepository; _heroService = heroService; _mapper = mapper; }
public static bool ValidateHero(Hero hero, IHeroRepository heroRepository) { if ((hero.Name.Length < 4) || (hero.Name.Length > 20)) { return(false); } foreach (char c in hero.Name.ToArray <char>()) { if (!chars.Contains(c)) { return(false); } } return(true); }
public Hero(IHeroRepository repository, string name) { try { Id = repository.GetAll().LastOrDefault().Id + 1; } catch (ArgumentNullException) { Id = 1; } finally { Name = name; Weapon = CreationServices.GetRandomInt(1, 7); DateOfCreation = DateTime.Now; } }
public void GetAll_ShouldReturnAtLeas3Heroes() { //Arrange InMemoryHeroRepositoryBuilder builder = new InMemoryHeroRepositoryBuilder(); IHeroRepository repository = builder.Build(); //Act IReadOnlyList <IHero> allHeroes = repository.GetAll(); //Assert Assert.That(allHeroes, Is.Not.Null, "The returned list is null."); Assert.That(allHeroes.Count, Is.GreaterThanOrEqualTo(3), "At least 3 heroes must be returned."); builder.HeroFactoryMock.Verify( factory => factory.CreateNewHero(It.IsAny <string>(), It.IsAny <int>(), It.IsAny <float>()), Times.Exactly(allHeroes.Count), $"When {allHeroes.Count} heroes are returned, " + $"the 'CreateNewHero' method of the factory should have been called {allHeroes.Count} times."); }
public HeroController(DataContext context, IHeroRepository repo) { _context = context; _repo = repo; }
public HeroController(IHeroRepository repository, ILogger <HeroController> logger) { _repository = repository; _logger = logger; }
public PlayersController(IPlayerRepository playerRepository, IHeroRepository heroRepository, IPlayerHeroRepository playerHeroRepository) { _playerRepository = playerRepository; _heroRepository = heroRepository; _playerHeroRepository = playerHeroRepository; }
public HitService(IHitRepository repository, IDragonRepository dragonRepository, IHeroRepository heroRepository, IDataAdapter dataAdapter) : base(repository, dataAdapter) { _dragonRepository = dragonRepository; _heroRepository = heroRepository; }
/// <summary> /// Initializes controller with an instance of repository interface. /// </summary> public HeroController(IHeroRepository heroRepository, IMetadataRepository metadataRepository) { _heroRepository = heroRepository; _metadataRepository = metadataRepository; }
public HeroFeedbackRepository(IHeroRepository repo) { _baseRepo = repo ?? throw new ArgumentNullException(nameof(repo)); }
public HeroService(IHeroRepository heroRepository, INotificator notificator) : base(notificator) { _heroRepository = heroRepository; }
public UnitOfWork(IHeroRepository heroRepository) { _heroRepository = heroRepository; }
public CachingRepository(IHeroRepository repository) { _repository = repository; }
public GetHeroByIdHandler(IHeroRepository heroRepository, IMapper mapper) { _heroRepository = heroRepository; _mapper = mapper; }
public DeleteHeroByIdHandler(IHeroRepository heroRepository) { _heroRepository = heroRepository; }
public HeroService(IHeroRepository heroRepository) { _heroRepository = heroRepository; }
public HeroService(IHeroRepository heroRepository) { this.heroRepository = heroRepository; }
public HerosController(IHeroRepository repo) { _repo = repo; }
public PetService(IPetRepository petRepo, IHeroRepository heroRepository) { _petRepository = petRepo; _heroRepository = heroRepository; }
public HeroService(IHeroRepository repository, IDataAdapter dataAdapter, ITokenManager <HeroEntity, string> tokenManager, UserManager <HeroEntity> userManager) : base(repository, dataAdapter) { _repository = repository; _tokenManager = tokenManager; _userManager = userManager; }
public HeroController(IHeroRepository heroRepository, ICryptographyService cryptographyService) { _heroRepository = heroRepository; _cryptographyService = cryptographyService; }
// Note dependency injection in controller here. Learn more at // https://docs.microsoft.com/en-us/aspnet/core/mvc/controllers/dependency-injection public HeroesController(IHeroRepository heroRepository) { this.heroRepository = heroRepository; }
public HeroApplication(IHeroRepository heroRepository) { _heroRepository = heroRepository; }