public void DiscountPoliciesShouldBeStoredInTheSameTable()
        {
            DiscountUntilExpired discountUntilExpired = new DiscountUntilExpired
                {
                    DiscountPercentage = new Percentage(20),
                    FromTo = new DateSpan {StartDate = DateTime.Today, EndDate = DateTime.Today.AddDays(1)}
                };
            PromoDay promoDay = new PromoDay
                {
                    DiscountPercentage = new Percentage(10),
                    DayDate = DateTime.Today
                };

            mappingContext.DiscountPolicies.Insert(discountUntilExpired);
            mappingContext.DiscountPolicies.Insert(promoDay);
            mappingContext.SaveChanges();

            DiscountUntilExpired discountUntilExpiredReadFromDb = ReadDiscountUntilExpiredFromDatabase(discountUntilExpired.Id);
            Assert.AreEqual(discountUntilExpiredReadFromDb.Id, discountUntilExpired.Id);
            Assert.AreEqual(discountUntilExpiredReadFromDb.DiscountPercentage, discountUntilExpired.DiscountPercentage);
            Assert.AreEqual(discountUntilExpiredReadFromDb.FromTo, discountUntilExpired.FromTo);

            PromoDay promoDayReadFromDb = ReadPromoDayFromDatabase(promoDay.Id);
            Assert.AreEqual(promoDayReadFromDb.Id, promoDay.Id);
            Assert.AreEqual(promoDayReadFromDb.DiscountPercentage, promoDay.DiscountPercentage);
            Assert.AreEqual(promoDayReadFromDb.DayDate, promoDay.DayDate);
        }
 private PromoDay ReadPromoDayFromDatabase(int id)
 {
     using (SqlConnection connection = new SqlConnection(connectionString))
     {
         connection.Open();
         using (SqlCommand command = new SqlCommand("SELECT * FROM DiscountPolicies WHERE ID = " + id, connection))
         {
             IDataReader dr = command.ExecuteReader();
             if (dr.Read())
             {
                 PromoDay promoDay = new PromoDay();
                 promoDay.Id = (int)dr["ID"];
                 Percentage percentage = new Percentage((int)dr["DiscountPercentage"]);
                 promoDay.DiscountPercentage = percentage;
                 promoDay.DayDate = (DateTime)dr["DayDate"];
                 return promoDay;
             }
             throw new ArgumentException("no id " + id + " found");
         }
     }
 }
 public IEntity Load(int id, SqlDataReader dataReader)
 {
     PromoDay promoDay = new PromoDay();
     promoDay.Id = id;
     promoDay.DayDate = (DateTime)dataReader["DayDate"];
     return promoDay;
 }