コード例 #1
0
        public void FailInGetLodgingByTouristSpotInternalErrorTest()
        {
            var lodgingRepositoryMock = new Mock <ILodgingRepository>(MockBehavior.Strict);

            lodgingRepositoryMock.Setup(m => m.GetAvailableLodgingsByTouristSpot(touristSpot.Id)).Throws(new ServerException());
            LodgingManagement lodgingLogic = new LodgingManagement(lodgingRepositoryMock.Object);

            lodgingLogic.GetAvailableLodgingsByTouristSpot(touristSpot.Id);
        }
コード例 #2
0
        public void GetLodgingsByTouristSpotTest()
        {
            lodging.TouristSpot = touristSpot;
            List <Lodging> listOfLodgings = new List <Lodging>()
            {
                lodging, lodgingConrad
            };

            var lodgingRepositoryMock = new Mock <ILodgingRepository>(MockBehavior.Strict);

            lodgingRepositoryMock.Setup(m => m.GetAvailableLodgingsByTouristSpot(It.IsAny <Guid>())).Returns(listOfLodgings);
            LodgingManagement lodgingLogic = new LodgingManagement(lodgingRepositoryMock.Object);

            List <Lodging> resultOfSearchLodgingByTouristSpot = lodgingLogic.GetAvailableLodgingsByTouristSpot(touristSpot.Id);

            lodgingRepositoryMock.VerifyAll();
            Assert.AreEqual(lodging, resultOfSearchLodgingByTouristSpot[0]);
        }