예제 #1
0
 static void Main(string[] args)
 {
     var sessionFactory = HibernateSession.SessionFactory();
     var session = sessionFactory.OpenSession();
     BandDAO bandDAO = new BandDAO(session);
     var band = new Band();
     band.BandName = "PanterA";
     using (var transaction = session.BeginTransaction()) {
         bandDAO.Save(band);
         transaction.Commit();
     }
     Console.ReadKey();
 }
예제 #2
0
 public void VotesPerBand_ShouldReturnOne()
 {
     Band myNewBand = new Band();
     myNewBand.BandName = "My Band";
     bandDao.Save(myNewBand);
     var bandSong = new Band() {
         BandName = "Ozzy Osbourne"
     };
     bandDao.Save(bandSong);
     Song song = new Song();
     song.Band = bandSong;
     song.SongName = "Crazy Train";
     songDao.Save(song);
     Vote vote = new Vote();
     vote.VotedBand = myNewBand;
     vote.VotedSong = song;
     vote.VotingDate = DateTime.Now;
     voteDao.Save(vote);
     IList<Vote> votesCasted = voteDao.VotesCastedTo(myNewBand);
     Assert.AreEqual(1, votesCasted.Count);
 }
예제 #3
0
 public IEnumerable<VotesPerSong> AllVotesPerSongForBand(Band band)
 {
     var bandVotes = this.VoteDAO.VotesCastedTo(band);
     var sumOfVotes = from vote in bandVotes group vote by vote.VotedSong into votePerSong select new VotesPerSong() { Song = votePerSong.Key, NumberOfVotes = votePerSong.Count() };
     return sumOfVotes;
 }
예제 #4
0
 public void Save(Band entity)
 {
     this.bandDAO.Save(entity);
 }
예제 #5
0
 public void Delete(Band entity)
 {
     this.bandDAO.Delete(entity);
 }
예제 #6
0
 public void SetUp()
 {
     this.voteDAO = new Mock<IVoteDAO>();
     this.votePoll = new VotePoll(voteDAO.Object);
     this.band = new Band();
 }