예제 #1
0
        public async Task GetImageListByEarthDate_Bad_RoverName()
        {
            var marsRepoMock = new Mock <IMarsRepository>();

            marsRepoMock.Setup(
                rmr => rmr.GetByEarthDate(It.IsAny <string>(), It.IsAny <DateTime>(), It.IsAny <string>(), It.IsAny <int>()))
            .Returns(Task.FromResult((Photos)null));

            var service = new ImagingServices(
                _loggerImaging.Object,
                marsRepoMock.Object);

            var response = await service.GetImageListByEarthDate("Bad Robot", string.Empty, new DateTime(2017, 2, 27), 0);


            Assert.Null(response);
        }
예제 #2
0
        public async Task GetImageListByEarthDate_Good_Parameters()
        {
            var marsRepoMock = new Mock <IMarsRepository>();

            marsRepoMock.Setup(
                rmr => rmr.GetByEarthDate(It.IsAny <string>(), It.IsAny <DateTime>(), It.IsAny <string>(), It.IsAny <int>()))
            .Returns(Task.FromResult(RoverPhotos));

            var service = new ImagingServices(
                _loggerImaging.Object,
                marsRepoMock.Object);

            var response = await service.GetImageListByEarthDate("Curiosity", string.Empty, new DateTime(2017, 2, 27), 0);

            Assert.Equal(RoverPhotos.photos[0].id, response.photos[0].id);
            Assert.Equal(RoverPhotos.photos[0].camera.id, response.photos[0].camera.id);
            Assert.Equal(RoverPhotos.photos[0].rover.id, response.photos[0].rover.id);
            Assert.Equal(RoverPhotos.photos[0].rover.cameras[0].id, response.photos[0].rover.cameras[0].id);
        }