コード例 #1
0
 public WebActionResult Search(SearchInput input)
 {
     using (WebActionExecutor executor = new WebActionExecutor())
     {
         return(executor.executeAction(new SearchAction(), input));
     }
 }
コード例 #2
0
        public void ParentFolderContainedInChildShouldNoGoRecursive()
        {
            using (WebActionExecutor executor = new WebActionExecutor())
            {
                var cc      = this.getGlobalObject <IGlobalContentCreator>();
                var folder1 = cc.getAndAddNewContent <DMSFolder>();
                var folder2 = cc.getAndAddNewContent <DMSFolder>();
                folder1.parent_folders.Add(folder2);
                folder2.parent_folders.Add(folder1);
                var input  = new ContentReference(folder1);
                var action = new GetDmsPathsAction();
                action.input = input;
                action.Authorize();
                var paths = action.Execute().output.paths;

                Assert.AreEqual(1, paths.Count());
                Assert.AreEqual(2, paths.FirstOrDefault().Count());

                input        = new ContentReference(folder2);
                action       = new GetDmsPathsAction();
                action.input = input;
                action.Authorize();
                paths = action.Execute().output.paths;

                Assert.AreEqual(1, paths.Count());
                Assert.AreEqual(2, paths.FirstOrDefault().Count());
            }
        }
コード例 #3
0
ファイル: FileService.cs プロジェクト: uranio-code/Mystery
        public WebActionResult getFile(string content_type_name, string guid, string property_name)
        {
            if (string.IsNullOrEmpty(property_name))
            {
                return(WebActionResultTemplates.InvalidInput);
            }

            var input = new DownloadFileActionInput()
            {
                content_reference = ContentReference.tryGetContentReferece(content_type_name, guid),
                property_name     = property_name,
                response          = HttpContext.Current.Response,
            };

            if (input.content_reference == null)
            {
                return(WebActionResultTemplates.InvalidInput);
            }


            using (WebActionExecutor executor = new WebActionExecutor())
            {
                return(executor.executeAction(new DownloadFileAction(), input));
            }
        }
コード例 #4
0
        public void FolderIn2FolderShouldGet2PathWith2Folder()
        {
            using (WebActionExecutor executor = new WebActionExecutor())
            {
                var cc             = this.getGlobalObject <IGlobalContentCreator>();
                var folder         = cc.getAndAddNewContent <DMSFolder>();
                var parent_folder1 = cc.getAndAddNewContent <DMSFolder>();
                var parent_folder2 = cc.getAndAddNewContent <DMSFolder>();
                folder.parent_folders.Add(parent_folder1);
                folder.parent_folders.Add(parent_folder2);
                var input  = new ContentReference(folder);
                var action = new GetDmsPathsAction();
                action.input = input;
                action.Authorize();
                var paths = action.Execute().output.paths;
                Assert.AreEqual(2, paths.Count());
                Assert.AreEqual(2, paths.FirstOrDefault().Count());
                Assert.AreEqual(2, paths.Skip(1).FirstOrDefault().Count());



                //we don't know the order
                var parent_guids = new HashSet <Guid>()
                {
                    parent_folder1.guid, parent_folder2.guid
                };
                foreach (var path in paths)
                {
                    Assert.IsTrue(parent_guids.Contains(path.FirstOrDefault().guid));
                }
            }
        }
コード例 #5
0
 public WebActionResult getInstance()
 {
     using (WebActionExecutor executor = new WebActionExecutor())
     {
         return(executor.executeAction(new GetInstanceInfoAction()));
     }
 }
コード例 #6
0
 public WebActionResult getApplications()
 {
     using (WebActionExecutor executor = new WebActionExecutor())
     {
         return(executor.executeAction(new GetApplicationsAction()));
     }
 }
コード例 #7
0
        public void getComments()
        {
            using (WebActionExecutor e = new WebActionExecutor())
            {
                var cc = this.getGlobalObject <IGlobalContentCreator>();
                var cd = this.getGlobalObject <IContentDispatcher>();

                // create a version
                DMSVersion created = cc.getNewContent <DMSVersion>();
                created.title = "Pippo";
                cd.Add(created);

                // sign action
                var addCommentAction = new DMSAddCommentAction(created, null);
                var input            = new AddCommentInput();
                input.comment_text = "ciao";
                input.content      = created;

                addCommentAction.input = input;

                WebActionResult result = e.executeAction(addCommentAction);
                Assert.IsTrue(result.isSuccessfull);

                Assert.IsTrue(created.comments.Count() == 1);
            }
        }
コード例 #8
0
        public void SigleReferenceSuggestionsActionCanNotTest()
        {
            using (WebActionExecutor executor = new WebActionExecutor())
            {
                //we add Adriano in db
                TestContentType  adriano = TestContentType.getARandomTestContentType(enforce_a_reference: true);
                ContentsDatabase db      = this.getGlobalObject <ContentsDatabase>();
                db.Add(adriano);
                //we became not admin
                MysterySession session  = this.getGlobalObject <MysterySession>();
                var            was_adim = session.authenticated_user.account_type == UserType.admin;
                if (was_adim)
                {
                    session.authenticated_user.account_type = UserType.normal;
                }

                var result = executor.executeAction(
                    new SigleReferenceSuggestionsAction(),
                    new PropertyEditSuggestionsActionInput
                {
                    content_reference = new Mystery.Content.ContentReference(adriano),
                    property_name     = nameof(TestContentType.not_ediatable_reference),
                    search_text       = null
                });
                Assert.IsTrue(!result.isSuccessfull && result.UnAuthorized);
                if (was_adim)
                {
                    session.authenticated_user.account_type = UserType.admin;
                }
            }
        }
コード例 #9
0
        private string ExecuteTest(Func <string> test)
        {
            MysterySession session = this.getGlobalObject <MysterySession>();

            session.authenticated_user = new Mystery.Users.User();

            using (WebActionExecutor executor = new WebActionExecutor())
            {
                return(executor.executeAction(new TestMakingAction(test), "").message);
            }
        }
コード例 #10
0
 public void RemoveTest()
 {
     using (WebActionExecutor executor = new WebActionExecutor()) {
         IContentContainer container = getContainer();
         TestContentType   c         = TestContentType.getARandomTestContentType(enforce_a_reference: false);
         container.Add(c);
         Assert.IsTrue(container.Remove(c));
         c = TestContentType.getARandomTestContentType(enforce_a_reference: false);
         Assert.IsFalse(container.Remove(c));
         Assert.AreEqual(container.Count, 0);
     }
 }
コード例 #11
0
        public void getLightContentRerefereceTest()
        {
            using (WebActionExecutor executor = new WebActionExecutor()) {
                IContentContainer container = getContainer();
                TestContentType   c         = TestContentType.getARandomTestContentType(enforce_a_reference: false);
                container.Add(c);
                LightContentReferece light_reference = container.GetLightContentRereferece <TestContentType>().FirstOrDefault();

                Assert.AreEqual(light_reference.ReferenceText, c.ReferenceText);
                Assert.AreEqual(light_reference.guid, c.guid);
            }
        }
コード例 #12
0
        public void CheckAddVersionTest()
        {
            using (WebActionExecutor e = new WebActionExecutor())
            {
                var cc = this.getGlobalObject <IGlobalContentCreator>();
                // create a folder
                var folder = cc.getNewContent <DMSFolder>();
                folder.title = "the folder";

                var cd = this.getGlobalObject <IContentDispatcher>();
                cd.Add(folder);

                // create a version inside the folder
                DMSVersion created = cc.getNewContent <DMSVersion>();
                created.title = "Pippo";
                created.parent_folders.Add(folder);
                cd.Add(created);

                // add a new version
                var addNewVersion = new DMSAddVersion(created, null);

                WebActionResult result = e.executeAction(addNewVersion);
                Assert.IsTrue(result.isSuccessfull);

                // reload the original version from the database to get the next version
                Guid version_guid = created.guid;
                created = cd.GetContent <DMSVersion>(version_guid);
                DMSVersion new_version = created.next_version;

                // exist the next version to the original one
                Assert.IsNotNull(new_version);

                // exist a previous version to the new version
                Assert.IsNotNull(new_version.previous_version);

                // created and the previous of the next are the same versions
                Assert.IsTrue(created.samePropertiesValue(new_version.previous_version.value));

                // new version and the next of the previous are the same
                Assert.IsTrue(new_version.samePropertiesValue(created.next_version.value));

                // new version and original are in the same folder
                folder = cd.GetContent <DMSFolder>(folder.guid);
                DMSFolder new_folder = created.parent_folders.FirstOrDefault();

                Assert.IsTrue(folder.samePropertiesValue(new_folder));

                // the new version has version number == 2
                Assert.IsTrue(new_version.version_number == 2);
            }
        }
コード例 #13
0
 public void FloatingVersionShouldHaveNoPaths()
 {
     using (WebActionExecutor executor = new WebActionExecutor())
     {
         var cc      = this.getGlobalObject <IGlobalContentCreator>();
         var version = cc.getAndAddNewContent <DMSVersion>();
         var input   = new ContentReference(version);
         var action  = new GetDmsPathsAction();
         action.input = input;
         action.Authorize();
         var paths = action.Execute().output.paths;
         Assert.AreEqual(0, paths.Count());
     }
 }
コード例 #14
0
        public void getAllByFilterTest()
        {
            using (WebActionExecutor executor = new WebActionExecutor()){
                IContentContainer      container = getContainer();
                List <TestContentType> contents  = new List <TestContentType>(from int i in Enumerable.Range(0, rnd.Next(10) + 2)
                                                                              select TestContentType.getARandomTestContentType(enforce_a_reference: false));

                container.AddContents(contents);


                Assert.IsTrue(container.GetAllByFilter <TestContentType>(
                                  x => x.a_string == contents[0].a_string || x.a_string == contents[1].a_string)
                              .sameContents(contents.Take(2)));
            }
        }
コード例 #15
0
 public void FloatingFolderShouldHaveOnly1PathWithThemInIt()
 {
     using (WebActionExecutor executor = new WebActionExecutor())
     {
         var cc     = this.getGlobalObject <IGlobalContentCreator>();
         var folder = cc.getAndAddNewContent <DMSFolder>();
         var input  = new ContentReference(folder);
         var action = new GetDmsPathsAction();
         action.input = input;
         action.Authorize();
         var paths = action.Execute().output.paths;
         Assert.AreEqual(1, paths.Count());
         Assert.AreEqual(1, paths.FirstOrDefault().Count());
         Assert.AreEqual(folder.guid, paths.FirstOrDefault().FirstOrDefault().guid);
     }
 }
コード例 #16
0
        private void ExecuteTest(Action test)
        {
            Func <string> to_test = () =>
            {
                test();
                return("cool");
            };
            MysterySession session = this.getGlobalObject <MysterySession>();

            session.authenticated_user = new Mystery.Users.User();

            using (WebActionExecutor executor = new WebActionExecutor())
            {
                executor.executeAction(new TestMakingAction(to_test), "");
            }
        }
コード例 #17
0
        public void CreateAContentInDbTest()
        {
            Guid guid = Guid.Empty;

            using (WebActionExecutor e = new WebActionExecutor())
            {
                string json = e.executeAction(new CreateAContentInDb <TestContentType>()).json_output;
                IMysteryJsonConverter converter = this.getGlobalObject <IMysteryJsonConverter>();
                guid = converter.readJson <Guid>(json);
            }

            ContentsDatabase db = this.getGlobalObject <ContentsDatabase>();

            Assert.IsNotNull(db.GetContent <TestContentType>(guid));
            Assert.IsTrue(db.ContainsType <TestContentType>());
        }
コード例 #18
0
        public void ProcessRequest(HttpContext context)
        {
            HttpRequest  request  = context.Request;
            HttpResponse response = context.Response;

            string result = "var MysteryRoutes =  angular.fromJson(";

            using (WebActionExecutor executor = new WebActionExecutor()) {
                var routes = executor.executeAction(new GetRoutes());
                //we have now a string ready to be js but we what it to became an object
                //we need one more parse
                result += this.getGlobalObject <IMysteryJsonConverter>().getJson(routes.json_output);
            };
            result += ");";
            response.Write(result);
        }
コード例 #19
0
 public WebActionResult getInstanceLogo()
 {
     using (WebActionExecutor executor = new WebActionExecutor())
     {
         return(executor.executeAction(
                    new GetInstanceLogoAction(),
                    () => {
             var mystery_instance = this.getGlobalObject <MysteryInstance>();
             return new DownloadFileActionInput()
             {
                 content_reference = new Content.ContentReference(mystery_instance),
                 property_name = nameof(MysteryInstance.logo),
                 response = HttpContext.Current.Response,
             };
         }));
     }
 }
コード例 #20
0
        public void GetEnumeratorTest()
        {
            using (WebActionExecutor executor = new WebActionExecutor()) {
                IContentContainer      container = getContainer();
                List <TestContentType> contents  = new List <TestContentType>(from int i in Enumerable.Range(0, rnd.Next(10) + 2)
                                                                              select TestContentType.getARandomTestContentType(enforce_a_reference: false));

                container.AddContents(contents);
                int tot = 0;
                foreach (IContent c in container)
                {
                    tot += 1;
                }

                Assert.AreEqual(contents.Count, tot);
            }
        }
コード例 #21
0
ファイル: FileService.cs プロジェクト: uranio-code/Mystery
        public WebActionResult PostNewFile()
        {
            var input = new List <AddFileInput>();

            foreach (string filename in HttpContext.Current.Request.Files)
            {
                HttpPostedFile file = HttpContext.Current.Request.Files[filename];
                input.Add(new AddFileInput()
                {
                    filename = file.FileName, stream = file.InputStream
                });
            }
            using (WebActionExecutor executor = new WebActionExecutor())
            {
                return(executor.executeAction(new AddFilesAction(), input));
            }
        }
コード例 #22
0
        public void check_document_deletion()
        {
            using (WebActionExecutor e = new WebActionExecutor())
            {
                var cc = this.getGlobalObject <IGlobalContentCreator>();
                var cd = this.getGlobalObject <IContentDispatcher>();

                // get the RecycleBin, also making sure it exist
                DMSRecycleBin bin = this.getGlobalObject <DMSRecycleBin>();

                // create a version
                DMSVersion created = cc.getNewContent <DMSVersion>();
                var        folder  = cc.getNewContent <DMSFolder>();
                created.title = "Pippo";
                created.parent_folders.Add(folder);
                cd.Add(folder);
                cd.Add(created);

                var add_version_action = new DMSAddVersion(created, null);

                WebActionResult result = e.executeAction(add_version_action);
                created = cd.GetContent <DMSVersion>(created.guid);
                DMSVersion created_2 = created.next_version;
                Assert.IsNotNull(created_2);

                result    = e.executeAction(add_version_action);
                created_2 = cd.GetContent <DMSVersion>(created_2.guid);
                DMSVersion created_3 = created_2.next_version;
                Assert.IsNotNull(created_3);

                // delete action
                var delete_document_action = new DMSDeleteDocument(created, null);
                result = e.executeAction(delete_document_action);
                Assert.IsTrue(result.isSuccessfull);

                created = cd.GetContent <DMSVersion>(created.guid);
                Assert.IsTrue(created.parent_folders.FirstOrDefault().guid == bin.guid);

                created_2 = cd.GetContent <DMSVersion>(created_2.guid);
                Assert.IsTrue(created_2.parent_folders.FirstOrDefault().guid == bin.guid);

                created_3 = cd.GetContent <DMSVersion>(created_3.guid);
                Assert.IsTrue(created_3.parent_folders.FirstOrDefault().guid == bin.guid);
            }
        }
コード例 #23
0
        public void WebContentDispatcherNoExceptionTest()
        {
            IContentDispatcher container = null;
            WebActionExecutor  executor  = null;
            ContentsDatabase   db        = this.getGlobalObject <ContentsDatabase>();
            TestContentType    c         = null;

            ExecuteTest(() => {
                container = WebContentDispatcher.getDispatcher();
                c         = TestContentType.getARandomTestContentType(enforce_a_reference: false);
                container.Add(c);
                Guid guid = c.guid;
                executor  = WebActionExecutor.current;
                return(guid.Tiny());
            });
            Assert.IsTrue(executor.status == WebActionExecutorStatus.done);
            Assert.IsTrue(db.Contains(c));
        }
コード例 #24
0
        public void getAllTest()
        {
            using (WebActionExecutor executor = new WebActionExecutor()) {
                IContentContainer container = getContainer();
                container.Clear();
                List <IContent> contents = new List <IContent>(from int i in Enumerable.Range(0, rnd.Next(10) + 2)
                                                               select TestContentType.getARandomTestContentType(enforce_a_reference: false));

                container.AddContents(contents);

                List <IContent> type2 = new List <IContent>(from int i in Enumerable.Range(0, rnd.Next(10) + 2)
                                                            select new TestContentType2());
                container.AddContents(type2);

                Assert.IsTrue(container.GetAll <TestContentType2>().sameContents(type2));
                Assert.IsTrue(container.GetAll <TestContentType>().sameContents(type2.Union(contents)));
            }
        }
コード例 #25
0
        public void SigleReferenceSuggestionsActionCanTest()
        {
            using (WebActionExecutor executor = new WebActionExecutor())
            {
                TestContentType  adriano = TestContentType.getARandomTestContentType(enforce_a_reference: true);
                ContentsDatabase db      = this.getGlobalObject <ContentsDatabase>();
                db.Add(adriano);

                var result = executor.executeAction(
                    new SigleReferenceSuggestionsAction(),
                    new PropertyEditSuggestionsActionInput {
                    content_reference = new Mystery.Content.ContentReference(adriano),
                    property_name     = nameof(TestContentType.single_reference),
                    search_text       = null
                });
                Assert.IsTrue(result.isSuccessfull);
            }
        }
コード例 #26
0
        public void CreateAContentEditItandDeleteITInDbTest()
        {
            Guid guid = Guid.Empty;

            using (WebActionExecutor e = new WebActionExecutor())
            {
                string json = e.executeAction(new CreateAContentInDb <TestContentType>()).json_output;
                IMysteryJsonConverter converter = this.getGlobalObject <IMysteryJsonConverter>();
                guid = converter.readJson <Guid>(json);
            }
            using (WebActionExecutor e = new WebActionExecutor())
            {
                IContentDispatcher cd = this.getGlobalObject <IContentDispatcher>();
                TestContentType    c  = cd.GetContent <TestContentType>(guid);
                c.a_string = "Carlo";
                e.executeAction(new SaveAContentInDb <TestContentType>(), c);
            }

            Assert.IsTrue(true);
        }
コード例 #27
0
        public void CreateNewDocumentTest()
        {
            using (WebActionExecutor e = new WebActionExecutor())
            {
                var cc     = this.getGlobalObject <IGlobalContentCreator>();
                var folder = cc.getNewContent <DMSFolder>();
                var guid   = folder.guid;
                var cd     = this.getGlobalObject <IContentDispatcher>();
                cd.Add(folder);

                var addDocument = new DMSCreateNewDocument(folder, null);

                WebActionResult result = e.executeAction(addDocument);
                Assert.IsTrue(result.isSuccessfull);

                IDMSContent created = folder.children.FirstOrDefault();

                Assert.IsNotNull(created);


                Assert.IsTrue(((DMSVersion)created).version_number == 1);
            }
        }
コード例 #28
0
        public void ProcessRequest(HttpContext context)
        {
            HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);
            string code = HttpContext.Current.Request["code"];

            using (WebActionExecutor executor = new WebActionExecutor())
            {
                executor.executeAction(new DownloadLiveIDInfoAction(), code);
            }


            HttpRequest  request  = context.Request;
            HttpResponse response = context.Response;


            response.Write(@"
<html>
    <body>
        <h1>just passing by</h1>
        <script>window.opener.loginCallBack(); window.close();</script>
    </body>
</html>");
        }
コード例 #29
0
 public void ShouldBeDisposable()
 {
     using (WebActionExecutor executor = new WebActionExecutor()) { }
     using (IContentContainer c = getContainer()) { }
     Assert.IsTrue(true);
 }
コード例 #30
0
        public void check_workflow_actions_excecution()
        {
            using (WebActionExecutor e = new WebActionExecutor())
            {
                var cc = this.getGlobalObject <IGlobalContentCreator>();
                var cd = this.getGlobalObject <IContentDispatcher>();

                // create a version
                DMSVersion created = cc.getNewContent <DMSVersion>();
                created.title = "Pippo";
                cd.Add(created);

                // sign action
                var sign_version_action = new DMSSignAction(created, null);

                WebActionResult result = e.executeAction(sign_version_action);
                Assert.IsTrue(result.isSuccessfull);

                created = cd.GetContent <DMSVersion>(created.guid);
                Assert.IsTrue(created.wf_Status == DMSConstants.wf_signed);

                // approve action
                var approve_version_action = new DMSVersionApproveAction(created, null);

                result = e.executeAction(approve_version_action);
                Assert.IsTrue(result.isSuccessfull);

                created = cd.GetContent <DMSVersion>(created.guid);
                Assert.IsTrue(created.wf_Status == DMSConstants.wf_approved);


                // under review action
                var under_review_version_action = new DMSVersionUnderReviewAction(created, null);

                result = e.executeAction(under_review_version_action);
                Assert.IsTrue(result.isSuccessfull);

                created = cd.GetContent <DMSVersion>(created.guid);
                Assert.IsTrue(created.wf_Status == DMSConstants.wf_under_review);


                // disapprove action
                var disapprove_version_action = new DMSVersionDisapproveAction(created, null);

                result = e.executeAction(disapprove_version_action);
                Assert.IsTrue(result.isSuccessfull);

                created = cd.GetContent <DMSVersion>(created.guid);
                Assert.IsTrue(created.wf_Status == DMSConstants.wf_disapproved);


                // obsolete action
                var obsolete_version_action = new DMSObsoleteVersionAction(created, null);

                result = e.executeAction(obsolete_version_action);
                Assert.IsTrue(result.isSuccessfull);

                created = cd.GetContent <DMSVersion>(created.guid);
                Assert.IsTrue(created.wf_Status == DMSConstants.wf_obsolete);


                // delete action
                var delete_version_action = new DMSDeleteVersion(created, null);

                result = e.executeAction(delete_version_action);
                Assert.IsTrue(result.isSuccessfull);

                created = cd.GetContent <DMSVersion>(created.guid);
                Assert.IsTrue(created.status == DMSConstants.obsolete);
            }
        }