public IMediaBuilder <TMediaType> Upload <TMediaType>(string file, Action <TMediaType> build = null) where TMediaType : MediaData { if (!File.Exists(file)) { throw new FileNotFoundException($"could not find file {file}, verify that you have set \"Copy to Output Directory = Copy always\""); } var command = new UploadFile( IpsumGenerator.Generate(3, false).Replace(" ", "_"), file, Fixture.GetContentType(typeof(TMediaType)), GetParent() ); if (build != null) { command.Build = p => build.Invoke((TMediaType)p); } var media = command.Execute(); _medias.Add(media); return(new MediaBuilder <TMediaType>(Fixture, _medias)); }
public IMediaBuilder <TMediaType> Upload <TMediaType>(string file, ContentReference parent, Action <TMediaType> build = null) where TMediaType : MediaData { ValidateFile(file); var command = new UploadFile( IpsumGenerator.Generate(3, false).Replace(" ", "_"), file, Fixture.GetContentType(typeof(TMediaType)), parent ); command.Build = CreateBuild(build); var media = command.Execute(); _medias.Add(media); return(new MediaBuilder <TMediaType>(Fixture, _medias)); }
private IMediaBuilder <TMediaType> UploadWhenHasLatest <TMediaType>(string file, Action <TMediaType> build) where TMediaType : MediaData { foreach (var latest in Fixture.Latest) { var command = new UploadFile( IpsumGenerator.Generate(3, false).Replace(" ", "_"), file, Fixture.GetContentType(typeof(TMediaType)), GetParent(latest) ); command.Build = CreateBuild(build); var media = command.Execute(); _medias.Add(media); } return(new MediaBuilder <TMediaType>(Fixture, _medias)); }
public IMediaBuilder <TMediaType> Upload <TMediaType>(string file, Action <TMediaType> build = null) where TMediaType : MediaData { ValidateFile(file); if (Fixture.Latest.Count > 0) { return(UploadWhenHasLatest(file, build)); } var command = new UploadFile( IpsumGenerator.Generate(3, false).Replace(" ", "_"), file, Fixture.GetContentType(typeof(TMediaType)), GetParent() ); command.Build = CreateBuild(build); var media = command.Execute(); _medias.Add(media); return(new MediaBuilder <TMediaType>(Fixture, _medias)); }