public void When_GetAudio_is_called_with_a_new_Audio_and_an_empty_string_for_setName_then_UploadAudio_on_the_AudioAdapter_is_called_with_that_Audio_and_the_stored_AudioAdapterSettings() { var tracks = AudioTrackCreator.CreateCollection(); var entity = AdapterSettingsCreator.CreateSingle(); entity.SetName = string.Empty; BandRepository .Expect(repository => repository.GetAdapterSettings(Arg <string> .Is.Anything)) .Return(entity) .Repeat.Once(); BandRepository.Replay(); AudioAdapter .Expect(adapter => adapter.GetItems(entity.SetName, entity.OAuthAccessToken)) .Return(tracks) .Repeat.Once(); AudioAdapter.Replay(); var result = Process.GetAudioTracks(); Assert.AreEqual(tracks.Count(), result.Count()); Assert.AreEqual(tracks.First().ResourceUri, result.First().ResourceUri); AudioAdapter.VerifyAllExpectations(); }
public void When_AddAudio_is_called_and_no_OAuthAccessToken_has_been_stored_then_an_InvalidOperationException_is_thrown_and_UploadAudio_on_the_AudioAdapter_is_never_called() { var photo = new MemoryStream(); const string fileName = "photo.jpg"; var entity = AdapterSettingsCreator.CreateSingle(); entity.OAuthAccessToken = null; BandRepository .Expect(repository => repository.GetAdapterSettings(Arg <string> .Is.Anything)) .Return(entity) .Repeat.Once(); BandRepository.Replay(); AudioAdapter .Expect(adapter => adapter.UploadItem(null, null, null, null)) .IgnoreArguments() .Return("") .Repeat.Never(); AudioAdapter.Replay(); Process.AddAudio(photo, fileName); AudioAdapter.VerifyAllExpectations(); }
public void When_GetAudio_is_called_and_no_OAuthAccessToken_has_been_stored_then_an_InvalidOperationException_is_thrown_and_GetAudio_on_the_AudioAdapter_is_never_called() { var photoAdapterSettings = AdapterSettingsCreator.CreateSingle(); photoAdapterSettings.OAuthAccessToken = null; BandRepository .Expect(repository => repository.GetAdapterSettings(Arg <string> .Is.Anything)) .Return(photoAdapterSettings) .Repeat.Once(); BandRepository.Replay(); AudioAdapter .Expect(adapter => adapter.GetItems(null, null)) .IgnoreArguments() .Return(new List <AudioTrack>()) .Repeat.Never(); AudioAdapter.Replay(); Process.GetAudioTracks(0, 10); AudioAdapter.VerifyAllExpectations(); }
public void When_AddAudio_is_called_with_a_new_Audio_then_UploadAudio_on_the_AudioAdapter_is_called_with_that_Audio_and_the_stored_AudioAdapterSettings() { var photo = new MemoryStream(); const string fileName = "photo.jpg"; const string photoId = "http://www.photos.com/myphoto"; var entity = AdapterSettingsCreator.CreateSingle(); BandRepository .Expect(repository => repository.GetAdapterSettings(Arg <string> .Is.Anything)) .Return(entity) .Repeat.Once(); BandRepository.Replay(); AudioAdapter .Expect(adapter => adapter.UploadItem(photo, entity.SetName, fileName, entity.OAuthAccessToken)) .Return(photoId) .Repeat.Once(); AudioAdapter.Replay(); var result = Process.AddAudio(photo, fileName); Assert.AreEqual(photoId, result); AudioAdapter.VerifyAllExpectations(); }