public async Task <ActionResult> Index() { using (HttpClient client = new HttpClient()) { try { client.BaseAddress = new Uri("https://api.coinlore.net/api/tickers/?start=0&limit=20"); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); HttpResponseMessage response = await client.GetAsync(client.BaseAddress); if (response.IsSuccessStatusCode) { var result = await response.Content.ReadAsStringAsync(); CoinBank resultObject = JsonConvert.DeserializeObject <CoinBank>(result); LoadCoinsFromBank(resultObject); return(View(resultObject)); } else { ModelState.AddModelError(string.Empty, "Server could not be reached"); } } catch (Exception ex) { var ss = ex.Message; } } return(View()); }
// Start is called before the first frame update void Start() { rigidbody = GetComponent <Rigidbody2D>(); rigidbody.freezeRotation = true; collider = GetComponent <BoxCollider2D>(); animator = GetComponent <Animator>(); Transform torso = transform.Find("Torso"); upperRightArm = torso.Find("UR_Arm"); lowerRightArm = upperRightArm.Find("LR_Arm"); health = GetComponent <Health>(); health.AttachHealthBar(Global.HudController.HealthDisplay); coinBank = GetComponent <CoinBank>(); coinBank.Pickup += OnPickupCoin; Global.HudController.CoinDisplay.AttachCoinBank(coinBank); audio = GetComponent <AudioSource>(); // Temp testing hasWeapon = weaponTransform != null; if (hasWeapon) { weapon = weaponTransform.GetComponent <Weapon>(); } }
public void GivenIPayTwoDollarsWithABankTotalOfThree() { var bank = new CoinBank(); bank.DecreaseBalance(2.1M); Assert.AreEqual(bank.HasChange(), false); }
public void GivenIPayOneDollarsWithABankTotalOfThree() { var bank = new CoinBank(); bank.DecreaseBalance(1.0M); Assert.AreEqual(bank.HasChange(), true); }
public void GivenIPayOneDollar() { var bank = new CoinBank(); bank.IncreaseBalance(1.0M); Assert.AreEqual(bank.Balance, 4.0M); }
public void GivenIReceiveChange() { var bank = new CoinBank(); bank.DecreaseBalance(1.0M); Assert.AreEqual(bank.Balance, 2.0M); }
public void SimpleCase() { // Arrange var bank = new CoinBank(); bank.AddCoin(CoinDenomination.TwentyPence); // Act bank.Withdraw(0.20M); // Assert Assert.AreEqual(0M, bank.Balance); }
public void MakeChange_25() { testCoinBank = new CoinBank(0, 0, 1); Dictionary <int, int> expectedResultDictionary = new Dictionary <int, int>() { { 5, 0 }, { 10, 0 }, { 25, 1 } }; Dictionary <int, int> actualResultDictionary = testCoinBank.MakeChange(25); Assert.AreEqual(expectedResultDictionary[5], actualResultDictionary[5]); Assert.AreEqual(expectedResultDictionary[10], actualResultDictionary[10]); Assert.AreEqual(expectedResultDictionary[25], actualResultDictionary[25]); }
public void SupplyingCoinsWhenMachineOutOfStockDoesNotIncreaseCredit() { // Arrange var bank = new CoinBank(); var provider = new CoinCreditProvider(bank); provider.UpdateOutOfStockStatus(true); // Act var result = provider.InsertCoin(CoinDenomination.FiftyPence); // Assert Assert.AreEqual(0, bank.Balance); Assert.IsFalse(result); }
public void SupplyingCoinsAddsToCoinBank() { var bank = new CoinBank(); Assert.AreEqual(0, bank.Balance); var provider = new CoinCreditProvider(bank); provider.UpdateOutOfStockStatus(false); provider.InsertCoin(CoinDenomination.FiftyPence); provider.InsertCoin(CoinDenomination.TenPence); provider.InsertCoin(CoinDenomination.FivePence); Assert.AreEqual(0.65M, bank.Balance); }
// Start is called before the first frame update void Start() { playerHealth = Global.Player.GetComponent <Health>(); playerCoins = Global.Player.GetComponent <CoinBank>(); shopGui = transform.Find("ShopGUI").gameObject; shopGui.SetActive(false); Transform parent = shopGui.transform.Find("Canvas").Find("Border").Find("Background"); Transform itemsTransform = parent.Find("Items"); Transform headerTransform = parent.Find("Header"); playerCoinsText = headerTransform.Find("Coins").Find("Text").GetComponent <Text>(); healBuyText = itemsTransform.Find("ItemHeal").Find("Background").Find("Text").GetComponent <Text>(); }
public void Load(GameObject player, bool overridePlayerPos = false) { Health playerHealth = player.GetComponent <Health>(); playerHealth.maxHealth = PlayerMaxHealth; playerHealth.HealthValue = PlayerHealth; CoinBank playerCoinBank = player.GetComponent <CoinBank>(); playerCoinBank.Coins = PlayerCoins; Global.GameController.LevelState = LevelState; if (overridePlayerPos) { player.transform.position = new Vector2(PlayerLevelPosX, PlayerLevelPosY); } }
private void LoadCoinsFromBank(CoinBank bank) { foreach (var coin in bank.data) { Coin coinToAdd = new Coin(); coinToAdd.ID = coin.id; coinToAdd.Rank = coin.rank; coinToAdd.Name = coin.name; coinToAdd.Symbol = coin.symbol; coinToAdd.NameID = coin.nameid; coinToAdd.Price_USD = coin.price_usd; coinToAdd.Price_BTC = coin.price_btc; coinToAdd.Percent_Change_24hr = coin.percent_change_24h; coinToAdd.Volume24 = coin.volume24; coinToAdd.Image = bank.Images[coin.rank]; bank.Coins.Add(coinToAdd); } }
public static bool TrySaveCurrentState(GameObject player, out GameState gameState) { if (player == null) { gameState = null; return(false); } Health playerHealth = player.GetComponent <Health>(); CoinBank playerCoinBank = player.GetComponent <CoinBank>(); gameState = new GameState() { PlayerCoins = playerCoinBank.Coins, PlayerMaxHealth = playerHealth.maxHealth, PlayerHealth = playerHealth.HealthValue, PlayerLevelPosX = player.transform.position.x, PlayerLevelPosY = player.transform.position.y, LevelState = Global.GameController.LevelState }; return(true); }
public void testInit() { testCoinBank = new CoinBank(); }
public void ValidCoin_Penny() { Assert.AreEqual(0, CoinBank.CoinValue(CoinBank.PENNY.Item1, CoinBank.PENNY.Item2)); }
public void ValidCoin_Nickel() { Assert.AreEqual(5, CoinBank.CoinValue(CoinBank.NICKEL.Item1, CoinBank.NICKEL.Item2)); }
public void ValidCoin_Dime() { Assert.AreEqual(10, CoinBank.CoinValue(CoinBank.DIME.Item1, CoinBank.DIME.Item2)); }
public void ValidCoin_Quarter() { Assert.AreEqual(25, CoinBank.CoinValue(CoinBank.QUARTER.Item1, CoinBank.QUARTER.Item2)); }
public CoinCreditProvider(CoinBank coinBank) { _coinBank = coinBank; }
public void AbleToMakeChange_25NoQuarters() { testCoinBank = new CoinBank(20, 10); Assert.IsTrue(testCoinBank.AbleToMakeChange(25)); }
public void AttachCoinBank(CoinBank coinBank) { this.coinBank = coinBank; coinBank.Changed += OnCoinChange; coinsText.text = coinBank.Coins.ToString(); }
public void AbleToMakeChange_Unable() { testCoinBank = new CoinBank(4); Assert.IsFalse(testCoinBank.AbleToMakeChange(25)); }