public void CreateAd_GivenAnAdWithTestName_NameMatchesTestName() { string testName = "TEST NAME FOR AD"; var testAd = new Ad(testName); Assert.AreEqual("TEST NAME FOR AD", testAd.Name); }
public void CreateAd_GivenAnAdWithNullName_NameDefaultsToEmptyString() { string testName = null; var testAd = new Ad(testName); Assert.AreEqual(String.Empty, testAd.Name); }
public void PlaceAd_GivenANewNewspaperAndNewAd_CanAddAdToNewsPaper() { var newsPaper = new Newspaper(); var testAd = new Ad(); newsPaper.PlaceAd(testAd); Assert.AreEqual(1, newsPaper.AdList.Count); }
public void PlaceAd_GivenThreeAds_NewspaperAdListCountIsThree() { var newsPaper = new Newspaper(); var testAd1 = new Ad(); var testAd2 = new Ad(); var testAd3 = new Ad(); newsPaper.PlaceAd(testAd1); newsPaper.PlaceAd(testAd2); newsPaper.PlaceAd(testAd3); Assert.AreEqual(3, newsPaper.AdList.Count); }
public void SaveNewAd(int newspaperId, Ad ad) { using (var conn = new OleDbConnection(string.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Persist Security Info=False;", connStr))) { conn.Open(); var adCmd = new OleDbCommand("", conn); adCmd.CommandText = @"INSERT INTO [Ads] (NewspaperId, Name) VALUES (@a, @b)"; adCmd.Parameters.Add(new OleDbParameter("a", newspaperId)); adCmd.Parameters.Add(new OleDbParameter("b", ad.Name)); adCmd.ExecuteNonQuery(); } }
public ActionResult PlaceAd() { string adText = TempData["adText"].ToString(); if (!string.IsNullOrEmpty(adText)) { var adToPlace = new Ad(adText); var newspaperToGetNewAd = newspapers.FirstOrDefault(x => x.Id == Convert.ToInt32(TempData["newspaperId"].ToString())); if (newspaperToGetNewAd != null) { //Persist New Ad in Database newspaperToGetNewAd.PlaceAd(adToPlace); writer.SaveNewAd(newspaperToGetNewAd.Id, adToPlace); } } return RedirectToAction("Index"); }
public void PlaceAd(Ad newAd) { AdList.Add(newAd); }
public void CreateAd_GivenAdWithNoName_NameDefaultsToEmptyString() { var testAd = new Ad(); Assert.AreEqual(String.Empty, testAd.Name); }