コード例 #1
0
        public void AddPartyTweet_NewCorrectPartyTweet_ShouldAddInDatabase()
        {
            IUnitOfWork           unitOfWork            = new MockUnitOfWork();
            PartyTweetsController partyTweetsController = new PartyTweetsController();
            Guest guest = new Guest {
                EmailAddress = "*****@*****.**"
            };
            Party party = new Party
            {
                Guests = new List <Guest> {
                    guest
                },
                EndTime   = DateTime.Now,
                StartTime = DateTime.Now
            };
            PartyGuest partyGuest = new PartyGuest {
                Guest = guest, Party = party
            };
            PartyTweet partyTweet = new PartyTweet {
                Message = "TestMessage", PartyGuest = partyGuest
            };

            unitOfWork.Parties.Insert(party);
            unitOfWork.Guests.Insert(guest);
            unitOfWork.PartyGuests.Insert(partyGuest);
            bool ok = partyTweetsController.AddPartyTweet(unitOfWork, partyTweet);

            Assert.IsTrue(ok);
            var partyTweets = unitOfWork.PartyTweets.Get();

            Assert.IsTrue(partyTweets.Any(pt => pt.Message == partyTweet.Message && pt.PartyGuest == partyGuest));
        }
コード例 #2
0
        public void AddTrack_NewCorrectTrack_ShouldAddInDatabase()
        {
            IUnitOfWork      unitOfWork       = new MockUnitOfWork();
            TracksController tracksController = new TracksController();
            Guest            guest            = new Guest {
                EmailAddress = "*****@*****.**"
            };
            Party party = new Party
            {
                Guests = new List <Guest> {
                    guest
                },
                EndTime   = DateTime.Now,
                StartTime = DateTime.Now,
                PlayList  = new PlayList()
            };
            PartyGuest partyGuest = new PartyGuest {
                Party = party, Guest = guest, PartyCode = 1
            };
            PlayList playList = new PlayList {
                Party = party
            };
            Track track = new Track {
                Title = "Song1", Interpret = "Interpret", PlayLists = new List <PlayList> {
                    playList
                }, RecommendedByGuest = partyGuest
            };

            unitOfWork.Parties.Insert(party);
            unitOfWork.PlayLists.Insert(playList);
            unitOfWork.PartyGuests.Insert(partyGuest);
            bool ok = tracksController.AddTrack(unitOfWork, track);

            Assert.IsTrue(ok);
            var tracks = unitOfWork.Tracks.Get();

            Assert.IsTrue(tracks.Any(t => t.Title == track.Title &&
                                     t.Interpret == track.Interpret &&
                                     t.Url == track.Url &&
                                     t.PlayLists.Equals(track.PlayLists) &&
                                     t.RecommendedByGuest == track.RecommendedByGuest));
        }
コード例 #3
0
        public void AddParty_NewCorrectParty_ShouldAddInDatabase()
        {
            IUnitOfWork       unitOfWork        = new MockUnitOfWork();
            PartiesController partiesController = new PartiesController();
            Guest             guest             = new Guest {
                EmailAddress = "*****@*****.**"
            };
            Party party = new Party
            {
                Guests = new List <Guest> {
                    guest
                },
                Name      = "Party1",
                Location  = "Beim Pepi",
                EndTime   = DateTime.Now,
                StartTime = DateTime.Now
            };
            PlayList playList = new PlayList {
                Party = party
            };
            Track track = new Track {
                Title = "Song1", Interpret = "Interpret", PlayLists = new List <PlayList> {
                    playList
                }
            };

            unitOfWork.Guests.Insert(guest);
            unitOfWork.PlayLists.Insert(playList);
            unitOfWork.Tracks.Insert(track);
            bool ok = partiesController.AddParty(unitOfWork, party);

            Assert.IsTrue(ok);
            var parties = unitOfWork.Parties.Get();

            Assert.IsTrue(parties.Any(p => p.Name == party.Name &&
                                      p.Location == party.Location &&
                                      p.StartTime == party.StartTime &&
                                      p.EndTime == party.EndTime));
        }
コード例 #4
0
        public void AddVote_NewCorrectVote_ShouldAddInDatabase()
        {
            IUnitOfWork     unitOfWork      = new MockUnitOfWork();
            VotesController votesController = new VotesController();
            Guest           guest           = new Guest {
                EmailAddress = "*****@*****.**", Id = 1
            };
            Party party = new Party
            {
                Guests = new List <Guest> {
                    guest
                },
                EndTime   = DateTime.Now,
                StartTime = DateTime.Now,
                Id        = 1
            };
            PlayList playList = new PlayList {
                Party = party, Id = 1
            };
            Track track = new Track {
                Title = "Song1", Interpret = "Interpret", PlayLists = new List <PlayList> {
                    playList
                }
            };

            unitOfWork.Parties.Insert(party);
            unitOfWork.Guests.Insert(guest);
            unitOfWork.PlayLists.Insert(playList);
            unitOfWork.Tracks.Insert(track);
            bool ok = votesController.AddVote(unitOfWork, guest, playList, track);

            Assert.IsTrue(ok);
            var votes = unitOfWork.Votes.Get();

            Assert.IsTrue(votes.Any(v => v.Track == track && v.PlayList == playList));
        }