public void Can_Update_MediaType_With_PropertyType_Removed() { // Arrange IScopeProvider provider = ScopeProvider; using (IScope scope = provider.CreateScope()) { MediaTypeRepository repository = CreateRepository(provider); MediaType mediaType = MediaTypeBuilder.CreateNewMediaType(); repository.Save(mediaType); // Act IMediaType mediaTypeV2 = repository.Get(mediaType.Id); mediaTypeV2.PropertyGroups["media"].PropertyTypes.Remove("title"); repository.Save(mediaTypeV2); IMediaType mediaTypeV3 = repository.Get(mediaType.Id); // Assert Assert.That(mediaTypeV3.PropertyTypes.Any(x => x.Alias == "title"), Is.False); Assert.That(mediaTypeV2.PropertyGroups.Count, Is.EqualTo(mediaTypeV3.PropertyGroups.Count)); Assert.That(mediaTypeV2.PropertyTypes.Count(), Is.EqualTo(mediaTypeV3.PropertyTypes.Count())); } }
public void Can_Perform_Update_On_MediaTypeRepository() { // Arrange IScopeProvider provider = ScopeProvider; using (IScope scope = provider.CreateScope()) { MediaTypeRepository repository = CreateRepository(provider); MediaType videoMediaType = MediaTypeBuilder.CreateNewMediaType(); repository.Save(videoMediaType); // Act IMediaType mediaType = repository.Get(videoMediaType.Id); mediaType.Thumbnail = "Doc2.png"; mediaType.PropertyGroups["media"].PropertyTypes.Add(new PropertyType(ShortStringHelper, "test", ValueStorageType.Ntext, "subtitle") { Name = "Subtitle", Description = "Optional Subtitle", Mandatory = false, SortOrder = 1, DataTypeId = -88 }); repository.Save(mediaType); bool dirty = ((MediaType)mediaType).IsDirty(); // Assert Assert.That(mediaType.HasIdentity, Is.True); Assert.That(dirty, Is.False); Assert.That(mediaType.Thumbnail, Is.EqualTo("Doc2.png")); Assert.That(mediaType.PropertyTypes.Any(x => x.Alias == "subtitle"), Is.True); } }
public void Cannot_Save_Media_With_Empty_Name() { // Arrange MediaType mediaType = MediaTypeBuilder.CreateNewMediaType(); MediaTypeService.Save(mediaType); IMedia media = MediaService.CreateMedia(string.Empty, -1, Constants.Conventions.MediaTypes.VideoAlias); // Act & Assert Assert.Throws <ArgumentException>(() => MediaService.Save(media)); }
public void Can_Move() { var provider = ScopeProvider; using (var scope = provider.CreateScope()) { var containerRepository = CreateContainerRepository(provider); var repository = CreateRepository(provider); var container1 = new EntityContainer(Constants.ObjectTypes.MediaType) { Name = "blah1" }; containerRepository.Save(container1); var container2 = new EntityContainer(Constants.ObjectTypes.MediaType) { Name = "blah2", ParentId = container1.Id }; containerRepository.Save(container2); IMediaType contentType = MediaTypeBuilder.CreateNewMediaType(); contentType.ParentId = container2.Id; repository.Save(contentType); // create a var contentType2 = (IMediaType) new MediaType(ShortStringHelper, contentType, "hello") { Name = "Blahasdfsadf" }; contentType.ParentId = contentType.Id; repository.Save(contentType2); var result = repository.Move(contentType, container1).ToArray(); Assert.AreEqual(2, result.Length); // re-get contentType = repository.Get(contentType.Id); contentType2 = repository.Get(contentType2.Id); Assert.AreEqual(container1.Id, contentType.ParentId); Assert.AreNotEqual(result.Single(x => x.Entity.Id == contentType.Id).OriginalPath, contentType.Path); Assert.AreNotEqual(result.Single(x => x.Entity.Id == contentType2.Id).OriginalPath, contentType2.Path); } }
public void Can_Verify_PropertyTypes_On_Video_MediaType() { // Arrange IScopeProvider provider = ScopeProvider; using (IScope scope = provider.CreateScope()) { MediaTypeRepository repository = CreateRepository(provider); MediaType mediaType = MediaTypeBuilder.CreateNewMediaType(); repository.Save(mediaType); // Act IMediaType contentType = repository.Get(mediaType.Id); // Assert Assert.That(contentType.PropertyTypes.Count(), Is.EqualTo(2)); Assert.That(contentType.PropertyGroups.Count(), Is.EqualTo(1)); } }
public void Can_Perform_Delete_On_MediaTypeRepository() { // Arrange IScopeProvider provider = ScopeProvider; using (IScope scope = provider.CreateScope()) { MediaTypeRepository repository = CreateRepository(provider); // Act MediaType mediaType = MediaTypeBuilder.CreateNewMediaType(); repository.Save(mediaType); IMediaType contentType2 = repository.Get(mediaType.Id); repository.Delete(contentType2); bool exists = repository.Exists(mediaType.Id); // Assert Assert.That(exists, Is.False); } }
public void Can_Perform_Add_On_MediaTypeRepository() { // Arrange IScopeProvider provider = ScopeProvider; using (IScope scope = provider.CreateScope()) { MediaTypeRepository repository = CreateRepository(provider); // Act MediaType contentType = MediaTypeBuilder.CreateNewMediaType(); repository.Save(contentType); IMediaType fetched = repository.Get(contentType.Id); // Assert Assert.That(contentType.HasIdentity, Is.True); Assert.That(contentType.PropertyGroups.All(x => x.HasIdentity), Is.True); Assert.That(contentType.Path.Contains(","), Is.True); Assert.That(contentType.SortOrder, Is.GreaterThan(0)); TestHelper.AssertPropertyValuesAreEqual(contentType, fetched, ignoreProperties: new[] { "UpdateDate" }); } }