public async Task GetMarsRoverPhotos_Return_Results_Download_Photos_NotExists() { _marsRaverPhotoRepoMock.Setup(x => x.GetMarsRoverPhotosByDate("2017-02-27")).Returns(Task.FromResult(MarsRoverPhotos("2017-02-27"))); _marsRaverPhotoRepoMock.Setup(x => x.GetMarsRoverPhotosByDate("2018-06-02")).Returns(Task.FromResult(MarsRoverPhotos("2018-06-02"))); _marsRaverPhotoRepoMock.Setup(x => x.GetMarsRoverPhotosByDate(It.IsNotIn <string>(new[] { "2017-02-27", "2018-06-02" }))).Returns(Task.FromResult(new List <MarsRoverPhoto>())); _marsRoverPhotoController = new MarsRoverPhotoController(_marsRaverPhotoRepoMock.Object); var photos = await _marsRoverPhotoController.GetMarsRoverPhotos(); string earthDate = "2017-02-27"; string path = Path.Combine(Directory.GetCurrentDirectory(), $@"Downloads\{earthDate}"); bool directoryExists = Directory.Exists(path); Assert.True(directoryExists); string imgFilePath = Path.Combine(Directory.GetCurrentDirectory(), $@"Downloads\{earthDate}\3.JPG"); Assert.False(System.IO.File.Exists(imgFilePath)); earthDate = "2018-06-02"; path = Path.Combine(Directory.GetCurrentDirectory(), $@"Downloads\{earthDate}"); Assert.True(Directory.Exists(path)); imgFilePath = Path.Combine(Directory.GetCurrentDirectory(), $@"Downloads\{earthDate}\3.JPG"); Assert.True(System.IO.File.Exists(imgFilePath)); imgFilePath = Path.Combine(Directory.GetCurrentDirectory(), $@"Downloads\{earthDate}\1.JPG"); Assert.False(System.IO.File.Exists(imgFilePath)); }
public async Task GetMarsRoverPhotos_Return_Results() { _marsRaverPhotoRepoMock.Setup(x => x.GetMarsRoverPhotosByDate("2017-02-27")).Returns(Task.FromResult(MarsRoverPhotos("2017-02-27"))); _marsRaverPhotoRepoMock.Setup(x => x.GetMarsRoverPhotosByDate(It.IsNotIn <string>(new[] { "2017-02-27" }))).Returns(Task.FromResult(new List <MarsRoverPhoto>())); _marsRoverPhotoController = new MarsRoverPhotoController(_marsRaverPhotoRepoMock.Object); var photos = await _marsRoverPhotoController.GetMarsRoverPhotos(); var retList = (List <MarsRoverPhoto>)(((OkObjectResult)photos).Value); Assert.True(retList.Count == 2); }