public void Factory_CreateNewHero_ShouldThrowArgumentExceptionForInvalidInput() { //Arrange IHeroFactory factory = CreateFactoryInstance(); //Act Assert.That(() => factory.CreateNewHero("", 50, 0.5f), Throws.InstanceOf <ArgumentException>(), "An empty name should not be allowed"); Assert.That(() => factory.CreateNewHero(null, 50, 0.5f), Throws.InstanceOf <ArgumentException>(), "An empty name should not be allowed"); Assert.That(() => factory.CreateNewHero("John", 0, 0.5f), Throws.InstanceOf <ArgumentException>(), "Strength of zero or less should not be allowed"); Assert.That(() => factory.CreateNewHero("John", -10, 0.5f), Throws.InstanceOf <ArgumentException>(), "Strength of zero or less should not be allowed"); Assert.That(() => factory.CreateNewHero("John", 101, 0.5f), Throws.InstanceOf <ArgumentException>(), "Strength bigger than 100 should not be allowed"); Assert.That(() => factory.CreateNewHero("John", 120, 0.5f), Throws.InstanceOf <ArgumentException>(), "Strength bigger than 100 should not be allowed"); Assert.That(() => factory.CreateNewHero("John", 50, -1.0f), Throws.InstanceOf <ArgumentException>(), "A negative supermode likeliness should not be allowed"); Assert.That(() => factory.CreateNewHero("John", 50, -10.0f), Throws.InstanceOf <ArgumentException>(), "A negative supermode likeliness should not be allowed"); Assert.That(() => factory.CreateNewHero("John", 50, 1.1f), Throws.InstanceOf <ArgumentException>(), "A supermode likeliness bigger than 1.0f should not be allowed"); Assert.That(() => factory.CreateNewHero("John", 50, 10.0f), Throws.InstanceOf <ArgumentException>(), "A supermode likeliness bigger than 1.0f should not be allowed"); }
public GameController(IUnitFactory unitFactory, IHeroFactory heroFactory, IItemFactory itemFactory) { this.unitFactory = unitFactory; this.heroFactory = heroFactory; this.itemFactory = itemFactory; this.heroes = new List<IHero>(); this.numberOfDay = 1; }
public HeroManager(IHeroFactory heroFactory, IItemFactory itemFactory, IRecipeFactory recipeFactory) { this.heroFactory = heroFactory; this.itemFactory = itemFactory; this.recipeFactory = recipeFactory; this.heroes = new Dictionary <string, IHero>(); }
private IHeroFactory CreateFactoryInstance() { AssertHasNestedFactory(); IHeroFactory factory = Activator.CreateInstance(_factoryType) as IHeroFactory; Assert.That(factory, Is.Not.Null, "Could not create an instance of the 'Factory' class and cast it to 'IHeroFactory'."); return(factory); }
public void Factory_CreateNewHero_ShouldCreateAValidHero() { //Arrange IHeroFactory factory = CreateFactoryInstance(); //Act AssertCreateValidHero(factory, "Joe", 50, 0.5f); AssertCreateValidHero(factory, "John", 1, 0.0f); AssertCreateValidHero(factory, "Jane", 100, 1.0f); }
public CommandInterpreter( IHeroRepository heroRepository, IHeroFactory heroFactory, IItemFactory itemFactory, IRecipeFactory recipeFactory) { this.heroRepository = heroRepository; this.heroFactory = heroFactory; this.itemFactory = itemFactory; this.recipeFactory = recipeFactory; }
private static void AssertCreateValidHero(IHeroFactory factory, string name, int strength, float superModeLikeliness) { IHero hero = factory.CreateNewHero(name, strength, superModeLikeliness); string call = $@"CreateNewHero(""{name}"", {strength}, {superModeLikeliness})"; Assert.That(hero, Is.Not.Null, $"{call} should not return null."); Assert.That(hero.Name, Is.EqualTo(name), $"{call} does not set name correctly."); Assert.That(hero.Strength, Is.EqualTo(strength), $"{call} does not set strength correctly."); Assert.That(hero.SuperModeLikeliness, Is.EqualTo(superModeLikeliness), $"{call} does not set supermode likeliness correctly."); Assert.That(hero.Health, Is.EqualTo(100), "Health should be 100."); }
public Engine( IInputReader reader, IOutputWriter writer, IManager manager, IHeroFactory heroFactory, ICommonItemFactory commonItemFactory, IRecipeFactory recipeFactory) { this.reader = reader; this.writer = writer; this.heroManager = manager; this.heroFactory = heroFactory; this.commonItemFactory = commonItemFactory; this.recipeFactory = recipeFactory; }
private void ConstructRepository(IHeroFactory heroFactory) { try { _heroRepository = Activator.CreateInstance(typeof(InMemoryHeroRepository), BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public, null, new object[] { heroFactory }, null) as InMemoryHeroRepository; } catch (Exception) { _heroRepository = null; } Assert.That(_heroRepository, Is.Not.Null, "Failed to instantiate an InMemoryHeroRepository."); }
public BattleAnalyzer(IFightAlgorithm fightAlgorithm, IArena arena, IHeroFactory heroFactory) { FightAlgorithm = fightAlgorithm; Arena = arena; Factory = heroFactory; }
public Hero(IHeroFactory fact) { Weapon = fact.GetHit(); Movement = fact.GetMovement(); }
public HeroManager(IHeroFactory heroFactory, IInventory inventory, IList <IHero> heroes) { this.heroFactory = heroFactory; this.inventory = inventory; this.heroes = heroes; }
public AddHeroCommand(IRepository<IHero> heroRepository, IHeroFactory heroFactory) { this.heroRepository = heroRepository; this.heroFactory = heroFactory; }
public DCHeroesController() { _heroFactory = HttpContext.Current.Application["HeroFactory"] as IHeroFactory; }
public HeroManager() { this.heroes = new Dictionary <string, IHero>(); heroFactory = new HeroFactory(); }
public Engine(IReader reader, IWriter writer, IHeroFactory heroFactory) { this.reader = reader; this.writer = writer; this.heroFactory = heroFactory; }
public Hero(IHeroFactory heroFactory) { _weapon = heroFactory.CreateWeapon(); _armor = heroFactory.CreateArmor(); }