Beispiel #1
0
        public void CreateInvalidLodgingWithoutRegionOnTouristSpotTest()
        {
            var lodgingRepositoryMock = new Mock <ILodgingRepository>(MockBehavior.Strict);

            lodgingRepositoryMock.Setup(m => m.Add(It.IsAny <Lodging>()));
            lodgingRepositoryMock.Setup(m => m.GetLodgingByNameAndTouristSpot(lodging.Name, touristSpot.Id)).Returns(value: null);

            var touristSpotRepositoryMock = new Mock <ITouristSpotRepository>(MockBehavior.Strict);

            touristSpotRepositoryMock.Setup(m => m.Get(It.IsAny <Guid>())).Throws(new ClientBusinessLogicException());
            touristSpotRepositoryMock.Setup(m => m.GetTouristSpotByName(It.IsAny <string>())).Returns(value: null);
            touristSpotRepositoryMock.Setup(m => m.Add(It.IsAny <TouristSpot>()));

            var regionMock = new Mock <IRepository <Region> >(MockBehavior.Strict);

            regionMock.Setup(m => m.Get(It.IsAny <Guid>())).Throws(new ClientBusinessLogicException());
            RegionManagement regionLogic = new RegionManagement(regionMock.Object);

            var categoryMock = new Mock <ICategoryRepository>(MockBehavior.Strict);

            categoryMock.Setup(m => m.Get(It.IsAny <Guid>())).Returns(aCategory);
            CategoryManagement categoryLogic = new CategoryManagement(categoryMock.Object);

            TouristSpotManagement touristSpotLogic = new TouristSpotManagement(touristSpotRepositoryMock.Object, regionLogic, categoryLogic);

            LodgingManagementForImportation lodgingLogic = new LodgingManagementForImportation(lodgingRepositoryMock.Object, touristSpotLogic);

            Lodging resultOfCreateALodging = lodgingLogic.Create(lodging, touristSpot, listOfPicturesPath);
        }
Beispiel #2
0
        public void CreateValidLodgingTestOk()
        {
            var lodgingRepositoryMock = new Mock <ILodgingRepository>(MockBehavior.Strict);

            lodgingRepositoryMock.Setup(m => m.Add(It.IsAny <Lodging>()));
            lodgingRepositoryMock.Setup(m => m.GetLodgingByNameAndTouristSpot(lodging.Name, touristSpot.Id)).Returns(value: null);

            var touristSpotRepositoryMock = new Mock <ITouristSpotRepository>(MockBehavior.Strict);

            touristSpotRepositoryMock.Setup(m => m.Get(It.IsAny <Guid>())).Returns(touristSpot);
            TouristSpotManagement touristSpotLogic = new TouristSpotManagement(touristSpotRepositoryMock.Object);

            LodgingManagementForImportation lodgingLogicForImportation = new LodgingManagementForImportation(lodgingRepositoryMock.Object, touristSpotLogic);

            Lodging resultOfCreateALodging = lodgingLogicForImportation.Create(lodging, touristSpot, listOfPicturesPath);

            Lodging lodgingToCompare = new Lodging()
            {
                Id              = resultOfCreateALodging.Id,
                Name            = resultOfCreateALodging.Name,
                QuantityOfStars = resultOfCreateALodging.QuantityOfStars,
                Address         = resultOfCreateALodging.Address,
                Images          = resultOfCreateALodging.Images,
                PricePerNight   = resultOfCreateALodging.PricePerNight,
                IsAvailable     = resultOfCreateALodging.IsAvailable,
                TouristSpot     = resultOfCreateALodging.TouristSpot
            };

            lodgingRepositoryMock.VerifyAll();
            Assert.AreEqual(lodging, lodgingToCompare);
        }
Beispiel #3
0
        public void CreateInvalidLodgingWithErrorInAddTest()
        {
            var lodgingRepositoryMock = new Mock <ILodgingRepository>(MockBehavior.Strict);

            lodgingRepositoryMock.Setup(m => m.Add(It.IsAny <Lodging>())).Throws(new ServerException());
            lodgingRepositoryMock.Setup(m => m.GetLodgingByNameAndTouristSpot(lodging.Name, touristSpot.Id)).Returns(value: null);

            var touristSpotRepositoryMock = new Mock <ITouristSpotRepository>(MockBehavior.Strict);

            touristSpotRepositoryMock.Setup(m => m.Get(It.IsAny <Guid>())).Returns(touristSpot);
            TouristSpotManagement touristSpotLogic = new TouristSpotManagement(touristSpotRepositoryMock.Object);

            LodgingManagementForImportation lodgingLogic = new LodgingManagementForImportation(lodgingRepositoryMock.Object, touristSpotLogic);

            Lodging resultOfCreateALodging = lodgingLogic.Create(lodging, touristSpot, listOfPicturesPath);
        }
Beispiel #4
0
        public void CreateValidLodgingWithoutTouristSpotTest()
        {
            var lodgingRepositoryMock = new Mock <ILodgingRepository>(MockBehavior.Strict);

            lodgingRepositoryMock.Setup(m => m.Add(It.IsAny <Lodging>()));
            lodgingRepositoryMock.Setup(m => m.GetLodgingByNameAndTouristSpot(lodging.Name, touristSpot.Id)).Returns(value: null);

            var touristSpotRepositoryMock = new Mock <ITouristSpotRepository>(MockBehavior.Strict);

            touristSpotRepositoryMock.Setup(m => m.Get(It.IsAny <Guid>())).Throws(new ClientBusinessLogicException());
            touristSpotRepositoryMock.Setup(m => m.GetTouristSpotByName(It.IsAny <string>())).Returns(value: null);
            touristSpotRepositoryMock.Setup(m => m.Add(It.IsAny <TouristSpot>()));

            var regionMock = new Mock <IRepository <Region> >(MockBehavior.Strict);

            regionMock.Setup(m => m.Get(It.IsAny <Guid>())).Returns(region);
            RegionManagement regionLogic = new RegionManagement(regionMock.Object);

            var categoryMock = new Mock <ICategoryRepository>(MockBehavior.Strict);

            categoryMock.Setup(m => m.Get(It.IsAny <Guid>())).Returns(aCategory);
            CategoryManagement categoryLogic = new CategoryManagement(categoryMock.Object);

            TouristSpotManagement touristSpotLogic = new TouristSpotManagement(touristSpotRepositoryMock.Object, regionLogic, categoryLogic);

            LodgingManagementForImportation lodgingLogic = new LodgingManagementForImportation(lodgingRepositoryMock.Object, touristSpotLogic);

            Lodging resultOfCreateALodging = lodgingLogic.Create(lodging, touristSpot, listOfPicturesPath);

            Lodging lodgingToCompare = new Lodging()
            {
                Id              = resultOfCreateALodging.Id,
                Name            = resultOfCreateALodging.Name,
                QuantityOfStars = resultOfCreateALodging.QuantityOfStars,
                Address         = resultOfCreateALodging.Address,
                Images          = resultOfCreateALodging.Images,
                PricePerNight   = resultOfCreateALodging.PricePerNight,
                IsAvailable     = resultOfCreateALodging.IsAvailable,
                TouristSpot     = resultOfCreateALodging.TouristSpot
            };

            lodgingRepositoryMock.VerifyAll();
            Assert.AreEqual(lodging, lodgingToCompare);
        }