public async Task GetExportProfileReturnsProfileAndPhotoDataTest() { var profileId = Guid.NewGuid(); var profile = ModelBuilder.Model.Create <Profile>(); var photos = ModelBuilder.Model.Ignoring <Photo>(x => x.Data).Create <List <Photo> >(); var photoData = ModelBuilder.Model.Create <byte[]>(); var profileQuery = Substitute.For <IProfileQuery>(); var photoQuery = Substitute.For <IPhotoQuery>(); using (var inputStream = new MemoryStream(photoData)) { photos.SetEach(x => x.Data = inputStream); using (var tokenSource = new CancellationTokenSource()) { profileQuery.GetProfile(profileId, tokenSource.Token).Returns(profile); photoQuery.GetPhotos(profileId, tokenSource.Token).Returns(photos); var sut = new ExportQuery(profileQuery, photoQuery); var actual = await sut.GetExportProfile(profileId, tokenSource.Token).ConfigureAwait(false); actual.Should().BeEquivalentTo(profile, opt => opt.ExcludingMissingMembers()); actual.Photos.Should().BeEquivalentTo(photos, opt => opt.Excluding(x => x.Data)); actual.Photos.All(x => x.Data.SequenceEqual(photoData)).Should().BeTrue(); } } }
public void GetExportProfileThrowsExceptionWithEmptyProfileIdTest() { var profileQuery = Substitute.For <IProfileQuery>(); var photoQuery = Substitute.For <IPhotoQuery>(); var sut = new ExportQuery(profileQuery, photoQuery); Func <Task> action = async() => await sut.GetExportProfile(Guid.Empty, CancellationToken.None).ConfigureAwait(false); action.Should().Throw <ArgumentException>(); }