示例#1
0
        public void TestInitialize()
        {
            // Arrange
            mock = new Mock <IStoreManagerRepository>();

            // Mock the Album Data
            parties = new List <Party>
            {
                new Party {
                    PartyId = 1, Party_Type_ = "Concert", Message_ = "Party time", Address_ = "Barrie", PLocation = new PLocation {
                        LocationID = 3, City = "Barrie"
                    }
                },
                new Party {
                    PartyId = 2, Party_Type_ = "Kegger", Message_ = "Party time", Address_ = "Barrie", PLocation = new PLocation {
                        LocationID = 3, City = "Barrie"
                    }
                },
                new Party {
                    PartyId = 3, Party_Type_ = "Party", Message_ = "Party time", Address_ = "Barrie", PLocation = new PLocation {
                        LocationID = 3, City = "Barrie"
                    }
                }
            };

            // populate the mock object with our sample data
            mock.Setup(m => m.Parties).Returns(parties.AsQueryable());

            // Pass the mock to 2nd constructor
            controller = new PartiesController(mock.Object);
        }
示例#2
0
        public void AddParty_UnitOfWorkNull_ShouldThrowException()
        {
            PartiesController partiesController = new PartiesController();
            Guest             guest             = new Guest {
                EmailAddress = "*****@*****.**"
            };
            Party party = new Party
            {
                Guests = new List <Guest> {
                    guest
                },
                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
                }
            };

            partiesController.AddParty(null, party);
        }
示例#3
0
 public APIPartiesControllerShould(ITestOutputHelper output)
 {
     _mockRepository = new Mock <IRepository>();
     _mockMapper     = new Mock <IMapper>();
     _sut            = new PartiesController(_mockRepository.Object, _mockMapper.Object);
     _output         = output;
 }
示例#4
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));
        }