// Use this for initialization void Start() { //Setting up Ammo and Cooldown Timer Text UI if (isLocalPlayer) //This is the local player's ship -- use the HUD heavyweapon UI elements { GameObject UI; //locate text for current ammo in scene UI = GameObject.FindGameObjectWithTag("CurrentAmmoUI"); ammoCountValueText = UI.GetComponentInChildren <Text>(); //locate text for max ammo in scene //UI = GameObject.FindGameObjectWithTag("MaxAmmoUI"); //ammoMaxValueText = UI.GetComponentInChildren<Text>(); //locate text for cool down in scene UI = GameObject.FindGameObjectWithTag("CooldownUI"); coolDownTimerText = UI.GetComponentInChildren <Text>(); //Get reference to HeavyWeapon Component the player ship is using playerHeavyWeapon = GetComponent <HeavyWeapon>(); //initialize text UI elements with infor from playerHeavyWeapon SetAmmoCountValueText(); //SetAmmoMaxValueText(); SetCoolDownTimerText(); } }
public void Optimistic_concurrency_error_attempting_to_modify_previously_deleted_entity_when_using_timestamp() { ExtendedSqlAzureExecutionStrategy.ExecuteNew( () => { using (new TransactionScope()) { using (var context = new GearsOfWarContext()) { using (var context2 = new GearsOfWarContext()) { var troika = new HeavyWeapon { Name = "Troika", Overheats = true, }; context.Weapons.Add(troika); context.SaveChanges(); var troika2 = context2.Weapons.OfType <HeavyWeapon>().Where(w => w.Name == "Troika").Single(); context.Weapons.Remove(troika); context.SaveChanges(); troika2.Overheats = false; Assert.Throws <DbUpdateConcurrencyException>(() => context2.SaveChanges()) .ValidateMessage(typeof(DbContext).Assembly(), "Update_ConcurrencyError", null); } } } }); }
public void Optimistic_concurrency_error_attempting_to_delete_previously_modified_entity_when_using_timestamp() { using (var context = new GearsOfWarContext()) { using (var context2 = new GearsOfWarContext()) { var troika = new HeavyWeapon { Name = "Troika", Overheats = true, }; context.Weapons.Add(troika); context.SaveChanges(); var troika2 = context2.Weapons.Where(w => w.Name == "Troika").Single(); troika.Overheats = false; context.SaveChanges(); context2.Weapons.Remove(troika2); Assert.Throws <DbUpdateConcurrencyException>(() => context2.SaveChanges()) .ValidateMessage(typeof(DbContext).Assembly, "Update_ConcurrencyError", null); } } }
public void Verify_that_order_of_insert_is_based_on_key_values_and_not_order_of_adding_to_collection() { ExtendedSqlAzureExecutionStrategy.ExecuteNew( () => { using (new TransactionScope()) { using (var context = new GearsOfWarContext()) { var weapon1 = new HeavyWeapon { Id = 10, Name = "Mortar", Overheats = false, }; var weapon2 = new HeavyWeapon { Id = 11, Name = "Oneshot", Overheats = false, }; var weapon3 = new StandardWeapon { Id = 12, Name = "Boltok", Specs = new WeaponSpecification { AmmoPerClip = 6, ClipsCount = 9, }, }; context.Weapons.Add(weapon3); context.Weapons.Add(weapon1); context.Weapons.Add(weapon2); context.SaveChanges(); var newWeapons = context.Weapons.OrderByDescending(t => t.Id).Take(3).ToList(); Assert.Equal("Boltok", newWeapons[0].Name); Assert.Equal("Oneshot", newWeapons[1].Name); Assert.Equal("Mortar", newWeapons[2].Name); } } }); }
public void Inserting_entity_that_references_itself_in_one_to_one_relationship_throws() { using (var context = new GearsOfWarContext()) { var hammerOfDawn = new HeavyWeapon { Name = "Hammer of Dawn", Overheats = false, }; hammerOfDawn.SynergyWith = hammerOfDawn; context.Weapons.Add(hammerOfDawn); Assert.Throws <DbUpdateException>(() => context.SaveChanges()) .InnerException.ValidateMessage(typeof(DbContext).Assembly, "Update_ConstraintCycle", null); } }