public void UpdateShouldCalculateCorrectAverageSingleValue() { var host = new AverageCalc(); host.Update(456); Assert.That(host.Average, Is.EqualTo(456), "Incorrect Average Calculation for a single update"); }
void Update() { if (!nextReady) { if (OVRInput.GetDown(OVRInput.Button.PrimaryIndexTrigger) && !wasPressed) { keyInformation.gameObject.SetActive(false); StartCoroutine(Counter(20, counter.GetComponent <Text>())); wasPressed = true; ball.gameObject.tag = "Active"; } AverageCalc averageCalc = ball.GetComponent <AverageCalc>(); average = averageCalc.average; if (spawnObject) { if (average < 1.1) { lowestToneStar.gameObject.SetActive(true); } else if (average < 2) { lowToneStar.gameObject.SetActive(true); } if (average < 3) { middleToneStar.gameObject.SetActive(true); } else if (average < 4) { bigToneStar.gameObject.SetActive(true); } else { highToneStar.gameObject.SetActive(true); } } if (stageDone) { StopAllCoroutines(); averageCalc.count0 = 0; averageCalc.count1 = 0; averageCalc.count2 = 0; averageCalc.count3 = 0; averageCalc.count4 = 0; averageCalc.sub0 = false; averageCalc.sub1 = false; averageCalc.sub2 = false; keyInformation.gameObject.SetActive(true); wasPressed = false; ball.gameObject.tag = "Inactive"; counter.GetComponent <Text>().text = "" + 20; counter.GetComponent <Text>().color = new Color(1255, 255, 255, 1); this.gameObject.tag = "Movable"; nextReady = true; } } }
public void UpdateShouldCalculateCorrectAverageTwoValues() { var host = new AverageCalc(); host.Update(456); host.Update(195); Assert.That(host.Average, Is.EqualTo(325.5), "Incorrect Average Calculation for a two updates"); }
public void UpdateShouldCalculateCorrectAverageTenValues() { var host = new AverageCalc(); for (var i = 1; i <= 10; i++) { host.Update(i); } Assert.That(host.Average, Is.EqualTo(5.5), "Incorrect Average Calculation for a two updates"); }
public void Average_Returns_Average_For_Simple_List() { var testContext = new List <double> { 3.01d, 1.02d, 5.0d, 9.23d, 4.22d }; double expectedResult = (3.01d + 1.02d + 5.0d + 9.23d + 4.22d) / 5; double actualResult = new AverageCalc().ExecuteCalc(testContext); Assert.AreEqual(expectedResult, actualResult); }
private static void UpdateWithRandoms(AverageCalc host, int numberOfElements, int maxRange) { double sum = 0; for (var i = 0; i < numberOfElements; i++) { var val = GetRandomNumber(0, maxRange); host.Update(val); sum += val; } var actual = sum / numberOfElements; Assert.That(host.Average, Is.EqualTo(actual), "Incorrect Average Calculation"); }
void Start() { stage1 = GetComponent <Stage1>(); error.gameObject.SetActive(false); averageCalc = ball.GetComponent <AverageCalc>(); }
void Start() { this.averageCalc = ball.GetComponent <AverageCalc>(); this.audioSource = gameObject.GetComponent <AudioSource>(); }