Example #1
0
        public void Run_UpdateVirtualSpaceAppFlowTest_RenameFileName()
        {
            LOG.Debug("execute method run");

            UpdateVirtualSpaceAppFlowTestSupport.RemoveVirtualFile(1L);
            UpdateVirtualSpaceAppFlowTestSupport.RemovePhysicalFile(1L);
            UpdateVirtualSpaceAppFlowTestSupport.CopyPhysicalSpace_Kinkaku(1L);

            var aclfile = UpdateVirtualSpaceAppFlowTestSupport.CopyVirtualSpace_Kinkaku_aclgene(1L);

            aclfile.MoveTo(Path.Combine(aclfile.DirectoryName, "Kinkaku2.jpg.aclgene"));             //  新しいACLファイル名前にリネームする
            aclfile = new FileInfo(Path.Combine(aclfile.DirectoryName, "Kinkaku2.jpg.aclgene"));

            // ...
            using (var dbc = new AppDbContext())
            {
                var workspace = WorkspaceRepository.Load(dbc, 1L);
                var workflow  = new WorkflowInvoker(new UpdateVirtualSpaceAppFlow());
                workflow.Extensions.Add(new WorkflowExtention(dbc));

                var pstack = new ParameterStack();
                pstack.SetValue("Event", Mogami.Core.Constructions.UpdateVirtualStatusEventType.RENAME);
                pstack.SetValue(ActivityParameterStack.WORKSPACE_FILEPATH, "Kinkaku2.jpg.aclgene");                 // リネーム後のファイル名
                pstack.SetValue(ActivityParameterStack.WORKSPACE, workspace);

                var results = workflow.Invoke(new Dictionary <string, object>
                {
                    { "ParameterStack", pstack }
                });

                dbc.SaveChanges();
            }

            using (var dbc = new AppDbContext())
            {
                var filemapinginfoRepository = new FileMappingInfoRepository(dbc);
                var entity = filemapinginfoRepository.Load(1L);

                var workspace = WorkspaceRepository.Load(dbc, 1L);

                // エンティティの値が変わっていることの確認
                Assert.AreEqual("Kinkaku2.jpg", entity.MappingFilePath);

                // 物理ディレクトリ空間での、ファイル名称が変更していることの確認
                var physicalFileInfo = new FileInfo(Path.Combine(workspace.PhysicalPath, "Kinkaku2.jpg"));
                Assert.IsTrue(physicalFileInfo.Exists);
            }
        }
Example #2
0
        public void Run_UpdateVirtualSpaceAppFlowTest_DeleteFileName()
        {
            UpdateVirtualSpaceAppFlowTestSupport.RemoveVirtualFile(1L);
            UpdateVirtualSpaceAppFlowTestSupport.RemovePhysicalFile(1L);
            UpdateVirtualSpaceAppFlowTestSupport.CopyPhysicalSpace_Kinkaku(1L);

            var aclfile = UpdateVirtualSpaceAppFlowTestSupport.CopyVirtualSpace_Kinkaku_aclgene(1L);

            aclfile.Delete();


            using (var dbc = new AppDbContext())
            {
                var workspace = WorkspaceRepository.Load(dbc, 1L);
                var workflow  = new WorkflowInvoker(new UpdateVirtualSpaceAppFlow());
                workflow.Extensions.Add(new WorkflowExtention(dbc));

                var pstack = new ParameterStack();
                pstack.SetValue("Event", Mogami.Core.Constructions.UpdateVirtualStatusEventType.DELETE);
                pstack.SetValue(ActivityParameterStack.WORKSPACE_FILEPATH, "Kinkaku.jpg.aclgene");                 // 削除したファイル
                pstack.SetValue(ActivityParameterStack.WORKSPACE, workspace);
                pstack.SetValue("WF_DeleteAclHash", "Test");

                var results = workflow.Invoke(new Dictionary <string, object>
                {
                    { "ParameterStack", pstack }
                });

                dbc.SaveChanges();
            }

            using (var dbc = new AppDbContext())
            {
                var workspace = WorkspaceRepository.Load(dbc, 1L);

                // 物理ファイルが削除されていることを確認する
                var physicalFileInfo = new FileInfo(Path.Combine(workspace.PhysicalPath, "Kinkaku.jpg"));
                Assert.IsFalse(physicalFileInfo.Exists);

                var entity = FileMappingInfoRepository.Load(dbc, 1L);
                Assert.IsNull(entity);
            }
        }