/// <summary> /// Sets up and initializes the tests. /// </summary> protected override void Init() { services = new ServiceCollection() .AddDbContext <Db>(options => options.UseSqlite("Filename=./piranha.tests.db")) .AddPiranhaEF() .AddSingleton <IStorage, Local.FileStorage>() .BuildServiceProvider(); using (var api = new Api(GetDb(), new ContentServiceFactory(services), storage)) { Piranha.App.Init(); contentService = new ContentService <Page, PageField, Models.PageBase>(services, Piranha.App.Mapper); // Add media using (var stream = File.OpenRead("../../../Assets/HLD_Screenshot_01_mech_1080.png")) { var image1 = new Models.StreamMediaContent() { Filename = "HLD_Screenshot_01_mech_1080.png", Data = stream }; api.Media.Save(image1); image1Id = image1.Id.Value; } } }
protected override void Init() { using (var api = CreateApi()) { Piranha.App.Init(api); // Add media folders var folder1 = new MediaFolder { Name = "Images" }; api.Media.SaveFolder(folder1); folder1Id = folder1.Id; // Add media using (var stream = File.OpenRead("../../../Assets/HLD_Screenshot_01_mech_1080.png")) { var image1 = new Models.StreamMediaContent { Filename = "HLD_Screenshot_01_mech_1080.png", Data = stream }; api.Media.Save(image1); image1Id = image1.Id.Value; // Add some additional meta data var image = api.Media.GetById(image1Id); image.Title = "Screenshot"; image.AltText = "This is a screenshot"; image.Description = "Screenshot from Hyper Light Drifter"; image.Properties["Game"] = "Hyper Light Drifter"; api.Media.SaveAsync(image).GetAwaiter().GetResult(); } using (var stream = File.OpenRead("../../../Assets/HLD_Screenshot_01_rise_1080.png")) { var image2 = new Models.StreamMediaContent { FolderId = folder1Id, Filename = "HLD_Screenshot_01_rise_1080.png", Data = stream }; api.Media.Save(image2); image2Id = image2.Id.Value; } using (var stream = File.OpenRead("../../../Assets/HLD_Screenshot_01_robot_1080.png")) { var image3 = new Models.StreamMediaContent { Filename = "HLD_Screenshot_01_robot_1080.png", Data = stream }; api.Media.Save(image3); image3Id = image3.Id.Value; } } }
protected override void Init() { using (var api = new Api(options, storage)) { using (var stream = File.OpenRead("../../../Assets/HLD_Screenshot_01_mech_1080.png")) { var image1 = new Models.StreamMediaContent() { Filename = "HLD_Screenshot_01_mech_1080.png", ContentType = "image/png", Data = stream }; api.Media.Save(image1); } } }
protected override void Init() { using (var api = new Api(services, GetDb(), storage, cache)) { Piranha.App.Init(api); // Add media folders var folder1 = new Data.MediaFolder() { Name = "Images" }; api.Media.SaveFolder(folder1); folder1Id = folder1.Id; // Add media using (var stream = File.OpenRead("../../../Assets/HLD_Screenshot_01_mech_1080.png")) { var image1 = new Models.StreamMediaContent() { Filename = "HLD_Screenshot_01_mech_1080.png", Data = stream }; api.Media.Save(image1); image1Id = image1.Id.Value; } using (var stream = File.OpenRead("../../../Assets/HLD_Screenshot_01_rise_1080.png")) { var image2 = new Models.StreamMediaContent() { FolderId = folder1Id, Filename = "HLD_Screenshot_01_rise_1080.png", Data = stream }; api.Media.Save(image2); image2Id = image2.Id.Value; } using (var stream = File.OpenRead("../../../Assets/HLD_Screenshot_01_robot_1080.png")) { var image3 = new Models.StreamMediaContent() { Filename = "HLD_Screenshot_01_robot_1080.png", Data = stream }; api.Media.Save(image3); image3Id = image3.Id.Value; } } }
public void Insert() { using (var api = new Api(services, GetDb(), storage, cache)) { using (var stream = File.OpenRead("../../../Assets/HLD_Screenshot_BETA_entrance.png")) { var image = new Models.StreamMediaContent() { Filename = "HLD_Screenshot_BETA_entrance.png", Data = stream }; api.Media.Save(image); Assert.NotNull(image.Id); image4Id = image.Id.Value; } } }
protected override void Init() { using (var api = new Api(services, GetDb(), storage, null, processor)) { App.Init(api); // Add media using (var stream = File.OpenRead("../../../Assets/HLD_Screenshot_01_mech_1080.png")) { var image1 = new Models.StreamMediaContent() { Filename = "HLD_Screenshot_01_mech_1080.png", Data = stream }; api.Media.Save(image1); imageId = image1.Id.Value; } } }
public override async Task InitializeAsync() { using (var api = CreateApi()) { // Add media using (var stream = File.OpenRead("../../../Assets/HLD_Screenshot_01_mech_1080.png")) { var image1 = new Models.StreamMediaContent() { Filename = "HLD_Screenshot_01_mech_1080.png", Data = stream }; await api.Media.SaveAsync(image1); imageId = image1.Id.Value; } } }
public async Task Insert() { using (var api = CreateApi()) { using (var stream = File.OpenRead("../../../Assets/HLD_Screenshot_BETA_entrance.png")) { var image = new Models.StreamMediaContent { Filename = "HLD_Screenshot_BETA_entrance.png", Data = stream }; await api.Media.SaveAsync(image); Assert.NotNull(image.Id); image4Id = image.Id.Value; } } }
/// <summary> /// Sets up and initializes the tests. /// </summary> public override async Task InitializeAsync() { using (var api = CreateApi()) { Piranha.App.Init(api); contentService = new ContentService <Page, PageField, Models.PageBase>(new ContentFactory(_services), Piranha.Data.EF.Module.Mapper); // Add media using (var stream = File.OpenRead("../../../Assets/HLD_Screenshot_01_mech_1080.png")) { var image1 = new Models.StreamMediaContent { Filename = "HLD_Screenshot_01_mech_1080.png", Data = stream }; await api.Media.SaveAsync(image1); image1Id = image1.Id.Value; } } }