コード例 #1
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;
                }
            }
        }
コード例 #2
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));
            }
        }
コード例 #3
0
 public WebActionResult getApplications()
 {
     using (WebActionExecutor executor = new WebActionExecutor())
     {
         return(executor.executeAction(new GetApplicationsAction()));
     }
 }
コード例 #4
0
 public WebActionResult Search(SearchInput input)
 {
     using (WebActionExecutor executor = new WebActionExecutor())
     {
         return(executor.executeAction(new SearchAction(), input));
     }
 }
コード例 #5
0
 public WebActionResult getInstance()
 {
     using (WebActionExecutor executor = new WebActionExecutor())
     {
         return(executor.executeAction(new GetInstanceInfoAction()));
     }
 }
コード例 #6
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);
            }
        }
コード例 #7
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);
            }
        }
コード例 #8
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);
            }
        }
コード例 #9
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);
            }
        }
コード例 #10
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>());
        }
コード例 #11
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), "");
            }
        }
コード例 #12
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);
        }
コード例 #13
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,
             };
         }));
     }
 }
コード例 #14
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));
            }
        }
コード例 #15
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);
            }
        }
コード例 #16
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);
        }
コード例 #17
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>");
        }
コード例 #18
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);
            }
        }
コード例 #19
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);
            }
        }