private DomainObjects.Resource<Widget> NewWidgetResource(string type, string key, int seq, string widgetName, int pageId, DateTime? effectiveDate = null, DateTime? expirationDate = null) { var resource = new DomainObjects.Resource<Widget>(type, key, seq, new Widget() { Name = widgetName }, new { PageId = pageId }); resource.EffectiveDate = effectiveDate; resource.ExpirationDate = expirationDate; return resource; }
public void BasicGetPurge() { var type = "foo3"; _repo.DeleteAll<string>(type); var resources = _repo.GetResources<string>(type); Assert.AreEqual(0, resources.Count); var resource = new DomainObjects.Resource<string>() { Type = type, Sequence = 1, Data = "BAR" }; resource = _repo.StoreResource(resource, _userId); _repo.SaveChanges(); Assert.IsNotNull(_repo.GetResourceById<string>(resource.Id)); resources = _repo.GetResources<string>(type); Assert.AreEqual(1, resources.Count); _repo.Delete<string>(resource); _repo.SaveChanges(); resources = _repo.GetResources<string>(type); Assert.AreEqual(0, resources.Count); }
public void BinaryResourceTest() { var type = "Image"; var key = "home/codeendeavors2.png"; _repo.DeleteAll<BinaryResource>(type); var path = Path.Combine(Environment.CurrentDirectory, @"..\..\..\CodeEndeavors.ResourceManager.UnitTest"); var binaryResource = new DomainObjects.Resource<BinaryResource>(type, key, null, new BinaryResource() { MimeType = "image/png", Name = "codeendeavors2.png", Path = Path.Combine(path, "codeendeavors2.png") }, new {ModuleId = 123}); binaryResource.Data.WriteStream(Path.Combine(path, "codeendeavors.png")); _repo.StoreResource(binaryResource, _userId); _repo.SaveChanges(); Assert.IsTrue(System.IO.File.Exists(binaryResource.Data.Path)); var image = _repo.GetResourceData<BinaryResource>(type, key, r => r.Scope.ModuleId == 123, null); Assert.AreEqual("codeendeavors2.png", image.Name); Assert.IsTrue(image.Size.HasValue); System.IO.File.Delete(image.Path); Assert.IsFalse(System.IO.File.Exists(image.Path)); }