Exemple #1
0
        public void GetLocations_TripExistsWithLocations_ReturnsList()
        {
            Guid tripID = Guid.NewGuid();
            Trip trip = new Trip()
            {
                ID = tripID,
                Posts = new List<Post>(),
            };

            Post Posts1 = new Post()
            {
                ID = Guid.NewGuid(),
                PostLat = "123",
                PostLong = "145",
                PostDate = DateTime.Now
            };

            Post Posts2 = new Post()
            {
                ID = Guid.NewGuid(),
                PostLat = "123",
                PostLong = "145",
                PostDate = DateTime.Now
            };

            trip.Posts.Add(Posts1);
            trip.Posts.Add(Posts2);

            Mock<ITripRepository> TripRepository = new Mock<ITripRepository>();
            Mock<ILoggerService> loggerService = new Mock<ILoggerService>();

            TripRepository.Setup(o => o.GetByID(It.IsAny<Guid>())).Returns(trip);

            TripService Service = new TripService(TripRepository.Object, loggerService.Object);

            IList<Location> Locations = Service.GetLocations(Guid.NewGuid());

            CollectionAssert.IsNotEmpty(Locations);
        }
Exemple #2
0
        public void GetLocations_TripWithNoLocations_EmptyList()
        {
            Guid tripID = Guid.NewGuid();
            Trip trip = new Trip()
            {
                ID = tripID,
                Posts = new List<Post>(),
            };

            Mock<ITripRepository> TripRepository = new Mock<ITripRepository>();
            Mock<ILoggerService> loggerService = new Mock<ILoggerService>();

            TripRepository.Setup(o => o.GetByID(It.IsAny<Guid>())).Returns(trip);

            TripService Service = new TripService(TripRepository.Object, loggerService.Object);

            IList<Location> Locations = Service.GetLocations(tripID);
            Assert.IsEmpty(Locations);
        }
Exemple #3
0
        public void GetLocations_NonExistingTrip_NullReturn()
        {
            Mock<ITripRepository> TripRepository = new Mock<ITripRepository>();
            Mock<ILoggerService> loggerService = new Mock<ILoggerService>();

            TripRepository.SetupSequence(o => o.GetByID(It.IsAny<Guid>())).Returns(null);

            TripService Service = new TripService(TripRepository.Object, loggerService.Object);
            IList<Location> Locations = Service.GetLocations(Guid.NewGuid());

            Assert.IsNull(Locations);
        }