Beispiel #1
0
        public void ShouldDeleteProject()
        {
            var context = new RoughCutEditorEntities();

            using (TransactionScope transactionScope = new TransactionScope())
            {
                var libraryId    = CreateId(typeof(Services.Contracts.Container).Name);
                var dataProvider = new DataProvider(this.loggerService, null, libraryId);

                Item item = Item.CreateItem(1, "title", "Video");
                item.Description = "description";
                item.Resources   = new EntityCollection <Resource>();
                Resource resource = Resource.CreateResource(1, "\test\test.wmv", "Master");
                resource.VideoFormat             = VideoFormat.CreateVideoFormat(1);
                resource.VideoFormat.Duration    = 10;
                resource.VideoFormat.FrameRate   = "Smpte25";
                resource.VideoFormat.ResolutionX = 200;
                resource.VideoFormat.ResolutionY = 500;
                item.Resources.Add(resource);

                context.AddToItem(item);

                TitleTemplate titleTemplate = TitleTemplate.CreateTitleTemplate(1, "TemplateName");

                context.AddToTitleTemplate(titleTemplate);

                context.SaveChanges();

                Project project = Project.CreateProject(1, "creator", DateTime.Now);
                project.Duration         = 100;
                project.Resolution       = "HD";
                project.AutoSaveInterval = 100;
                project.StartTimeCode    = 3600;
                project.SmpteFrameRate   = "Smpte2997NonDrop";
                project.RippleMode       = true;

                Container mediaBin = Container.CreateContainer(1);
                mediaBin.Items.Add(item);

                Container container = Container.CreateContainer(2);
                mediaBin.Containers.Add(container);

                project.MediaBin = mediaBin;

                Comment comment = Comment.CreateComment(1, "Text", "Timeline", "user", DateTime.Today);
                comment.MarkIn  = 1200;
                comment.MarkOut = 1500;

                Comment shotComment = Comment.CreateComment(2, "Text", "Shot", "user", DateTime.Today);
                shotComment.MarkIn  = 170;
                shotComment.MarkOut = 180;

                project.Comments.Add(comment);
                project.Comments.Add(shotComment);

                Track track = Track.CreateTrack(1, "Video");

                Shot shot = Shot.CreateShot(1);
                shot.Item         = item;
                shot.ItemMarkIn   = 150;
                shot.ItemMarkOut  = 200;
                shot.TrackMarkIn  = 500;
                shot.TrackMarkOut = 0;
                shot.Volume       = 5;
                shot.Comments.Add(shotComment);

                track.Shots = new EntityCollection <Shot>();
                track.Shots.Add(shot);

                project.Tracks.Add(track);

                Title title = Title.CreateTitle(1, 600, 100, "Main", "Sub");
                title.TitleTemplate = titleTemplate;

                project.Titles.Add(title);

                context.AddToProject(project);

                context.SaveChanges();

                var retrievedProject = dataProvider.LoadProject(new Uri(string.Format("http://temp/{0}", project.Id)));

                bool result = dataProvider.DeleteProject(new Uri(string.Format("http://temp/{0}", project.Id)));
                var  retrievedDeletedProject = dataProvider.LoadProject(new Uri(string.Format("http://temp/{0}", project.Id)));

                Assert.IsTrue(result);
                Assert.IsNull(retrievedDeletedProject.Id);
            }
        }
Beispiel #2
0
        public void ShouldLoadProject()
        {
            var context = new RoughCutEditorEntities();

            using (TransactionScope transactionScope = new TransactionScope())
            {
                var libraryId    = CreateId(typeof(Services.Contracts.Container).Name);
                var dataProvider = new DataProvider(this.loggerService, null, libraryId);

                Item item = Item.CreateItem(1, "title", "Video");
                item.Description = "description";
                item.Resources   = new EntityCollection <Resource>();
                Resource resource = Resource.CreateResource(1, "\test\test.wmv", "Master");
                resource.VideoFormat             = VideoFormat.CreateVideoFormat(1);
                resource.VideoFormat.Duration    = 10;
                resource.VideoFormat.FrameRate   = "Smpte25";
                resource.VideoFormat.ResolutionX = 200;
                resource.VideoFormat.ResolutionY = 500;
                item.Resources.Add(resource);

                context.AddToItem(item);

                TitleTemplate titleTemplate = TitleTemplate.CreateTitleTemplate(1, "TemplateName");

                context.AddToTitleTemplate(titleTemplate);

                context.SaveChanges();

                Project project = Project.CreateProject(1, "creator", DateTime.Now);
                project.Duration         = 100;
                project.Resolution       = "HD";
                project.AutoSaveInterval = 100;
                project.StartTimeCode    = 3600;
                project.SmpteFrameRate   = "Smpte2997NonDrop";
                project.RippleMode       = true;

                Container mediaBin = Container.CreateContainer(1);
                mediaBin.Items.Add(item);

                Container container = Container.CreateContainer(2);
                container.Items.Add(item);
                mediaBin.Containers.Add(container);

                project.MediaBin = mediaBin;

                Comment comment = Comment.CreateComment(3, "Text", "Timeline", "user", DateTime.Today);
                comment.MarkIn  = 1200;
                comment.MarkOut = 1500;

                Comment shotComment = Comment.CreateComment(4, "Text", "Shot", "user", DateTime.Today);
                shotComment.MarkIn  = 170;
                shotComment.MarkOut = 180;

                project.Comments.Add(comment);
                project.Comments.Add(shotComment);

                Track track = Track.CreateTrack(1, "Video");

                Shot shot = Shot.CreateShot(1);
                shot.Item         = item;
                shot.ItemMarkIn   = 150;
                shot.ItemMarkOut  = 200;
                shot.TrackMarkIn  = 500;
                shot.TrackMarkOut = 0;
                shot.Volume       = 5;
                shot.Comments.Add(shotComment);

                track.Shots = new EntityCollection <Shot>();
                track.Shots.Add(shot);

                project.Tracks.Add(track);

                Title title = Title.CreateTitle(1, 600, 100, "Main", "Sub");
                title.TitleTemplate = titleTemplate;

                project.Titles.Add(title);

                context.AddToProject(project);

                context.SaveChanges();

                var retrievedProject = dataProvider.LoadProject(new Uri(string.Format(IdUrlTemplate, project.Id)));

                Assert.AreEqual(project.Duration, retrievedProject.Duration);
                Assert.AreEqual(project.Resolution, retrievedProject.Resolution);
                Assert.AreEqual(project.AutoSaveInterval, retrievedProject.AutoSaveInterval);
                Assert.AreEqual(project.StartTimeCode, retrievedProject.StartTimeCode);
                Assert.AreEqual(project.SmpteFrameRate, retrievedProject.SmpteFrameRate);
                Assert.AreEqual(project.RippleMode, retrievedProject.RippleMode);
                Assert.AreEqual(project.Creator, retrievedProject.Creator);
                Assert.IsNotNull(retrievedProject.MediaBin);
                Assert.AreEqual(string.Format(IdUrlTemplate, mediaBin.Id), retrievedProject.MediaBin.Id.ToString());
                Assert.AreEqual(1, retrievedProject.MediaBin.Items.Count);
                Assert.AreEqual(1, retrievedProject.MediaBin.Containers.Count);
                Assert.AreEqual(0, retrievedProject.MediaBin.Containers[0].Items.Count);
                Assert.AreEqual(1, retrievedProject.Sequences[0].Tracks.Count);
                Assert.AreEqual(string.Format(IdUrlTemplate, track.Id), retrievedProject.Sequences[0].Tracks[0].Id.ToString());
                Assert.AreEqual(track.TrackType, retrievedProject.Sequences[0].Tracks[0].TrackType);
                Assert.AreEqual(track.Shots.Count, retrievedProject.Sequences[0].Tracks[0].Shots.Count);
                Assert.AreEqual(string.Format(IdUrlTemplate, shot.Id), retrievedProject.Sequences[0].Tracks[0].Shots[0].Id.ToString());
                Assert.AreEqual(shot.TrackMarkIn, retrievedProject.Sequences[0].Tracks[0].Shots[0].TrackAnchor.MarkIn);
                Assert.AreEqual(shot.TrackMarkOut, retrievedProject.Sequences[0].Tracks[0].Shots[0].TrackAnchor.MarkOut);
                Assert.AreEqual(shot.ItemMarkIn, retrievedProject.Sequences[0].Tracks[0].Shots[0].SourceAnchor.MarkIn);
                Assert.AreEqual(shot.ItemMarkOut, retrievedProject.Sequences[0].Tracks[0].Shots[0].SourceAnchor.MarkOut);
                Assert.AreEqual(shot.Volume, retrievedProject.Sequences[0].Tracks[0].Shots[0].Volume);
                Assert.AreEqual(1, retrievedProject.Sequences[0].Tracks[0].Shots[0].Comments.Count);
                Assert.AreEqual(string.Format(IdUrlTemplate, shotComment.Id), retrievedProject.Sequences[0].Tracks[0].Shots[0].Comments[0].Id.ToString());
                Assert.AreEqual(shotComment.Creator, retrievedProject.Sequences[0].Tracks[0].Shots[0].Comments[0].Creator);
                Assert.AreEqual(shotComment.Created, retrievedProject.Sequences[0].Tracks[0].Shots[0].Comments[0].Created);
                Assert.AreEqual(shotComment.Text, retrievedProject.Sequences[0].Tracks[0].Shots[0].Comments[0].Text);
                Assert.AreEqual(shotComment.CommentType, retrievedProject.Sequences[0].Tracks[0].Shots[0].Comments[0].Type);
                Assert.AreEqual(shotComment.MarkIn, retrievedProject.Sequences[0].Tracks[0].Shots[0].Comments[0].MarkIn);
                Assert.AreEqual(shotComment.MarkOut, retrievedProject.Sequences[0].Tracks[0].Shots[0].Comments[0].MarkOut);
                Assert.AreEqual(2, retrievedProject.Comments.Count);
                Assert.AreEqual(string.Format(IdUrlTemplate, comment.Id), retrievedProject.Comments[1].Id.ToString());
                Assert.AreEqual(comment.Created, retrievedProject.Comments[1].Created);
                Assert.AreEqual(comment.Creator, retrievedProject.Comments[1].Creator);
                Assert.AreEqual(comment.Text, retrievedProject.Comments[1].Text);
                Assert.AreEqual(comment.CommentType, retrievedProject.Comments[1].Type);
                Assert.AreEqual(comment.MarkIn, retrievedProject.Comments[1].MarkIn);
                Assert.AreEqual(comment.MarkOut, retrievedProject.Comments[1].MarkOut);
                Assert.AreEqual(string.Format(IdUrlTemplate, shotComment.Id), retrievedProject.Comments[0].Id.ToString());
                Assert.AreEqual(shotComment.Created, retrievedProject.Comments[0].Created);
                Assert.AreEqual(shotComment.Creator, retrievedProject.Comments[0].Creator);
                Assert.AreEqual(shotComment.Text, retrievedProject.Comments[0].Text);
                Assert.AreEqual(shotComment.CommentType, retrievedProject.Comments[0].Type);
                Assert.AreEqual(shotComment.MarkIn, retrievedProject.Comments[0].MarkIn);
                Assert.AreEqual(shotComment.MarkOut, retrievedProject.Comments[0].MarkOut);
                Assert.AreEqual(string.Format(IdUrlTemplate, item.Id), retrievedProject.Sequences[0].Tracks[0].Shots[0].Source.Id.ToString());
                Assert.AreEqual(item.Title, retrievedProject.Sequences[0].Tracks[0].Shots[0].Source.Title);
                Assert.AreEqual(item.Description, retrievedProject.Sequences[0].Tracks[0].Shots[0].Source.Description);
                Assert.IsInstanceOfType(retrievedProject.Sequences[0].Tracks[0].Shots[0].Source, typeof(VideoItem));
                Assert.AreEqual(string.Format(IdUrlTemplate, item.Resources.First().Id), retrievedProject.Sequences[0].Tracks[0].Shots[0].Source.Resources[0].Id.ToString());
                Assert.AreEqual(item.Resources.First().Ref, retrievedProject.Sequences[0].Tracks[0].Shots[0].Source.Resources[0].Ref);
                Assert.AreEqual(item.Resources.First().VideoFormat.Duration, ((VideoItem)retrievedProject.Sequences[0].Tracks[0].Shots[0].Source).Duration);
                Assert.AreEqual(item.Resources.First().VideoFormat.FrameRate, ((VideoItem)retrievedProject.Sequences[0].Tracks[0].Shots[0].Source).FrameRate.ToString());
                Assert.AreEqual(item.Resources.First().VideoFormat.ResolutionX, ((VideoItem)retrievedProject.Sequences[0].Tracks[0].Shots[0].Source).Width);
                Assert.AreEqual(item.Resources.First().VideoFormat.ResolutionY, ((VideoItem)retrievedProject.Sequences[0].Tracks[0].Shots[0].Source).Height);
                Assert.AreEqual(1, retrievedProject.Titles.Count);
                Assert.AreEqual(string.Format(IdUrlTemplate, title.Id), retrievedProject.Titles[0].Id.ToString());
                Assert.AreEqual(title.MainText, retrievedProject.Titles[0].TextBlockCollection[0].Text);
                Assert.AreEqual(title.SubText, retrievedProject.Titles[0].TextBlockCollection[1].Text);
                Assert.AreEqual(title.TrackMarkIn, retrievedProject.Titles[0].TrackAnchor.MarkIn);
                Assert.AreEqual(title.TrackMarkOut, retrievedProject.Titles[0].TrackAnchor.MarkOut);
                Assert.AreEqual(string.Format(IdUrlTemplate, title.TitleTemplate.Id), retrievedProject.Titles[0].TitleTemplate.Id.ToString());
                Assert.AreEqual(title.TitleTemplate.TemplateName, retrievedProject.Titles[0].TitleTemplate.TemplateName);
            }
        }