private void Plan_Submit(object sender, RoutedEventArgs e) { if (DailySmoked.SelectedValue == null || ReductionPerWeek.SelectedValue == null || StartDate.SelectedDate == null) { NullValues.Visibility = Visibility.Visible; } //else if (repo.GetCount() != 0) { // DeleteCurrentPlan.Visibility = Visibility.Visible; // ChoosePlan.Visibility = Visibility.Collapsed; //} else { QuitBox.Visibility = Visibility.Visible; ChoosePlan.Visibility = Visibility.Collapsed; int smokeDaily = (int)DailySmoked.SelectedValue; int reduceRate = (int)ReductionPerWeek.SelectedValue; DateTime tryer = (DateTime)StartDate.SelectedDate; repo.Add(new DataEntry(tryer.ToShortDateString(), smokeDaily, reduceRate)); double days = ((double)smokeDaily / reduceRate) * 7; int totalDays = (int)Math.Ceiling(days); int counter = 1; while (counter < totalDays) { if (counter % 7 == 0 && smokeDaily > reduceRate) { int smokeReducer = smokeDaily - reduceRate; smokeDaily = smokeReducer; repo.Add(new DataEntry(tryer.AddDays(counter).ToShortDateString(), smokeReducer, reduceRate)); counter++; } else if (smokeDaily < reduceRate && totalDays - counter <= 7) { reduceRate = smokeDaily; repo.Add(new DataEntry(tryer.AddDays(counter).ToShortDateString(), smokeDaily, reduceRate)); counter++; } else { repo.Add(new DataEntry(tryer.AddDays(counter).ToShortDateString(), smokeDaily, reduceRate)); counter++; } } } }
public void ICannotEnterDuplicateLabelAppears() { repo.Add(new DataEntry("5/18/15", 3, 5)); Assert.AreEqual(1, repo.GetCount()); Label aba = window.Get <Label>("PlanInPlace"); Assert.IsTrue(aba.Visible); }
public void TestAddToDatabase() //Valid { Assert.AreEqual(0, repo.GetCount()); repo.Add(new DataEntry("New Years Eve", 1, 2)); Assert.AreEqual(1, repo.GetCount()); }