示例#1
0
        public void AddAccommodationNullInputTest2()
        {
            Accommodation accommodation = new Accommodation()
            {
                Id            = 5,
                Name          = "abom",
                Address       = "ag",
                Images        = null,
                ContactNumber = "a",
                Information   = "a",
                PricePerNight = 5,
                SpotId        = 3,
            };

            TouristicSpot spot = new TouristicSpot()
            {
                Name = "a",
                Id   = 6
            };
            var mockAccommodation = new Mock <IAccommodationRepository>(MockBehavior.Strict);

            mockAccommodation.Setup(p => p.AddAndSave(It.IsAny <Accommodation>())).Returns(accommodation);
            mockAccommodation.Setup(p => p.GetByName(It.IsAny <string>())).Returns(accommodation);
            var mockTouristicSpot = new Mock <ITouristicSpotRepository>(MockBehavior.Strict);

            mockTouristicSpot.Setup(p => p.GetById(It.IsAny <int>())).Returns(spot);
            var mockReview  = new Mock <IReviewRepository>(MockBehavior.Strict);
            var mockBooking = new Mock <IBookingRepository>(MockBehavior.Strict);
            var logic       = new AccommodationLogic(mockAccommodation.Object, mockTouristicSpot.Object, mockReview.Object, mockBooking.Object);

            var result = logic.AddAccommodation(accommodation);
        }
示例#2
0
        public void AddAccommodationTest2()
        {
            List <AccommodationImage> images = new List <AccommodationImage>();
            AccommodationImage        image  = new AccommodationImage()
            {
                Image           = "image",
                AccommodationId = 5
            };

            images.Add(image);
            Accommodation accommodation = new Accommodation()
            {
                Id            = 5,
                Name          = "abom",
                Address       = "ag",
                Images        = images,
                ContactNumber = "a",
                Information   = "a",
                PricePerNight = 5,
                SpotId        = 3,
            };
            TouristicSpot spot = new TouristicSpot()
            {
                Name = "a",
                Id   = 6
            };
            var mockAccommodation = new Mock <IAccommodationRepository>(MockBehavior.Strict);

            mockAccommodation.Setup(p => p.AddAndSave(It.IsAny <Accommodation>())).Returns(accommodation);
            mockAccommodation.Setup(p => p.GetByName(It.IsAny <string>())).Returns <Accommodation>(null);
            var mockTouristicSpot = new Mock <ITouristicSpotRepository>(MockBehavior.Strict);
            var mockReview        = new Mock <IReviewRepository>(MockBehavior.Strict);

            mockTouristicSpot.Setup(p => p.GetById(It.IsAny <int>())).Returns(spot);
            var mockBooking = new Mock <IBookingRepository>(MockBehavior.Strict);
            var logic       = new AccommodationLogic(mockAccommodation.Object, mockTouristicSpot.Object, mockReview.Object, mockBooking.Object);

            var result = logic.AddAccommodation(accommodation);

            mockAccommodation.VerifyAll();
            mockTouristicSpot.VerifyAll();
            Assert.IsTrue(result.Equals(accommodation));
        }