public void NonGenericLemmingUniqueNameShouldBeEqualToName() { var lemming = Lemming.From(typeof(Service)); Assert.AreEqual("NailsFramework.Tests.IoC.Lemmings.Service", lemming.Name); Assert.AreEqual("NailsFramework.Tests.IoC.Lemmings.Service", lemming.UniqueName); }
public MoveToCliffState(Lemming lemming, HexagonMap.MapPosition targetPosition) { this.lemming = lemming; this.targetPosition = GameController.Instance.map.GetRandomPositionInCliffPosition(targetPosition); lemming.randomPositionOfCurrentTargetPosition = this.targetPosition; SetRandomSpeed(lemming); }
public void GenericLemmings() { objectFactory.Configure(new[] { Lemming.From(typeof(GenericService <>)) }, new Injection[0]); var service = objectFactory.GetObject <GenericService <string> >(); Assert.IsNotNull(service); }
private bool ProcessSpawners(LevelMoment mom) { bool result = false; List <Spawner> spawners = new List <Spawner>(); spawners.AddRange(mom.spawners); foreach (Spawner spawn in spawners) { spawn.age--; if (spawn.age == 0) { mom.spawners.Remove(spawn); } if (spawn.age % 2 != 0) { continue; } Lemming lem = spawn.MakeLemming(); if (mom.IsFree(lem.position)) { mom.lemmings.Add(lem); } } return(result); }
public void ShouldBeAbleToAddGenericLemmingsOfDifferentTypes() { var serviceLemming = Lemming.From <ServiceWithGenericDependency>(); serviceLemming.Injections.OfType <ReferenceInjection>().Single().ReferencedLemming = "Test1"; var anotherServiceLemming = Lemming.From <AnotherServiceWithGenericDependency>(); anotherServiceLemming.Injections.OfType <ReferenceInjection>().Single().ReferencedLemming = "Test2"; var test1 = Lemming.From(typeof(GenericService <>)); test1.Name = "Test1"; var test2 = Lemming.From(typeof(GenericService <>)); test2.Name = "Test2"; var lemmings = new[] { serviceLemming, anotherServiceLemming, test1, test2 }; objectFactory.Configure(lemmings, new Injection[0]); var service = objectFactory.GetObject <ServiceWithGenericDependency>(); Assert.IsNotNull(service); Assert.IsNotNull(service.GenericDependency); var service2 = objectFactory.GetObject <ServiceWithGenericDependency>(); Assert.IsNotNull(service2); Assert.IsNotNull(service2.GenericDependency); }
private void PlaceLemming(char key, Lemming lem) { GameObject newObject = GetObject(key); if (newObject == null) { return; } Vector3Int pos = lem.position; newObject.SetActive(true); newObject.transform.localPosition = new Vector3(pos.x, pos.y, pos.z); Vector3 angles = new Vector3(0f, 90f, 0f); float turn = 0f; if (lem.direction.z == -1) { turn = 1; } else if (lem.direction.x == -1) { turn = 2; } else if (lem.direction.z == 1) { turn = 3; } newObject.transform.localEulerAngles = angles * turn; }
public void ShouldAddInjectionsDueAttributes() { var lemming = Lemming.From(typeof(Service)); Assert.AreEqual(1, lemming.Injections.Count()); Assert.AreEqual("Dependency", lemming.Injections.Single().Property.Name); }
/// <summary> /// Inflicts the block's effects on a lemming. /// </summary> /// <param name="lemming">The lemming who triggered the block.</param> /// <param name="hit">Collision information.</param> public override void AffectLemming(Lemming lemming, RaycastHit hit = new RaycastHit()) { if (lemming.CanJump()) { lemming.body.AddForce((transform.forward + Vector3.up) * force); } }
public void SingletonsShouldBeSingletonsWhenGettedFromDifferentTypes() { objectFactory.Configure(new[] { Lemming.From <ServiceDependency>() }, new Injection[0]); var o1 = objectFactory.GetObject <ServiceDependency>(); var o2 = objectFactory.GetObject <IServiceDependency>(); Assert.AreEqual(o1, o2); }
private void SetRandomSpeed(Lemming lemming) { const float RANDOM_PERCENTAGE_LIMIT = 20; var maximumSpeed = lemming.defaultSpeed * (1 + RANDOM_PERCENTAGE_LIMIT / 100); var minimumSpeed = lemming.defaultSpeed * (1 - RANDOM_PERCENTAGE_LIMIT / 100); lemming.speed = Random.Range(minimumSpeed, maximumSpeed); }
public void InstanceInjection() { objectFactory.Configure(new[] { Lemming.From <ServiceDependency>() }, new Injection[0]); var instance = new NonLemmingWithInjections(); objectFactory.Inject(instance); Assert.IsNotNull(instance.Dependency); Assert.AreEqual("test123", instance.Value); }
public override void Move(LevelMoment next, LevelMoment prev, Lemming lemming, GameBlock block) { lemming.position = block.pos; LevelData.Instance.WormHole(next); next.timeTraveler = lemming; next.lemmings.Remove(lemming); next.phasedLemmings.Remove(lemming); next.fail--; }
public void NonSingletonsShouldNotBeSingletons() { var lemming = Lemming.From <ServiceDependency>(); lemming.Singleton = false; objectFactory.Configure(new[] { lemming }, new Injection[0]); var o1 = objectFactory.GetObject <ServiceDependency>(); var o2 = objectFactory.GetObject <ServiceDependency>(); Assert.AreNotEqual(o1, o2); }
public void ShouldSetInjectionNamesWithAttributes() { var lemming = Lemming.From(typeof(NamedLemming)); Assert.AreEqual(lemming.Injections.Count(), 1); var reference = (ReferenceInjection)lemming.Injections.Single(); Assert.AreEqual("Dependency", reference.Property.Name); Assert.AreEqual("lalala", reference.ReferencedLemming); }
public void ConfigurationInjectionsShouldHaveValueAsAppSetingsWithLemmingPropertyAsKeyByDefault() { var lemming = Lemming.From(typeof(LemmingWithValuesFromConfiguration)); Assert.AreEqual(lemming.Injections.Count(), 1); var reference = (ConfigurationInjection)lemming.Injections.Single(); Assert.AreEqual("ConfigurationValue", reference.Property.Name); Assert.AreEqual("testConfigurationValueForDefaultKey", reference.Value); }
public Lemming MakeLemming() { Lemming result = new Lemming(); result.age = 25; result.direction = direction; result.position = position + Vector3Int.down; result.phase = phase; return(result); }
public void ConfigurationInjectionsOverridenKey() { var lemming = Lemming.From(typeof(LemmingWithValuesFromConfigurationWithOverridenKey)); Assert.AreEqual(lemming.Injections.Count(), 1); var value = (ConfigurationInjection)lemming.Injections.Single(); Assert.AreEqual("ConfigurationValue", value.Property.Name); Assert.AreEqual("test123", value.Value); }
public void GetFromInterface() { objectFactory.Configure(new[] { Lemming.From(typeof(Service)), Lemming.From(typeof(ServiceDependency)) }, new Injection[0]); var service = objectFactory.GetObject <IService>(); Assert.IsNotNull(service); }
public void GetFromTypeGeneric() { objectFactory.Configure(new[] { Lemming.From(typeof(ServiceWithGenericDependency)), Lemming.From(typeof(GenericService <>)) }, new Injection[0]); var service = objectFactory.GetObject <GenericService <string> >(); Assert.IsNotNull(service); }
public void ConfigurationInjectionForNamedLemmingDefaultKey() { var lemming = Lemming.From(typeof(LemmingWithValuesFromConfiguration)); lemming.Name = "Bar"; Assert.AreEqual(lemming.Injections.Count(), 1); var reference = (ConfigurationInjection)lemming.Injections.Single(); Assert.AreEqual("ConfigurationValue", reference.Property.Name); Assert.AreEqual("bar-value", reference.Value); }
public void ConfigurationInjectionForGenericNamedLemmingDefaultNonGenericKey() { var lemming = Lemming.From(typeof(GenericLemmingWithValuesFromConfiguration <string>)); lemming.Name = "GenericLemming2"; Assert.AreEqual(lemming.Injections.Count(), 1); var reference = (ConfigurationInjection)lemming.Injections.Single(); Assert.AreEqual("ConfigurationValue", reference.Property.Name); Assert.AreEqual("generic2-value", reference.Value); }
public void GetFromTypeNonGeneric() { objectFactory.Configure(new[] { Lemming.From(typeof(Service)), Lemming.From(typeof(ServiceDependency)) }, new Injection[0]); var service = objectFactory.GetObject(typeof(Service)); Assert.IsNotNull(service); }
public void GetGenericByNameAndTypeParameters() { objectFactory.Configure(new[] { Lemming.From(typeof(GenericService <>)) }, new Injection[0]); var service = objectFactory.GetGenericObject <string>("NailsFramework.Tests.IoC.Lemmings.GenericService"); Assert.IsNotNull(service); Assert.IsInstanceOf <IGenericService <string> >(service); }
public void ReferenceInjections() { objectFactory.Configure(new[] { Lemming.From(typeof(Service)), Lemming.From(typeof(ServiceDependency)) }, new Injection[0]); var service = objectFactory.GetObject <Service>(); Assert.IsInstanceOf <ServiceDependency>(service.Dependency); }
public void SingletonsShouldBeSingletonsWhenGettedFromTypeAndName() { var lemming = Lemming.From <ServiceDependency>(); lemming.Name = "Test"; objectFactory.Configure(new[] { lemming }, new Injection[0]); var o1 = objectFactory.GetObject <ServiceDependency>(); var o2 = objectFactory.GetObject("Test"); Assert.AreEqual(o1, o2); }
public void GenericReferenceInjections() { objectFactory.Configure(new[] { Lemming.From(typeof(GenericService <>)), Lemming.From(typeof(ServiceWithGenericDependency)) }, new Injection[0]); var service = objectFactory.GetObject <ServiceWithGenericDependency>(); Assert.IsInstanceOf <GenericService <string> >(service.GenericDependency); }
public Lemming DeepCopy() { Lemming result = new Lemming { age = this.age, phase = this.phase, direction = this.direction, position = this.position }; return(result); }
private void InjectTestProperties() { var lemming = Lemming.From(GetType()); foreach (var injection in lemming.Injections) { if (!configured || !lemming.Singleton) { injection.Accept(this); } } }
public override void Move(LevelMoment next, LevelMoment prev, Lemming lemming, GameBlock block) { Vector3Int i = block.pos; if (fade > '0') { next.level[i.x, i.y, i.z] = fade; } else { next.level[i.x, i.y, i.z] = GameBoardCubeDictionary.OPEN_CUBE; } }
/// <summary> /// Inflicts the block's effects on a lemming. /// </summary> /// <param name="lemming">The lemming who triggered the block.</param> /// <param name="hit">Collision information.</param> public override void AffectLemming(Lemming lemming, RaycastHit hit = new RaycastHit()) { Vector3 xz = VectorUtil.SetY(transform.forward, 0); xz.Normalize(); // Turns the lemming around if it would be walking into the block. if (VectorUtil.ApproximatelyEqual(lemming.transform.forward, xz)) { xz = -xz; } lemming.transform.forward = xz; }