Compare commits
329 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| fcaa4ad8d6 | |||
| bf70e208ad | |||
| 26f705b129 | |||
| 9e3941e8e1 | |||
| 7886b7814d | |||
| cf7756a96d | |||
| 20347c1ccd | |||
| 36255709e6 | |||
| 506ed9f866 | |||
| f87bec398d | |||
| 1e5b6a6a0f | |||
| a2f8e92098 | |||
| 9d5af4ad5e | |||
| ae154885e4 | |||
| 2c29e422bc | |||
| 2d6b8712d5 | |||
| 81aad6fc64 | |||
| 58280e7d63 | |||
| c856795cb7 | |||
| 2d514ac09e | |||
| 8e8b8bdea1 | |||
| d8c781f97f | |||
| 6502470708 | |||
| 680396daab | |||
| 4e4ea59433 | |||
| 40f7e87e04 | |||
| fbce20d0c3 | |||
| 982fa26b7e | |||
| c3055ca43f | |||
| 4cca364511 | |||
| 9e0ed94d77 | |||
| 374147a1a0 | |||
| 5f0fe69c82 | |||
| e325e06efc | |||
| 5e7db1047b | |||
| 61fe0a4a93 | |||
| aa1aabef3a | |||
| d1c865480f | |||
| c427c51053 | |||
| 08070e319a | |||
| ac2ebc4071 | |||
| d4c79a0915 | |||
| 61f9845db0 | |||
| 43e23829ae | |||
| 5774ce68c7 | |||
| b9af6f631a | |||
| cd401f5e37 | |||
| 75c2b07ad3 | |||
| 969fe30f6e | |||
| 0f90d357cf | |||
| d955daab0f | |||
| 617b17ca9e | |||
| 9e3d7a1cce | |||
| f04071d7c7 | |||
| 2cce9395da | |||
| 6ad56863d4 | |||
| 2703fa7ea2 | |||
| b3c6654d41 | |||
| 0071651621 | |||
| 4dbc27f1fe | |||
| 3f8bbc2f02 | |||
| 999be9c578 | |||
| b36b1693dd | |||
| 99b2192ab7 | |||
| 5230f55f44 | |||
| f93fee28dd | |||
| fc7cfea4ad | |||
| bc5f651c64 | |||
| ecdca378c6 | |||
| 4628c1f858 | |||
| 5af4d02f44 | |||
| 2f9b526465 | |||
| 800e02bccf | |||
| 693b0dba24 | |||
| 2004f6a51e | |||
| f650b6238c | |||
| 7c179a7868 | |||
| 7a7e0edfa7 | |||
| 69adec1d68 | |||
| 0cf6548f86 | |||
| 111ee66b60 | |||
| fedcd6f970 | |||
| 8e82ff5450 | |||
| 81459c3659 | |||
| 8907c9855b | |||
| e1bf30ec26 | |||
| 6bb9c5b81c | |||
| 6aafbfb245 | |||
| d5fe8c11c8 | |||
| 3fdb122e91 | |||
| 710dda164f | |||
| 07d0d82bd1 | |||
| 91eb3ea59e | |||
| 096f1b6ff9 | |||
| f24c0d3e7a | |||
| 104338c817 | |||
| 568f098445 | |||
| f46d595f00 | |||
| 46826ad590 | |||
| a8bd34b77e | |||
| 40774cfff2 | |||
| 5dde898205 | |||
| 249287e101 | |||
| 3e458e2ba6 | |||
| 4f293a8be1 | |||
| 3b9d9ab8c4 | |||
| 83f875dadd | |||
| 89df81d3df | |||
| 2e4ee42c90 | |||
| a03858a726 | |||
| 253174d4b3 | |||
| 947889fae6 | |||
| 7ee0b582dd | |||
| 7bec4efc60 | |||
| 571d8086c8 | |||
| 8abeefe6bb | |||
| 0aaf3eea02 | |||
| 8fc84f9b09 | |||
| 493b98a771 | |||
| 114a9b4d33 | |||
| 824b1e7c08 | |||
| dfa9b297db | |||
| adceb24651 | |||
| c7f1a1419a | |||
| 8878b5e21c | |||
| 6ebb1d1b4b | |||
| 583cd2d1e9 | |||
| 86c6b01e73 | |||
| 1170e222e3 | |||
| fe004db7d5 | |||
| 9e75ffb332 | |||
| d0bb6b7aa4 | |||
| c306f94a6a | |||
| 11b2ec89fd | |||
| 89596f00f1 | |||
| 4fa6e70e72 | |||
| a5a0a84d46 | |||
| 839431e6fa | |||
| 5369a6fc56 | |||
| 8a078e258f | |||
| fb42574c34 | |||
| 9ad3b6a337 | |||
| 91da14b0c6 | |||
| f361e286ed | |||
| 65b16fbfe5 | |||
| 6ad2853bce | |||
| e60e4e52fc | |||
| b2407eab98 | |||
| 778c7a836b | |||
| 11f9cdead0 | |||
| a1076d5443 | |||
| 4a11bf68f3 | |||
| fa64e73a43 | |||
| adf3e2dfe0 | |||
| c4c86cf5ce | |||
| 479aba8e1d | |||
| effe7c1669 | |||
| 0c474e2aba | |||
| 4f5b34cdfe | |||
| 0cb7f220ea | |||
| 0995b2cb5a | |||
| af1fe425a2 | |||
| 22385d40db | |||
| 1b37475144 | |||
| 87667ec2d1 | |||
| be0bacd895 | |||
| a2564bd0c3 | |||
| 402a5c9d56 | |||
| 2a2f22c7d9 | |||
| 372a768dca | |||
| f6e48243a6 | |||
| 94ea677ec0 | |||
| 55e7159f7d | |||
| 390a94e323 | |||
| 19fb920aa1 | |||
| f35e1604ca | |||
| b9765c3bec | |||
| d5a57c505c | |||
| 5f365241a8 | |||
| 9c121f0044 | |||
| f13bc07ddc | |||
| a707d23692 | |||
| 0929b7d42c | |||
| 35a9272b68 | |||
| 112453a032 | |||
| bba7367ba6 | |||
| 367073e02e | |||
| 83e679ba5e | |||
| 05c35b22bd | |||
| 1a4322eb48 | |||
| 4d950fb4d4 | |||
| 0d191fb8bd | |||
| f6318fb6f3 | |||
| c7a3efadb1 | |||
| 956425dfbf | |||
| c616354522 | |||
| 17b29357d4 | |||
| 36246b96d4 | |||
| 7d8791ec86 | |||
| f349a9ae3e | |||
| 2719e2c231 | |||
| 57a766098d | |||
| dafde545b0 | |||
| 610538261e | |||
| f78cb8a970 | |||
| e8f84cfec0 | |||
| def276de01 | |||
| 293b170a56 | |||
| 9f7b82e20f | |||
| 6ba4efc416 | |||
| 981fb39af6 | |||
| c64f6f894e | |||
| 3e73c2da43 | |||
| 26a8d23039 | |||
| 2632ef740c | |||
| f024dba864 | |||
| 9758851a4b | |||
| 04b3532e9d | |||
| 38e56f0fea | |||
| 462baf91e4 | |||
| 01bcd3b623 | |||
| 64fd95bd22 | |||
| f1366c7d29 | |||
| baaa9340e4 | |||
| 183a5b5c43 | |||
| 1a0c095f40 | |||
| ffada74aa4 | |||
| f2fc70f731 | |||
| 866b0113e7 | |||
| 06c49daca7 | |||
| 9293008b94 | |||
| dbb9386d22 | |||
| 51ed441b85 | |||
| f566fec665 | |||
| 9d92781a97 | |||
| 123bfe5afe | |||
| 3383d2a2ac | |||
| d9f38a20af | |||
| a91669abc0 | |||
| cc6dfd0c55 | |||
| d4802fcef6 | |||
| 35c3208b77 | |||
| 3b9db8a92f | |||
| 7debe17c58 | |||
| 1bfc1229bd | |||
| f941456af6 | |||
| 828e88e6f2 | |||
| 3d6fd2d785 | |||
| e56881abc6 | |||
| d32991c30a | |||
| 8758f9649b | |||
| 07902e840f | |||
| e807ee7d64 | |||
| 6f0f1ab2c3 | |||
| cd28240172 | |||
| 85ca85fd42 | |||
| 4a10178697 | |||
| ccba7f14a0 | |||
| b797e0d0c5 | |||
| 8220b033f3 | |||
| 6fffc8b45e | |||
| b550b3dde3 | |||
| 7002291c41 | |||
| 51bbf7ceb5 | |||
| 93d9f09fcc | |||
| 42a68cb770 | |||
| 1c2dec00fc | |||
| fcea4c7fdd | |||
| b6ef4bf6b5 | |||
| 82297a6ff1 | |||
| 3bf79f0a23 | |||
| 3f5aa3aa2b | |||
| cc5ac1a84c | |||
| 6373add383 | |||
| 180099b718 | |||
| 65f15125e1 | |||
| f026201c68 | |||
| 640b2c0ee0 | |||
| bef7ad1196 | |||
| 33c6c8b473 | |||
| 0a26e482aa | |||
| d0de54e2d3 | |||
| 6effcdfce9 | |||
| cbdabaa3b1 | |||
| 65c97040b3 | |||
| a33d7da211 | |||
| f31b6d9c2c | |||
| 367c945b42 | |||
| b962fcdbc3 | |||
| 0f8a13d60a | |||
| 5c1502c806 | |||
| 3cdebf4427 | |||
| 5176b68935 | |||
| 0bfc5f1272 | |||
| 39c18d4201 | |||
| 66ea8ae604 | |||
| 44f2a9e96f | |||
| 6fc794ca2e | |||
| 4bcee1df71 | |||
| 8e2716d300 | |||
| b8c7b09d25 | |||
| 741057b7d6 | |||
| 769b74afef | |||
| 6d4364a8b9 | |||
| efb7bc7689 | |||
| 6536286ffa | |||
| 6f07898979 | |||
| 7cf4c33d15 | |||
| d75ebed53d | |||
| 3136981043 | |||
| 893ca14859 | |||
| df958223b0 | |||
| 1217d9f0b3 | |||
| 1301897f39 | |||
| 6d34fe416d | |||
| a884ece8b1 | |||
| 0ffcc9b889 | |||
| ee3131b63d | |||
| 4fd7182388 | |||
| ae85b7bf2b | |||
| b52c480da3 | |||
| dada91f006 | |||
| 348694d9d4 | |||
| 855e3b3dcc | |||
| 5a8ea4aa41 | |||
| 4bd465f666 | |||
| ad591c07cf | |||
| cd3aaa47ca | |||
| a05cc03254 |
+135
-134
@@ -1,134 +1,135 @@
|
||||
*.obj
|
||||
*.pdb
|
||||
*.user
|
||||
*.aps
|
||||
*.pch
|
||||
*.vspscc
|
||||
.DS_Store
|
||||
._.DS_Store
|
||||
[Bb]in
|
||||
[Db]ebug*/
|
||||
obj/
|
||||
[Rr]elease*/
|
||||
_ReSharper*/
|
||||
_NCrunch_*/
|
||||
*.ncrunchsolution
|
||||
*.ncrunchsolution.user
|
||||
*.ncrunchproject
|
||||
*.crunchsolution.cache
|
||||
[Tt]est[Rr]esult*
|
||||
[Bb]uild[Ll]og.*
|
||||
*.[Pp]ublish.xml
|
||||
*.suo
|
||||
[sS]ource
|
||||
[sS]andbox
|
||||
umbraco.config
|
||||
*.vs10x
|
||||
App_Data/TEMP/*
|
||||
[Uu]mbraco/[Pp]resentation/[Uu]mbraco/[Pp]lugins/*
|
||||
[Uu]mbraco/[Pp]resentation/[Uu]ser[Cc]ontrols/*
|
||||
[Uu]mbraco/[Pp]resentation/[Ss]cripts/*
|
||||
[Uu]mbraco/[Pp]resentation/[Ff]onts/*
|
||||
[Uu]mbraco/[Pp]resentation/[Cc]ss/*
|
||||
|
||||
src/Umbraco.Web.UI/[Cc]ss/*
|
||||
src/Umbraco.Web.UI/App_Code/*
|
||||
src/Umbraco.Web.UI/App_Data/*
|
||||
src/Umbraco.Tests/App_Data/*
|
||||
src/Umbraco.Web.UI/[Mm]edia/*
|
||||
src/Umbraco.Web.UI/[Mm]aster[Pp]ages/*
|
||||
src/Umbraco.Web.UI/[Mm]acro[Ss]cripts/*
|
||||
!src/Umbraco.Web.UI/[Mm]acro[Ss]cripts/[Ww]eb.[Cc]onfig
|
||||
src/Umbraco.Web.UI/[Xx]slt/*
|
||||
src/Umbraco.Web.UI/[Ii]mages/*
|
||||
src/Umbraco.Web.UI/[Ss]cripts/*
|
||||
src/Umbraco.Web.UI/Web.*.config.transformed
|
||||
|
||||
umbraco/presentation/umbraco/plugins/uComponents/uComponentsInstaller.ascx
|
||||
umbraco/presentation/packages/uComponents/MultiNodePicker/CustomTreeService.asmx
|
||||
_BuildOutput/*
|
||||
*.ncrunchsolution
|
||||
build/UmbracoCms.AllBinaries*zip
|
||||
build/UmbracoCms.WebPI*zip
|
||||
build/UmbracoCms*zip
|
||||
build/UmbracoExamine.PDF*zip
|
||||
build/*.nupkg
|
||||
src/Umbraco.Tests/config/applications.config
|
||||
src/Umbraco.Tests/config/trees.config
|
||||
src/Umbraco.Web.UI/web.config
|
||||
*.orig
|
||||
src/Umbraco.Tests/config/404handlers.config
|
||||
src/Umbraco.Web.UI/[Vv]iews/*.cshtml
|
||||
src/Umbraco.Web.UI/[Vv]iews/*.vbhtml
|
||||
src/Umbraco.Tests/[Cc]onfig/umbracoSettings.config
|
||||
src/Umbraco.Web.UI/[Vv]iews/*
|
||||
src/packages/
|
||||
src/packages/repositories.config
|
||||
|
||||
src/Umbraco.Web.UI/[Ww]eb.config
|
||||
*.transformed
|
||||
webpihash.txt
|
||||
|
||||
node_modules
|
||||
|
||||
src/Umbraco.Web.UI/[Uu]mbraco/[Ll]ib/*
|
||||
src/Umbraco.Web.UI/[Uu]mbraco/[Jj]s/umbraco.*
|
||||
src/Umbraco.Web.UI/[Uu]mbraco/[Jj]s/routes.js
|
||||
src/Umbraco.Web.UI/[Uu]mbraco/[Jj]s/app.dev.js
|
||||
src/Umbraco.Web.UI/[Uu]mbraco/[Jj]s/loader.js
|
||||
src/Umbraco.Web.UI/[Uu]mbraco/[Jj]s/loader.dev.js
|
||||
src/Umbraco.Web.UI/[Uu]mbraco/[Jj]s/main.js
|
||||
src/Umbraco.Web.UI/[Uu]mbraco/[Jj]s/app.js
|
||||
|
||||
src/Umbraco.Web.UI/[Uu]mbraco/[Jj]s/tuning.panel.js
|
||||
src/Umbraco.Web.UI/[Uu]mbraco/[Jj]s/tuning.palettes.js
|
||||
src/Umbraco.Web.UI/[Uu]mbraco/[Jj]s/tuning.loader.js
|
||||
src/Umbraco.Web.UI/[Uu]mbraco/[Jj]s/tuning.front.js
|
||||
src/Umbraco.Web.UI/[Uu]mbraco/[Jj]s/tuning.config.js
|
||||
|
||||
src/Umbraco.Web.UI/[Uu]mbraco/[Vv]iews/
|
||||
src/Umbraco.Web.UI/[Uu]mbraco/[Vv]iews/**/*.js
|
||||
src/Umbraco.Web.UI/[Uu]mbraco/[Vv]iews/**/*.css
|
||||
src/Umbraco.Web.UI/[Uu]mbraco/[Vv]iews/**/*.html
|
||||
src/Umbraco.Web.UI/[Uu]mbraco/[Aa]ssets/*
|
||||
src/Umbraco.Web.UI.Client/[Bb]uild/*
|
||||
src/Umbraco.Web.UI.Client/[Bb]uild/[Bb]elle/
|
||||
src/Umbraco.Web.UI/[Uu]ser[Cc]ontrols/
|
||||
build/_BuildOutput/
|
||||
src/Umbraco.Web.UI.Client/src/[Ll]ess/*.css
|
||||
tools/NDepend/
|
||||
|
||||
src/Umbraco.Web.UI/App_Plugins/*
|
||||
src/*.psess
|
||||
src/*.vspx
|
||||
src/Umbraco.Web.UI/[Uu]mbraco/[Jj]s/routes.js.*
|
||||
NDependOut/*
|
||||
*.ndproj
|
||||
QueryResult.htm
|
||||
*.ndproj
|
||||
src/Umbraco.Web.UI/[Uu]mbraco/[Aa]ssets/*
|
||||
src/Umbraco.Web.UI/[Uu]mbraco/[Ll]ib/*
|
||||
src/Umbraco.Web.UI/[Uu]mbraco/[Vv]iews/**/*.html
|
||||
src/Umbraco.Web.UI/[Uu]mbraco/[Vv]iews/**/*.js
|
||||
|
||||
src/Umbraco.Web.UI/[Cc]onfig/appSettings.config
|
||||
src/Umbraco.Web.UI/[Cc]onfig/connectionStrings.config
|
||||
src/Umbraco.Web.UI/umbraco/plugins/*
|
||||
src/Umbraco.Web.UI/umbraco/js/init.js
|
||||
build/ApiDocs/*
|
||||
build/ApiDocs/Output/*
|
||||
src/Umbraco.Web.UI.Client/bower_components/*
|
||||
/src/Umbraco.Web.UI/Umbraco/preview
|
||||
|
||||
#Ignore Rule for output of generated documentation files from Grunt docserve
|
||||
src/Umbraco.Web.UI.Client/docs/api
|
||||
src/*.boltdata/
|
||||
/src/Umbraco.Web.UI/Umbraco/Js/canvasdesigner.loader.js
|
||||
/src/Umbraco.Web.UI/Umbraco/Js/canvasdesigner.palettes.js
|
||||
/src/Umbraco.Web.UI/Umbraco/Js/canvasdesigner.panel.js
|
||||
/src/Umbraco.Web.UI/Umbraco/Js/canvasdesigner.config.js
|
||||
/src/Umbraco.Web.UI/Umbraco/Js/canvasdesigner.front.js
|
||||
src/umbraco.sln.ide/*
|
||||
build/UmbracoCms.*/
|
||||
src/.vs/
|
||||
src/Umbraco.Web.UI/umbraco/js/install.loader.js
|
||||
*.obj
|
||||
*.pdb
|
||||
*.user
|
||||
*.aps
|
||||
*.pch
|
||||
*.vspscc
|
||||
.DS_Store
|
||||
._.DS_Store
|
||||
[Bb]in
|
||||
[Db]ebug*/
|
||||
obj/
|
||||
[Rr]elease*/
|
||||
_ReSharper*/
|
||||
_NCrunch_*/
|
||||
*.ncrunchsolution
|
||||
*.ncrunchsolution.user
|
||||
*.ncrunchproject
|
||||
*.crunchsolution.cache
|
||||
[Tt]est[Rr]esult*
|
||||
[Bb]uild[Ll]og.*
|
||||
*.[Pp]ublish.xml
|
||||
*.suo
|
||||
[sS]ource
|
||||
[sS]andbox
|
||||
umbraco.config
|
||||
*.vs10x
|
||||
App_Data/TEMP/*
|
||||
[Uu]mbraco/[Pp]resentation/[Uu]mbraco/[Pp]lugins/*
|
||||
[Uu]mbraco/[Pp]resentation/[Uu]ser[Cc]ontrols/*
|
||||
[Uu]mbraco/[Pp]resentation/[Ss]cripts/*
|
||||
[Uu]mbraco/[Pp]resentation/[Ff]onts/*
|
||||
[Uu]mbraco/[Pp]resentation/[Cc]ss/*
|
||||
|
||||
src/Umbraco.Web.UI/[Cc]ss/*
|
||||
src/Umbraco.Web.UI/App_Code/*
|
||||
src/Umbraco.Web.UI/App_Data/*
|
||||
src/Umbraco.Tests/App_Data/*
|
||||
src/Umbraco.Web.UI/[Mm]edia/*
|
||||
src/Umbraco.Web.UI/[Mm]aster[Pp]ages/*
|
||||
src/Umbraco.Web.UI/[Mm]acro[Ss]cripts/*
|
||||
!src/Umbraco.Web.UI/[Mm]acro[Ss]cripts/[Ww]eb.[Cc]onfig
|
||||
src/Umbraco.Web.UI/[Xx]slt/*
|
||||
src/Umbraco.Web.UI/[Ii]mages/*
|
||||
src/Umbraco.Web.UI/[Ss]cripts/*
|
||||
src/Umbraco.Web.UI/Web.*.config.transformed
|
||||
|
||||
umbraco/presentation/umbraco/plugins/uComponents/uComponentsInstaller.ascx
|
||||
umbraco/presentation/packages/uComponents/MultiNodePicker/CustomTreeService.asmx
|
||||
_BuildOutput/*
|
||||
*.ncrunchsolution
|
||||
build/UmbracoCms.AllBinaries*zip
|
||||
build/UmbracoCms.WebPI*zip
|
||||
build/UmbracoCms*zip
|
||||
build/UmbracoExamine.PDF*zip
|
||||
build/*.nupkg
|
||||
src/Umbraco.Tests/config/applications.config
|
||||
src/Umbraco.Tests/config/trees.config
|
||||
src/Umbraco.Web.UI/web.config
|
||||
*.orig
|
||||
src/Umbraco.Tests/config/404handlers.config
|
||||
src/Umbraco.Web.UI/[Vv]iews/*.cshtml
|
||||
src/Umbraco.Web.UI/[Vv]iews/*.vbhtml
|
||||
src/Umbraco.Tests/[Cc]onfig/umbracoSettings.config
|
||||
src/Umbraco.Web.UI/[Vv]iews/*
|
||||
src/packages/
|
||||
src/packages/repositories.config
|
||||
|
||||
src/Umbraco.Web.UI/[Ww]eb.config
|
||||
*.transformed
|
||||
webpihash.txt
|
||||
|
||||
node_modules
|
||||
|
||||
src/Umbraco.Web.UI/[Uu]mbraco/[Ll]ib/*
|
||||
src/Umbraco.Web.UI/[Uu]mbraco/[Jj]s/umbraco.*
|
||||
src/Umbraco.Web.UI/[Uu]mbraco/[Jj]s/routes.js
|
||||
src/Umbraco.Web.UI/[Uu]mbraco/[Jj]s/app.dev.js
|
||||
src/Umbraco.Web.UI/[Uu]mbraco/[Jj]s/loader.js
|
||||
src/Umbraco.Web.UI/[Uu]mbraco/[Jj]s/loader.dev.js
|
||||
src/Umbraco.Web.UI/[Uu]mbraco/[Jj]s/main.js
|
||||
src/Umbraco.Web.UI/[Uu]mbraco/[Jj]s/app.js
|
||||
|
||||
src/Umbraco.Web.UI/[Uu]mbraco/[Jj]s/tuning.panel.js
|
||||
src/Umbraco.Web.UI/[Uu]mbraco/[Jj]s/tuning.palettes.js
|
||||
src/Umbraco.Web.UI/[Uu]mbraco/[Jj]s/tuning.loader.js
|
||||
src/Umbraco.Web.UI/[Uu]mbraco/[Jj]s/tuning.front.js
|
||||
src/Umbraco.Web.UI/[Uu]mbraco/[Jj]s/tuning.config.js
|
||||
|
||||
src/Umbraco.Web.UI/[Uu]mbraco/[Vv]iews/
|
||||
src/Umbraco.Web.UI/[Uu]mbraco/[Vv]iews/**/*.js
|
||||
src/Umbraco.Web.UI/[Uu]mbraco/[Vv]iews/**/*.css
|
||||
src/Umbraco.Web.UI/[Uu]mbraco/[Vv]iews/**/*.html
|
||||
src/Umbraco.Web.UI/[Uu]mbraco/[Aa]ssets/*
|
||||
src/Umbraco.Web.UI.Client/[Bb]uild/*
|
||||
src/Umbraco.Web.UI.Client/[Bb]uild/[Bb]elle/
|
||||
src/Umbraco.Web.UI/[Uu]ser[Cc]ontrols/
|
||||
build/_BuildOutput/
|
||||
src/Umbraco.Web.UI.Client/src/[Ll]ess/*.css
|
||||
tools/NDepend/
|
||||
|
||||
src/Umbraco.Web.UI/App_Plugins/*
|
||||
src/*.psess
|
||||
src/*.vspx
|
||||
src/Umbraco.Web.UI/[Uu]mbraco/[Jj]s/routes.js.*
|
||||
NDependOut/*
|
||||
*.ndproj
|
||||
QueryResult.htm
|
||||
*.ndproj
|
||||
src/Umbraco.Web.UI/[Uu]mbraco/[Aa]ssets/*
|
||||
src/Umbraco.Web.UI/[Uu]mbraco/[Ll]ib/*
|
||||
src/Umbraco.Web.UI/[Uu]mbraco/[Vv]iews/**/*.html
|
||||
src/Umbraco.Web.UI/[Uu]mbraco/[Vv]iews/**/*.js
|
||||
|
||||
src/Umbraco.Web.UI/[Cc]onfig/appSettings.config
|
||||
src/Umbraco.Web.UI/[Cc]onfig/connectionStrings.config
|
||||
src/Umbraco.Web.UI/umbraco/plugins/*
|
||||
src/Umbraco.Web.UI/umbraco/js/init.js
|
||||
build/ApiDocs/*
|
||||
build/ApiDocs/Output/*
|
||||
src/Umbraco.Web.UI.Client/bower_components/*
|
||||
/src/Umbraco.Web.UI/Umbraco/preview
|
||||
|
||||
#Ignore Rule for output of generated documentation files from Grunt docserve
|
||||
src/Umbraco.Web.UI.Client/docs/api
|
||||
src/*.boltdata/
|
||||
/src/Umbraco.Web.UI/Umbraco/Js/canvasdesigner.loader.js
|
||||
/src/Umbraco.Web.UI/Umbraco/Js/canvasdesigner.palettes.js
|
||||
/src/Umbraco.Web.UI/Umbraco/Js/canvasdesigner.panel.js
|
||||
/src/Umbraco.Web.UI/Umbraco/Js/canvasdesigner.config.js
|
||||
/src/Umbraco.Web.UI/Umbraco/Js/canvasdesigner.front.js
|
||||
src/umbraco.sln.ide/*
|
||||
build/UmbracoCms.*/
|
||||
src/.vs/
|
||||
src/Umbraco.Web.UI/umbraco/js/install.loader.js
|
||||
src/Umbraco.Tests/media
|
||||
@@ -13,13 +13,13 @@ If you're interested in making changes to Belle make sure to read the [Belle Rea
|
||||
|
||||
## Umbraco - the simple, flexible and friendly ASP.NET CMS ##
|
||||
|
||||
**More than 177,000 sites trust Umbraco**
|
||||
**More than 350,000 sites trust Umbraco**
|
||||
|
||||
For the first time on the Microsoft platform a free user and developer friendly CMS that makes it quick and easy to create websites - or a breeze to build complex web applications. Umbraco has award-winning integration capabilities and supports ASP.NET MVC or Web Forms, including User and Custom Controls, out of the box. It's a developers dream and your users will love it too.
|
||||
For the first time on the Microsoft platform, there is a free user and developer friendly CMS that makes it quick and easy to create websites - or a breeze to build complex web applications. Umbraco has award-winning integration capabilities and supports ASP.NET MVC or Web Forms, including User and Custom Controls, out of the box. It's a developer's dream and your users will love it too.
|
||||
|
||||
Used by more than 177,000 active websites including [http://daviscup.com](http://daviscup.com), [http://heinz.com](http://heinz.com), [http://peugeot.com](http://peugeot.com), [http://www.hersheys.com/](http://www.hersheys.com/) and **The Official ASP.NET and IIS.NET website from Microsoft** ([http://asp.net](http://asp.net) / [http://iis.net](http://iis.net)) you can be sure that the technology is proven, stable and scales.
|
||||
Used by more than 350,000 active websites including [http://daviscup.com](http://daviscup.com), [http://heinz.com](http://heinz.com), [http://peugeot.com](http://peugeot.com), [http://www.hersheys.com/](http://www.hersheys.com/) and **The Official ASP.NET and IIS.NET website from Microsoft** ([http://asp.net](http://asp.net) / [http://iis.net](http://iis.net)), you can be sure that the technology is proven, stable and scales.
|
||||
|
||||
To view more examples please visit [http://umbraco.com/why-umbraco/#caseStudies](http://umbraco.com/why-umbraco/#caseStudies)
|
||||
To view more examples, please visit [http://umbraco.com/why-umbraco/#caseStudies](http://umbraco.com/why-umbraco/#caseStudies)
|
||||
|
||||
## Downloading ##
|
||||
|
||||
@@ -35,6 +35,6 @@ If you want to contribute back to Umbraco you should check out our [guide to con
|
||||
|
||||
## Found a bug? ##
|
||||
|
||||
Another way you can contribute to Umbraco is by providing issue reports, for information on how to submit an issue report refer to our [online guide for reporting issues](http://our.umbraco.org/contribute/report-an-issue-or-request-a-feature).
|
||||
Another way you can contribute to Umbraco is by providing issue reports. For information on how to submit an issue report refer to our [online guide for reporting issues](http://our.umbraco.org/contribute/report-an-issue-or-request-a-feature).
|
||||
|
||||
To view existing issues please visit [http://issues.umbraco.org](http://issues.umbraco.org)
|
||||
To view existing issues, please visit [http://issues.umbraco.org](http://issues.umbraco.org).
|
||||
|
||||
+2
-2
@@ -175,8 +175,8 @@
|
||||
<!-- Copy SQL CE -->
|
||||
<ItemGroup>
|
||||
<SQLCE4Files
|
||||
Include="..\src\packages\SqlServerCE.4.0.0.0\**\*.*"
|
||||
Exclude="..\src\packages\SqlServerCE.4.0.0.0\lib\**\*;..\src\packages\SqlServerCE.4.0.0.0\**\*.nu*"
|
||||
Include="..\src\packages\SqlServerCE.4.0.0.1\**\*.*"
|
||||
Exclude="..\src\packages\SqlServerCE.4.0.0.1\lib\**\*;..\src\packages\SqlServerCE.4.0.0.1\**\*.nu*"
|
||||
/>
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -72,7 +72,6 @@
|
||||
<file src="..\_BuildOutput\WebApp\bin\UmbracoExamine.dll" target="lib\UmbracoExamine.dll" />
|
||||
<file src="..\_BuildOutput\WebApp\bin\UmbracoExamine.xml" target="lib\UmbracoExamine.xml" />
|
||||
<file src="tools\install.core.ps1" target="tools\install.ps1" />
|
||||
<file src="tools\uninstall.core.ps1" target="tools\uninstall.ps1" />
|
||||
|
||||
<!-- Added to be able to produce a symbols package -->
|
||||
<file src="..\_BuildOutput\bin\SQLCE4Umbraco.pdb" target="lib" />
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
<dependencies>
|
||||
<dependency id="UmbracoCms.Core" version="[$version$]" />
|
||||
<dependency id="Newtonsoft.Json" version="[6.0.8, 9.0.0)" />
|
||||
<dependency id="Umbraco.ModelsBuilder" version="[3.0.0, 4.0.0)" />
|
||||
<dependency id="Umbraco.ModelsBuilder" version="[3.0.2, 4.0.0)" />
|
||||
</dependencies>
|
||||
</metadata>
|
||||
<files>
|
||||
@@ -33,7 +33,6 @@
|
||||
<file src="..\_BuildOutput\WebApp\umbraco\**" target="UmbracoFiles\umbraco" />
|
||||
<file src="..\_BuildOutput\WebApp\umbraco_client\**" target="UmbracoFiles\umbraco_client" />
|
||||
<file src="tools\install.ps1" target="tools\install.ps1" />
|
||||
<file src="tools\uninstall.ps1" target="tools\uninstall.ps1" />
|
||||
<file src="tools\Readme.txt" target="tools\Readme.txt" />
|
||||
<file src="tools\ReadmeUpgrade.txt" target="tools\ReadmeUpgrade.txt" />
|
||||
<file src="tools\Web.config.install.xdt" target="Content\Web.config.install.xdt" />
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
<appSettings xdt:Transform="InsertIfMissing" />
|
||||
<appSettings>
|
||||
<add key="owin:appStartup" value="UmbracoDefaultOwinStartup" xdt:Locator="Match(key)" xdt:Transform="InsertIfMissing" />
|
||||
<add key="Umbraco.ModelsBuilder.Enable" value="false" xdt:Locator="Match(key)" xdt:Transform="InsertIfMissing" />
|
||||
<add key="Umbraco.ModelsBuilder.ModelsMode" value="Nothing" xdt:Locator="Match(key)" xdt:Transform="InsertIfMissing" />
|
||||
</appSettings>
|
||||
|
||||
<umbracoConfiguration xdt:Transform="InsertIfMissing">
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
param($installPath, $toolsPath, $package, $project)
|
||||
|
||||
Write-Host "installPath:" "${installPath}"
|
||||
Write-Host "toolsPath:" "${toolsPath}"
|
||||
|
||||
Write-Host " "
|
||||
|
||||
if ($project) {
|
||||
|
||||
# Create paths and list them
|
||||
$projectPath = (Get-Item $project.Properties.Item("FullPath").Value).FullName
|
||||
Write-Host "projectPath:" "${projectPath}"
|
||||
$backupPath = Join-Path $projectPath "App_Data\NuGetBackup"
|
||||
Write-Host "backupPath:" "${backupPath}"
|
||||
$umbracoBinFolder = Join-Path $projectPath "bin"
|
||||
Write-Host "umbracoBinFolder:" "${umbracoBinFolder}"
|
||||
|
||||
# Remove backups
|
||||
Write-Host "removing backups:" "${backupPath}"
|
||||
if(Test-Path $backupPath) { Remove-Item -Recurse -Force $backupPath -Confirm:$false }
|
||||
|
||||
# Delete files Umbraco ships with
|
||||
|
||||
Write-Host "removing dlls:" "${umbracoBinFolder}"
|
||||
if(Test-Path $umbracoBinFolder\businesslogic.dll) { Remove-Item $umbracoBinFolder\businesslogic.dll -Force -Confirm:$false }
|
||||
if(Test-Path $umbracoBinFolder\cms.dll) { Remove-Item $umbracoBinFolder\cms.dll -Force -Confirm:$false }
|
||||
if(Test-Path $umbracoBinFolder\controls.dll) { Remove-Item $umbracoBinFolder\controls.dll -Force -Confirm:$false }
|
||||
if(Test-Path $umbracoBinFolder\interfaces.dll) { Remove-Item $umbracoBinFolder\interfaces.dll -Force -Confirm:$false }
|
||||
if(Test-Path $umbracoBinFolder\log4net.dll) { Remove-Item $umbracoBinFolder\log4net.dll -Force -Confirm:$false }
|
||||
if(Test-Path $umbracoBinFolder\Microsoft.ApplicationBlocks.Data.dll) { Remove-Item $umbracoBinFolder\Microsoft.ApplicationBlocks.Data.dll -Force -Confirm:$false }
|
||||
if(Test-Path $umbracoBinFolder\SQLCE4Umbraco.dll) { Remove-Item $umbracoBinFolder\SQLCE4Umbraco.dll -Force -Confirm:$false }
|
||||
if(Test-Path $umbracoBinFolder\System.Data.SqlServerCe.dll) { Remove-Item $umbracoBinFolder\System.Data.SqlServerCe.dll -Force -Confirm:$false }
|
||||
if(Test-Path $umbracoBinFolder\System.Data.SqlServerCe.Entity.dll) { Remove-Item $umbracoBinFolder\System.Data.SqlServerCe.Entity.dll -Force -Confirm:$false }
|
||||
if(Test-Path $umbracoBinFolder\TidyNet.dll) { Remove-Item $umbracoBinFolder\TidyNet.dll -Force -Confirm:$false }
|
||||
if(Test-Path $umbracoBinFolder\umbraco.dll) { Remove-Item $umbracoBinFolder\umbraco.dll -Force -Confirm:$false }
|
||||
if(Test-Path $umbracoBinFolder\Umbraco.Core.dll) { Remove-Item $umbracoBinFolder\Umbraco.Core.dll -Force -Confirm:$false }
|
||||
if(Test-Path $umbracoBinFolder\umbraco.DataLayer.dll) { Remove-Item $umbracoBinFolder\umbraco.DataLayer.dll -Force -Confirm:$false }
|
||||
if(Test-Path $umbracoBinFolder\umbraco.editorControls.dll) { Remove-Item $umbracoBinFolder\umbraco.editorControls.dll -Force -Confirm:$false }
|
||||
if(Test-Path $umbracoBinFolder\umbraco.MacroEngines.dll) { Remove-Item $umbracoBinFolder\umbraco.MacroEngines.dll -Force -Confirm:$false }
|
||||
if(Test-Path $umbracoBinFolder\umbraco.providers.dll) { Remove-Item $umbracoBinFolder\umbraco.providers.dll -Force -Confirm:$false }
|
||||
if(Test-Path $umbracoBinFolder\Umbraco.Web.UI.dll) { Remove-Item $umbracoBinFolder\Umbraco.Web.UI.dll -Force -Confirm:$false }
|
||||
if(Test-Path $umbracoBinFolder\UmbracoExamine.dll) { Remove-Item $umbracoBinFolder\UmbracoExamine.dll -Force -Confirm:$false }
|
||||
|
||||
$amd64Folder = Join-Path $umbracoBinFolder "amd64"
|
||||
if(Test-Path $amd64Folder) { Remove-Item $amd64Folder -Force -Recurse -Confirm:$false }
|
||||
$x86Folder = Join-Path $umbracoBinFolder "x86"
|
||||
if(Test-Path $x86Folder) { Remove-Item $x86Folder -Force -Recurse -Confirm:$false }
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
param($installPath, $toolsPath, $package, $project)
|
||||
|
||||
Write-Host "installPath:" "${installPath}"
|
||||
Write-Host "toolsPath:" "${toolsPath}"
|
||||
|
||||
Write-Host " "
|
||||
|
||||
if ($project) {
|
||||
|
||||
# Create paths and list them
|
||||
$projectPath = (Get-Item $project.Properties.Item("FullPath").Value).FullName
|
||||
Write-Host "projectPath:" "${projectPath}"
|
||||
$backupPath = Join-Path $projectPath "App_Data\NuGetBackup"
|
||||
Write-Host "backupPath:" "${backupPath}"
|
||||
$appBrowsers = Join-Path $projectPath "App_Browsers"
|
||||
Write-Host "appBrowsers:" "${appBrowsers}"
|
||||
$appData = Join-Path $projectPath "App_Data"
|
||||
Write-Host "appData:" "${appData}"
|
||||
|
||||
# Remove backups
|
||||
Write-Host "removing backups:" "${backupPath}"
|
||||
if(Test-Path $backupPath) { Remove-Item -Recurse -Force $backupPath -Confirm:$false }
|
||||
|
||||
# Remove app_data files
|
||||
Write-Host "removing app_data files:" "${appData}"
|
||||
if(Test-Path $appData\packages) { Remove-Item $appData\packages -Recurse -Force -Confirm:$false }
|
||||
|
||||
Write-Host "removing app_browsers:" "${appBrowsers}"
|
||||
if(Test-Path $appBrowsers\Form.browser) { Remove-Item $appBrowsers\Form.browser -Force -Confirm:$false }
|
||||
if(Test-Path $appBrowsers\w3cvalidator.browser) { Remove-Item $appBrowsers\w3cvalidator.browser -Force -Confirm:$false }
|
||||
|
||||
# Remove umbraco and umbraco_files
|
||||
$umbracoFolder = Join-Path $projectPath "Umbraco"
|
||||
Write-Host "removing umbraco folder:" "${umbracoFolder}"
|
||||
if(Test-Path $umbracoFolder) { Remove-Item $umbracoFolder -Recurse -Force -Confirm:$false }
|
||||
$umbracoClientFolder = Join-Path $projectPath "Umbraco_Client"
|
||||
Write-Host "removing umbraco client folder:" "${umbracoClientFolder}"
|
||||
if(Test-Path $umbracoClientFolder) { Remove-Item $umbracoClientFolder -Recurse -Force -Confirm:$false }
|
||||
}
|
||||
@@ -1,2 +1,2 @@
|
||||
# Usage: on line 2 put the release version, on line 3 put the version comment (example: beta)
|
||||
7.4.0
|
||||
7.4.3
|
||||
@@ -47,13 +47,15 @@
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
|
||||
<Private>True</Private>
|
||||
<HintPath>..\packages\SqlServerCE.4.0.0.0\lib\System.Data.SqlServerCe.dll</HintPath>
|
||||
<Reference Include="System.Data.SqlServerCe, Version=4.0.0.1, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\SqlServerCE.4.0.0.1\lib\System.Data.SqlServerCe.dll</HintPath>
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Data.SqlServerCe.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
|
||||
<Private>True</Private>
|
||||
<HintPath>..\packages\SqlServerCE.4.0.0.0\lib\System.Data.SqlServerCe.Entity.dll</HintPath>
|
||||
<Reference Include="System.Data.SqlServerCe.Entity, Version=4.0.0.1, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\SqlServerCE.4.0.0.1\lib\System.Data.SqlServerCe.Entity.dll</HintPath>
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="SqlServerCE" version="4.0.0.0" targetFramework="net40" />
|
||||
<package id="SqlServerCE" version="4.0.0.1" targetFramework="net45" />
|
||||
</packages>
|
||||
+2
-2
@@ -11,5 +11,5 @@ using System.Resources;
|
||||
|
||||
[assembly: AssemblyVersion("1.0.*")]
|
||||
|
||||
[assembly: AssemblyFileVersion("7.4.0")]
|
||||
[assembly: AssemblyInformationalVersion("7.4.0")]
|
||||
[assembly: AssemblyFileVersion("7.4.3")]
|
||||
[assembly: AssemblyInformationalVersion("7.4.3")]
|
||||
@@ -6,7 +6,7 @@ namespace Umbraco.Core.Configuration
|
||||
{
|
||||
public class UmbracoVersion
|
||||
{
|
||||
private static readonly Version Version = new Version("7.4.0");
|
||||
private static readonly Version Version = new Version("7.4.3");
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current version of Umbraco.
|
||||
|
||||
@@ -10,6 +10,12 @@ namespace Umbraco.Core
|
||||
/// </summary>
|
||||
public static class Web
|
||||
{
|
||||
public const string UmbracoContextDataToken = "umbraco-context";
|
||||
public const string UmbracoDataToken = "umbraco";
|
||||
public const string PublishedDocumentRequestDataToken = "umbraco-doc-request";
|
||||
public const string CustomRouteDataToken = "umbraco-custom-route";
|
||||
public const string UmbracoRouteDefinitionDataToken = "umbraco-route-def";
|
||||
|
||||
/// <summary>
|
||||
/// The preview cookie name
|
||||
/// </summary>
|
||||
|
||||
@@ -5,8 +5,10 @@ using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Linq.Expressions;
|
||||
using System.Text;
|
||||
using System.Web.Services.Description;
|
||||
using Umbraco.Core.Cache;
|
||||
using Umbraco.Core.Logging;
|
||||
|
||||
namespace Umbraco.Core.Dynamics
|
||||
{
|
||||
@@ -20,6 +22,20 @@ namespace Umbraco.Core.Dynamics
|
||||
/// </summary>
|
||||
private static readonly ConcurrentDictionary<Tuple<Type, string, int>, MethodInfo[]> MethodCache = new ConcurrentDictionary<Tuple<Type, string, int>, MethodInfo[]>();
|
||||
|
||||
private static IEnumerable<Type> GetTypes(Assembly a)
|
||||
{
|
||||
try
|
||||
{
|
||||
return TypeFinder.GetTypesWithFormattedException(a);
|
||||
}
|
||||
catch (ReflectionTypeLoadException ex)
|
||||
{
|
||||
// is this going to flood the log?
|
||||
LogHelper.Error(typeof (ExtensionMethodFinder), "Failed to get types.", ex);
|
||||
return Enumerable.Empty<Type>();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the enumerable of all extension method info's in the app domain = USE SPARINGLY!!!
|
||||
/// </summary>
|
||||
@@ -36,7 +52,7 @@ namespace Umbraco.Core.Dynamics
|
||||
// assemblies that contain extension methods
|
||||
.Where(a => a.IsDefined(typeof (ExtensionAttribute), false))
|
||||
// types that contain extension methods
|
||||
.SelectMany(a => a.GetTypes()
|
||||
.SelectMany(a => GetTypes(a)
|
||||
.Where(t => t.IsDefined(typeof (ExtensionAttribute), false) && t.IsSealed && t.IsGenericType == false && t.IsNested == false))
|
||||
// actual extension methods
|
||||
.SelectMany(t => t.GetMethods(BindingFlags.Static | BindingFlags.Public)
|
||||
@@ -45,9 +61,9 @@ namespace Umbraco.Core.Dynamics
|
||||
.Concat(typeof (Enumerable).GetMethods(BindingFlags.Static | BindingFlags.Public))
|
||||
//If we don't do this then we'll be scanning all assemblies each time!
|
||||
.ToArray(),
|
||||
|
||||
|
||||
//only cache for 5 minutes
|
||||
timeout: TimeSpan.FromMinutes(5),
|
||||
timeout: TimeSpan.FromMinutes(5),
|
||||
|
||||
//each time this is accessed it will be for 5 minutes longer
|
||||
isSliding:true);
|
||||
@@ -57,7 +73,7 @@ namespace Umbraco.Core.Dynamics
|
||||
/// Returns all extension methods found matching the definition
|
||||
/// </summary>
|
||||
/// <param name="runtimeCache">
|
||||
/// The runtime cache is used to temporarily cache all extension methods found in the app domain so that
|
||||
/// The runtime cache is used to temporarily cache all extension methods found in the app domain so that
|
||||
/// while we search for individual extension methods, the process will be reasonably 'quick'. We then statically
|
||||
/// cache the MethodInfo's that we are looking for and then the runtime cache will expire and give back all that memory.
|
||||
/// </param>
|
||||
@@ -78,7 +94,7 @@ namespace Umbraco.Core.Dynamics
|
||||
{
|
||||
var candidates = GetAllExtensionMethodsInAppDomain(runtimeCache);
|
||||
|
||||
// filter by name
|
||||
// filter by name
|
||||
var filtr1 = candidates.Where(m => m.Name == name);
|
||||
|
||||
// filter by args count
|
||||
@@ -102,7 +118,7 @@ namespace Umbraco.Core.Dynamics
|
||||
|
||||
return filtr3.ToArray();
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
private static MethodInfo DetermineMethodFromParams(IEnumerable<MethodInfo> methods, Type genericType, IEnumerable<object> args)
|
||||
@@ -123,12 +139,12 @@ namespace Umbraco.Core.Dynamics
|
||||
types = method.GetParameters().Select(pi => pi.ParameterType).Skip(1)
|
||||
});
|
||||
|
||||
//This type comparer will check
|
||||
//This type comparer will check
|
||||
var typeComparer = new DelegateEqualityComparer<Type>(
|
||||
//Checks if the argument type passed in can be assigned from the parameter type in the method. For
|
||||
//Checks if the argument type passed in can be assigned from the parameter type in the method. For
|
||||
// example, if the argument type is HtmlHelper<MyModel> but the method parameter type is HtmlHelper then
|
||||
// it will match because the argument is assignable to that parameter type and will be able to execute
|
||||
TypeHelper.IsTypeAssignableFrom,
|
||||
TypeHelper.IsTypeAssignableFrom,
|
||||
//This will not ever execute but if it does we need to get the hash code of the string because the hash
|
||||
// code of a type is random
|
||||
type => type.FullName.GetHashCode());
|
||||
@@ -159,7 +175,7 @@ namespace Umbraco.Core.Dynamics
|
||||
.ToArray();
|
||||
|
||||
var methods = GetAllExtensionMethods(runtimeCache, thisType, name, args.Length).ToArray();
|
||||
|
||||
|
||||
return DetermineMethodFromParams(methods, genericType, args);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using Semver;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Persistence.Migrations;
|
||||
|
||||
namespace Umbraco.Core.Events
|
||||
@@ -13,23 +14,49 @@ namespace Umbraco.Core.Events
|
||||
/// </summary>
|
||||
/// <param name="eventObject"></param>
|
||||
/// <param name="targetVersion"></param>
|
||||
/// <param name="productName"></param>
|
||||
/// <param name="canCancel"></param>
|
||||
/// <param name="configuredVersion"></param>
|
||||
public MigrationEventArgs(IList<IMigration> eventObject, SemVersion configuredVersion, SemVersion targetVersion, bool canCancel)
|
||||
: base(eventObject, canCancel)
|
||||
{
|
||||
ConfiguredSemVersion = configuredVersion;
|
||||
TargetSemVersion = targetVersion;
|
||||
}
|
||||
public MigrationEventArgs(IList<IMigration> eventObject, SemVersion configuredVersion, SemVersion targetVersion, string productName, bool canCancel)
|
||||
: this(eventObject, null, configuredVersion, targetVersion, productName, canCancel)
|
||||
{ }
|
||||
|
||||
[Obsolete("Use constructor accepting UmbracoVersion instances instead")]
|
||||
/// <summary>
|
||||
/// Constructor accepting multiple migrations that are used in the migration runner
|
||||
/// </summary>
|
||||
/// <param name="eventObject"></param>
|
||||
/// <param name="targetVersion"></param>
|
||||
/// <param name="canCancel"></param>
|
||||
/// <param name="configuredVersion"></param>
|
||||
[Obsolete("Use constructor accepting a product name instead.")]
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public MigrationEventArgs(IList<IMigration> eventObject, SemVersion configuredVersion, SemVersion targetVersion, bool canCancel)
|
||||
: this(eventObject, null, configuredVersion, targetVersion, GlobalSettings.UmbracoMigrationName, canCancel)
|
||||
{ }
|
||||
|
||||
[Obsolete("Use constructor accepting SemVersion instances and a product name instead.")]
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public MigrationEventArgs(IList<IMigration> eventObject, Version configuredVersion, Version targetVersion, bool canCancel)
|
||||
: base(eventObject, canCancel)
|
||||
{
|
||||
ConfiguredSemVersion = new SemVersion(configuredVersion);
|
||||
TargetSemVersion = new SemVersion(targetVersion);
|
||||
}
|
||||
: this(eventObject, null, new SemVersion(configuredVersion), new SemVersion(targetVersion), GlobalSettings.UmbracoMigrationName, canCancel)
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Constructor accepting multiple migrations that are used in the migration runner
|
||||
/// </summary>
|
||||
/// <param name="eventObject"></param>
|
||||
/// <param name="migrationContext"></param>
|
||||
/// <param name="targetVersion"></param>
|
||||
/// <param name="productName"></param>
|
||||
/// <param name="canCancel"></param>
|
||||
/// <param name="configuredVersion"></param>
|
||||
internal MigrationEventArgs(IList<IMigration> eventObject, MigrationContext migrationContext, SemVersion configuredVersion, SemVersion targetVersion, string productName, bool canCancel)
|
||||
: base(eventObject, canCancel)
|
||||
{
|
||||
MigrationContext = migrationContext;
|
||||
ConfiguredSemVersion = configuredVersion;
|
||||
TargetSemVersion = targetVersion;
|
||||
ProductName = productName;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor accepting multiple migrations that are used in the migration runner
|
||||
@@ -39,12 +66,15 @@ namespace Umbraco.Core.Events
|
||||
/// <param name="targetVersion"></param>
|
||||
/// <param name="canCancel"></param>
|
||||
/// <param name="configuredVersion"></param>
|
||||
[Obsolete("Use constructor accepting a product name instead.")]
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
internal MigrationEventArgs(IList<IMigration> eventObject, MigrationContext migrationContext, SemVersion configuredVersion, SemVersion targetVersion, bool canCancel)
|
||||
: base(eventObject, canCancel)
|
||||
{
|
||||
MigrationContext = migrationContext;
|
||||
ConfiguredSemVersion = configuredVersion;
|
||||
TargetSemVersion = targetVersion;
|
||||
ProductName = GlobalSettings.UmbracoMigrationName;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -53,21 +83,28 @@ namespace Umbraco.Core.Events
|
||||
/// <param name="eventObject"></param>
|
||||
/// <param name="configuredVersion"></param>
|
||||
/// <param name="targetVersion"></param>
|
||||
public MigrationEventArgs(IList<IMigration> eventObject, SemVersion configuredVersion, SemVersion targetVersion)
|
||||
: base(eventObject)
|
||||
{
|
||||
ConfiguredSemVersion = configuredVersion;
|
||||
TargetSemVersion = targetVersion;
|
||||
}
|
||||
/// <param name="productName"></param>
|
||||
public MigrationEventArgs(IList<IMigration> eventObject, SemVersion configuredVersion, SemVersion targetVersion, string productName)
|
||||
: this(eventObject, null, configuredVersion, targetVersion, productName, false)
|
||||
{ }
|
||||
|
||||
[Obsolete("Use constructor accepting UmbracoVersion instances instead")]
|
||||
/// <summary>
|
||||
/// Constructor accepting multiple migrations that are used in the migration runner
|
||||
/// </summary>
|
||||
/// <param name="eventObject"></param>
|
||||
/// <param name="configuredVersion"></param>
|
||||
/// <param name="targetVersion"></param>
|
||||
[Obsolete("Use constructor accepting a product name instead.")]
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public MigrationEventArgs(IList<IMigration> eventObject, SemVersion configuredVersion, SemVersion targetVersion)
|
||||
: this(eventObject, null, configuredVersion, targetVersion, GlobalSettings.UmbracoMigrationName, false)
|
||||
{ }
|
||||
|
||||
[Obsolete("Use constructor accepting SemVersion instances and a product name instead.")]
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public MigrationEventArgs(IList<IMigration> eventObject, Version configuredVersion, Version targetVersion)
|
||||
: base(eventObject)
|
||||
{
|
||||
ConfiguredSemVersion = new SemVersion(configuredVersion);
|
||||
TargetSemVersion = new SemVersion(targetVersion);
|
||||
}
|
||||
: this(eventObject, null, new SemVersion(configuredVersion), new SemVersion(targetVersion), GlobalSettings.UmbracoMigrationName, false)
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Returns all migrations that were used in the migration runner
|
||||
@@ -95,6 +132,8 @@ namespace Umbraco.Core.Events
|
||||
|
||||
public SemVersion TargetSemVersion { get; private set; }
|
||||
|
||||
public string ProductName { get; private set; }
|
||||
|
||||
internal MigrationContext MigrationContext { get; private set; }
|
||||
}
|
||||
}
|
||||
@@ -487,11 +487,8 @@ namespace Umbraco.Core.Models
|
||||
var oldPropertyGroup = PropertyGroups.FirstOrDefault(x =>
|
||||
x.PropertyTypes.Any(y => y.Alias == propertyTypeAlias));
|
||||
|
||||
// reset PropertyGroupId, which will be re-evaluated when the content type
|
||||
// is saved - what is important is group.PropertyTypes - see code in
|
||||
// ContentTypeBaseRepository.PersistUpdatedBaseContentType
|
||||
propertyType.PropertyGroupId = new Lazy<int>(() => default(int));
|
||||
propertyType.ResetDirtyProperties(); // PropertyGroupId must not be dirty
|
||||
// set new group
|
||||
propertyType.PropertyGroupId = newPropertyGroup == null ? null : new Lazy<int>(() => newPropertyGroup.Id, false);
|
||||
|
||||
// remove from old group, if any - add to new group, if any
|
||||
if (oldPropertyGroup != null)
|
||||
@@ -540,7 +537,7 @@ namespace Umbraco.Core.Models
|
||||
// re-assign the group's properties to no group
|
||||
foreach (var property in group.PropertyTypes)
|
||||
{
|
||||
property.PropertyGroupId = new Lazy<int>(() => 0);
|
||||
property.PropertyGroupId = null;
|
||||
_propertyTypes.Add(property);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,12 @@ namespace Umbraco.Core.Models
|
||||
/// </summary
|
||||
public interface IMediaType : IContentTypeComposition
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Creates a deep clone of the current entity with its identity/alias and it's property identities reset
|
||||
/// </summary>
|
||||
/// <param name="newAlias"></param>
|
||||
/// <returns></returns>
|
||||
IMediaType DeepCloneWithResetIdentities(string newAlias);
|
||||
}
|
||||
}
|
||||
@@ -38,5 +38,30 @@ namespace Umbraco.Core.Models
|
||||
: base(parent, alias)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a deep clone of the current entity with its identity/alias and it's property identities reset
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public IMediaType DeepCloneWithResetIdentities(string alias)
|
||||
{
|
||||
var clone = (MediaType)DeepClone();
|
||||
clone.Alias = alias;
|
||||
clone.Key = Guid.Empty;
|
||||
foreach (var propertyGroup in clone.PropertyGroups)
|
||||
{
|
||||
propertyGroup.ResetIdentity();
|
||||
propertyGroup.ResetDirtyProperties(false);
|
||||
}
|
||||
foreach (var propertyType in clone.PropertyTypes)
|
||||
{
|
||||
propertyType.ResetIdentity();
|
||||
propertyType.ResetDirtyProperties(false);
|
||||
}
|
||||
|
||||
clone.ResetIdentity();
|
||||
clone.ResetDirtyProperties(false);
|
||||
return clone;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -221,8 +221,9 @@ namespace Umbraco.Core.Models
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets the PropertyGroup's Id for which this PropertyType belongs
|
||||
/// Gets or sets the identifier of the PropertyGroup this PropertyType belongs to.
|
||||
/// </summary>
|
||||
/// <remarks>For generic properties, the value is <c>null</c>.</remarks>
|
||||
[DataMember]
|
||||
internal Lazy<int> PropertyGroupId
|
||||
{
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web.Caching;
|
||||
using System.Web.UI;
|
||||
using Umbraco.Core.Cache;
|
||||
|
||||
namespace Umbraco.Core.Models.PublishedContent
|
||||
@@ -16,6 +13,7 @@ namespace Umbraco.Core.Models.PublishedContent
|
||||
public class PublishedContentType
|
||||
{
|
||||
private readonly PublishedPropertyType[] _propertyTypes;
|
||||
private readonly HashSet<string> _compositionAliases;
|
||||
|
||||
// fast alias-to-index xref containing both the raw alias and its lowercase version
|
||||
private readonly Dictionary<string, int> _indexes = new Dictionary<string, int>();
|
||||
@@ -27,6 +25,7 @@ namespace Umbraco.Core.Models.PublishedContent
|
||||
{
|
||||
Id = contentType.Id;
|
||||
Alias = contentType.Alias;
|
||||
_compositionAliases = new HashSet<string>(contentType.CompositionAliases(), StringComparer.InvariantCultureIgnoreCase);
|
||||
_propertyTypes = contentType.CompositionPropertyTypes
|
||||
.Select(x => new PublishedPropertyType(this, x))
|
||||
.ToArray();
|
||||
@@ -34,10 +33,11 @@ namespace Umbraco.Core.Models.PublishedContent
|
||||
}
|
||||
|
||||
// internal so it can be used for unit tests
|
||||
internal PublishedContentType(int id, string alias, IEnumerable<PublishedPropertyType> propertyTypes)
|
||||
internal PublishedContentType(int id, string alias, IEnumerable<string> compositionAliases, IEnumerable<PublishedPropertyType> propertyTypes)
|
||||
{
|
||||
Id = id;
|
||||
Alias = alias;
|
||||
_compositionAliases = new HashSet<string>(compositionAliases, StringComparer.InvariantCultureIgnoreCase);
|
||||
_propertyTypes = propertyTypes.ToArray();
|
||||
foreach (var propertyType in _propertyTypes)
|
||||
propertyType.ContentType = this;
|
||||
@@ -45,8 +45,8 @@ namespace Umbraco.Core.Models.PublishedContent
|
||||
}
|
||||
|
||||
// create detached content type - ie does not match anything in the DB
|
||||
internal PublishedContentType(string alias, IEnumerable<PublishedPropertyType> propertyTypes)
|
||||
: this (0, alias, propertyTypes)
|
||||
internal PublishedContentType(string alias, IEnumerable<string> compositionAliases, IEnumerable<PublishedPropertyType> propertyTypes)
|
||||
: this(0, alias, compositionAliases, propertyTypes)
|
||||
{ }
|
||||
|
||||
private void InitializeIndexes()
|
||||
@@ -63,6 +63,7 @@ namespace Umbraco.Core.Models.PublishedContent
|
||||
|
||||
public int Id { get; private set; }
|
||||
public string Alias { get; private set; }
|
||||
public HashSet<string> CompositionAliases { get { return _compositionAliases; } }
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -113,10 +114,25 @@ namespace Umbraco.Core.Models.PublishedContent
|
||||
internal static void ClearContentType(int id)
|
||||
{
|
||||
Logging.LogHelper.Debug<PublishedContentType>("Clear content type w/id {0}.", () => id);
|
||||
// requires a predicate because the key does not contain the ID
|
||||
// faster than key strings comparisons anyway
|
||||
|
||||
// we don't support "get all" at the moment - so, cheating
|
||||
var all = ApplicationContext.Current.ApplicationCache.StaticCache.GetCacheItemsByKeySearch<PublishedContentType>("PublishedContentType_").ToArray();
|
||||
|
||||
// the one we want to clear
|
||||
var clr = all.FirstOrDefault(x => x.Id == id);
|
||||
if (clr == null) return;
|
||||
|
||||
// those that have that one in their composition aliases
|
||||
// note: CompositionAliases contains all recursive aliases
|
||||
var oth = all.Where(x => x.CompositionAliases.InvariantContains(clr.Alias)).Select(x => x.Id);
|
||||
|
||||
// merge ids
|
||||
var ids = oth.Concat(new[] { clr.Id }).ToArray();
|
||||
|
||||
// clear them all at once
|
||||
// we don't support "clear many at once" at the moment - so, cheating
|
||||
ApplicationContext.Current.ApplicationCache.StaticCache.ClearCacheObjectTypes<PublishedContentType>(
|
||||
(key, value) => value.Id == id);
|
||||
(key, value) => ids.Contains(value.Id));
|
||||
}
|
||||
|
||||
internal static void ClearDataType(int id)
|
||||
|
||||
@@ -164,7 +164,7 @@ namespace Umbraco.Core.Persistence.Factories
|
||||
Name = typeDto.Name,
|
||||
SortOrder = typeDto.SortOrder,
|
||||
ValidationRegExp = typeDto.ValidationRegExp,
|
||||
PropertyGroupId = new Lazy<int>(() => default(int)),
|
||||
PropertyGroupId = null,
|
||||
CreateDate = dto.CreateDate,
|
||||
UpdateDate = dto.CreateDate
|
||||
};
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -27,18 +28,21 @@ namespace Umbraco.Core.Persistence.Migrations
|
||||
private readonly IMigration[] _migrations;
|
||||
|
||||
[Obsolete("Use the ctor that specifies all dependencies instead")]
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public MigrationRunner(Version currentVersion, Version targetVersion, string productName)
|
||||
: this(LoggerResolver.Current.Logger, currentVersion, targetVersion, productName)
|
||||
{
|
||||
}
|
||||
|
||||
[Obsolete("Use the ctor that specifies all dependencies instead")]
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public MigrationRunner(ILogger logger, Version currentVersion, Version targetVersion, string productName)
|
||||
: this(logger, currentVersion, targetVersion, productName, null)
|
||||
{
|
||||
}
|
||||
|
||||
[Obsolete("Use the ctor that specifies all dependencies instead")]
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public MigrationRunner(ILogger logger, Version currentVersion, Version targetVersion, string productName, params IMigration[] migrations)
|
||||
: this(ApplicationContext.Current.Services.MigrationEntryService, logger, new SemVersion(currentVersion), new SemVersion(targetVersion), productName, migrations)
|
||||
{
|
||||
@@ -92,7 +96,7 @@ namespace Umbraco.Core.Persistence.Migrations
|
||||
: OrderedDowngradeMigrations(foundMigrations).ToList();
|
||||
|
||||
|
||||
if (Migrating.IsRaisedEventCancelled(new MigrationEventArgs(migrations, _currentVersion, _targetVersion, true), this))
|
||||
if (Migrating.IsRaisedEventCancelled(new MigrationEventArgs(migrations, _currentVersion, _targetVersion, _productName, true), this))
|
||||
{
|
||||
_logger.Warn<MigrationRunner>("Migration was cancelled by an event");
|
||||
return false;
|
||||
@@ -121,7 +125,7 @@ namespace Umbraco.Core.Persistence.Migrations
|
||||
throw;
|
||||
}
|
||||
|
||||
Migrated.RaiseEvent(new MigrationEventArgs(migrations, migrationContext, _currentVersion, _targetVersion, false), this);
|
||||
Migrated.RaiseEvent(new MigrationEventArgs(migrations, migrationContext, _currentVersion, _targetVersion, _productName, false), this);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
+11
-1
@@ -20,7 +20,17 @@ namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSevenFourZer
|
||||
if (columns.Any(x => x.TableName.InvariantEquals("cmsPropertyTypeGroup") && x.ColumnName.InvariantEquals("parentGroupId")) == false)
|
||||
return;
|
||||
|
||||
Delete.ForeignKey("FK_cmsPropertyTypeGroup_cmsPropertyTypeGroup_id").OnTable("cmsPropertyTypeGroup");
|
||||
//This constraing can be based on old aliases, before removing them, check they exist
|
||||
var constraints = SqlSyntax.GetConstraintsPerColumn(Context.Database).Distinct().ToArray();
|
||||
if (constraints.Any(x => x.Item1.InvariantEquals("cmsPropertyTypeGroup") && x.Item3.InvariantEquals("FK_cmsPropertyTypeGroup_cmsPropertyTypeGroup_id")))
|
||||
{
|
||||
Delete.ForeignKey("FK_cmsPropertyTypeGroup_cmsPropertyTypeGroup_id").OnTable("cmsPropertyTypeGroup");
|
||||
}
|
||||
if (constraints.Any(x => x.Item1.InvariantEquals("cmsPropertyTypeGroup") && x.Item3.InvariantEquals("FK_cmsPropertyTypeGroup_cmsPropertyTypeGroup")))
|
||||
{
|
||||
Delete.ForeignKey("FK_cmsPropertyTypeGroup_cmsPropertyTypeGroup").OnTable("cmsPropertyTypeGroup");
|
||||
}
|
||||
|
||||
Delete.Column("parentGroupId").FromTable("cmsPropertyTypeGroup");
|
||||
}
|
||||
|
||||
|
||||
@@ -128,6 +128,34 @@ namespace Umbraco.Core.Persistence.Querying
|
||||
right = Visit(b.Right);
|
||||
}
|
||||
}
|
||||
else if (operand == "=")
|
||||
{
|
||||
// deal with (x == true|false) - most common
|
||||
var constRight = b.Right as ConstantExpression;
|
||||
if (constRight != null && constRight.Type == typeof (bool))
|
||||
return ((bool) constRight.Value) ? VisitNotNot(b.Left) : VisitNot(b.Left);
|
||||
right = Visit(b.Right);
|
||||
|
||||
// deal with (true|false == x) - why not
|
||||
var constLeft = b.Left as ConstantExpression;
|
||||
if (constLeft != null && constLeft.Type == typeof (bool))
|
||||
return ((bool) constLeft.Value) ? VisitNotNot(b.Right) : VisitNot(b.Right);
|
||||
left = Visit(b.Left);
|
||||
}
|
||||
else if (operand == "<>")
|
||||
{
|
||||
// deal with (x != true|false) - most common
|
||||
var constRight = b.Right as ConstantExpression;
|
||||
if (constRight != null && constRight.Type == typeof(bool))
|
||||
return ((bool) constRight.Value) ? VisitNot(b.Left) : VisitNotNot(b.Left);
|
||||
right = Visit(b.Right);
|
||||
|
||||
// deal with (true|false != x) - why not
|
||||
var constLeft = b.Left as ConstantExpression;
|
||||
if (constLeft != null && constLeft.Type == typeof(bool))
|
||||
return ((bool) constLeft.Value) ? VisitNot(b.Right) : VisitNotNot(b.Right);
|
||||
left = Visit(b.Left);
|
||||
}
|
||||
else
|
||||
{
|
||||
left = Visit(b.Left);
|
||||
@@ -152,7 +180,7 @@ namespace Umbraco.Core.Persistence.Querying
|
||||
case "COALESCE":
|
||||
return string.Format("{0}({1},{2})", operand, left, right);
|
||||
default:
|
||||
return left + " " + operand + " " + right;
|
||||
return "(" + left + " " + operand + " " + right + ")";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -231,25 +259,47 @@ namespace Umbraco.Core.Persistence.Querying
|
||||
switch (u.NodeType)
|
||||
{
|
||||
case ExpressionType.Not:
|
||||
var o = Visit(u.Operand);
|
||||
|
||||
//use a Not equal operator instead of <> since we don't know that <> works in all sql servers
|
||||
|
||||
switch (u.Operand.NodeType)
|
||||
{
|
||||
case ExpressionType.MemberAccess:
|
||||
//In this case it wil be a false property , i.e. x => !Trashed
|
||||
SqlParameters.Add(true);
|
||||
return string.Format("NOT ({0} = @0)", o);
|
||||
default:
|
||||
//In this case it could be anything else, such as: x => !x.Path.StartsWith("-20")
|
||||
return string.Format("NOT ({0})", o);
|
||||
}
|
||||
return VisitNot(u.Operand);
|
||||
default:
|
||||
return Visit(u.Operand);
|
||||
}
|
||||
}
|
||||
|
||||
private string VisitNot(Expression exp)
|
||||
{
|
||||
var o = Visit(exp);
|
||||
|
||||
// use a "NOT (...)" syntax instead of "<>" since we don't know whether "<>" works in all sql servers
|
||||
// also, x.StartsWith(...) translates to "x LIKE '...%'" which we cannot "<>" and have to "NOT (...")
|
||||
|
||||
switch (exp.NodeType)
|
||||
{
|
||||
case ExpressionType.MemberAccess:
|
||||
// false property , i.e. x => !Trashed
|
||||
SqlParameters.Add(true);
|
||||
return string.Format("NOT ({0} = @{1})", o, SqlParameters.Count - 1);
|
||||
default:
|
||||
// could be anything else, such as: x => !x.Path.StartsWith("-20")
|
||||
return "NOT (" + o + ")";
|
||||
}
|
||||
}
|
||||
|
||||
private string VisitNotNot(Expression exp)
|
||||
{
|
||||
var o = Visit(exp);
|
||||
|
||||
switch (exp.NodeType)
|
||||
{
|
||||
case ExpressionType.MemberAccess:
|
||||
// true property, i.e. x => Trashed
|
||||
SqlParameters.Add(true);
|
||||
return string.Format("({0} = @{1})", o, SqlParameters.Count - 1);
|
||||
default:
|
||||
// could be anything else, such as: x => x.Path.StartsWith("-20")
|
||||
return o;
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual string VisitNewArray(NewArrayExpression na)
|
||||
{
|
||||
|
||||
|
||||
@@ -914,7 +914,7 @@ AND umbracoNode.id <> @id",
|
||||
//check for default templates
|
||||
bool? isDefaultTemplate = Convert.ToBoolean(ct.dtIsDefault);
|
||||
int? templateId = ct.dtTemplateId;
|
||||
if (currDefaultTemplate == -1 && isDefaultTemplate.HasValue && templateId.HasValue)
|
||||
if (currDefaultTemplate == -1 && isDefaultTemplate.HasValue && isDefaultTemplate.Value && templateId.HasValue)
|
||||
{
|
||||
currDefaultTemplate = templateId.Value;
|
||||
}
|
||||
@@ -1212,5 +1212,19 @@ AND umbracoNode.id <> @id",
|
||||
{
|
||||
return PerformExists(id);
|
||||
}
|
||||
|
||||
public string GetUniqueAlias(string alias)
|
||||
{
|
||||
// alias is unique accross ALL content types!
|
||||
var aliasColumn = SqlSyntax.GetQuotedColumnName("alias");
|
||||
var aliases = Database.Fetch<string>(@"SELECT cmsContentType." + aliasColumn + @" FROM cmsContentType
|
||||
INNER JOIN umbracoNode ON cmsContentType.nodeId = umbracoNode.id
|
||||
WHERE cmsContentType." + aliasColumn + @" LIKE @pattern",
|
||||
new { pattern = alias + "%", objectType = NodeObjectTypeId });
|
||||
var i = 1;
|
||||
string test;
|
||||
while (aliases.Contains(test = alias + i)) i++;
|
||||
return test;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,5 +32,13 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
/// </param>
|
||||
/// <returns></returns>
|
||||
IEnumerable<string> GetAllContentTypeAliases(params Guid[] objectTypes);
|
||||
|
||||
/// <summary>
|
||||
/// Derives a unique alias from an existing alias.
|
||||
/// </summary>
|
||||
/// <param name="alias">The original alias.</param>
|
||||
/// <returns>The original alias with a number appended to it, so that it is unique.</returns>
|
||||
/// /// <remarks>Unique accross all content, media and member types.</remarks>
|
||||
string GetUniqueAlias(string alias);
|
||||
}
|
||||
}
|
||||
@@ -15,5 +15,13 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
IEnumerable<IMediaType> GetByQuery(IQuery<PropertyType> query);
|
||||
|
||||
IEnumerable<MoveEventInfo<IMediaType>> Move(IMediaType toMove, EntityContainer container);
|
||||
|
||||
/// <summary>
|
||||
/// Derives a unique alias from an existing alias.
|
||||
/// </summary>
|
||||
/// <param name="alias">The original alias.</param>
|
||||
/// <returns>The original alias with a number appended to it, so that it is unique.</returns>
|
||||
/// <remarks>Unique accross all content, media and member types.</remarks>
|
||||
string GetUniqueAlias(string alias);
|
||||
}
|
||||
}
|
||||
@@ -28,6 +28,8 @@ namespace Umbraco.Core.Persistence.SqlSyntax
|
||||
GuidColumnDefinition = "char(36)";
|
||||
|
||||
DefaultValueFormat = "DEFAULT {0}";
|
||||
|
||||
InitColumnTypeMap();
|
||||
}
|
||||
|
||||
public override IEnumerable<string> GetTablesInSchema(Database db)
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
using Umbraco.Core.Models.PublishedContent;
|
||||
|
||||
namespace Umbraco.Core.PropertyEditors.ValueConverters
|
||||
{
|
||||
/// <summary>
|
||||
/// We need this property converter so that we always force the value of a label to be a string
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Without a property converter defined for the label type, the value will be converted with
|
||||
/// the `ConvertUsingDarkMagic` method which will try to parse the value into it's correct type, but this
|
||||
/// can cause issues if the string is detected as a number and then strips leading zeros.
|
||||
/// Example: http://issues.umbraco.org/issue/U4-7929
|
||||
/// </remarks>
|
||||
[DefaultPropertyValueConverter]
|
||||
[PropertyValueType(typeof (string))]
|
||||
[PropertyValueCache(PropertyCacheValue.All, PropertyCacheLevel.Content)]
|
||||
public class LabelValueConverter : PropertyValueConverterBase
|
||||
{
|
||||
public override bool IsConverter(PublishedPropertyType propertyType)
|
||||
{
|
||||
return Constants.PropertyEditors.NoEditAlias.Equals(propertyType.PropertyEditorAlias);
|
||||
}
|
||||
public override object ConvertDataToSource(PublishedPropertyType propertyType, object source, bool preview)
|
||||
{
|
||||
return source == null ? string.Empty : source.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -103,10 +103,18 @@ namespace Umbraco.Core.Security
|
||||
var backOfficeIdentity = http.User.Identity as UmbracoBackOfficeIdentity;
|
||||
if (backOfficeIdentity != null) return backOfficeIdentity;
|
||||
|
||||
//Check if there's more than one identity assigned and see if it's a UmbracoBackOfficeIdentity and use that
|
||||
var claimsPrincipal = http.User as ClaimsPrincipal;
|
||||
if (claimsPrincipal != null)
|
||||
{
|
||||
backOfficeIdentity = claimsPrincipal.Identities.OfType<UmbracoBackOfficeIdentity>().FirstOrDefault();
|
||||
if (backOfficeIdentity != null) return backOfficeIdentity;
|
||||
}
|
||||
|
||||
//Otherwise convert to a UmbracoBackOfficeIdentity if it's auth'd and has the back office session
|
||||
var claimsIdentity = http.User.Identity as ClaimsIdentity;
|
||||
if (claimsIdentity != null && claimsIdentity.IsAuthenticated)
|
||||
{
|
||||
{
|
||||
try
|
||||
{
|
||||
return UmbracoBackOfficeIdentity.FromClaimsIdentity(claimsIdentity);
|
||||
|
||||
@@ -794,7 +794,7 @@ namespace Umbraco.Core.Services
|
||||
|
||||
//TODO: This needs to change, if we are deleting a content type, we should just delete the data,
|
||||
// this method will recursively go lookup every content item, check if any of it's descendants are
|
||||
// of a different type, move them to the recycle bin, then permanently delete the content items.
|
||||
// of a different type, move them to the recycle bin, then permanently delete the content items.
|
||||
// The main problem with this is that for every content item being deleted, events are raised...
|
||||
// which we need for many things like keeping caches in sync, but we can surely do this MUCH better.
|
||||
|
||||
@@ -1067,6 +1067,92 @@ namespace Umbraco.Core.Services
|
||||
new OperationStatus<MoveOperationStatusType>(MoveOperationStatusType.Success, evtMsgs));
|
||||
}
|
||||
|
||||
public Attempt<OperationStatus<IMediaType, MoveOperationStatusType>> CopyMediaType(IMediaType toCopy, int containerId)
|
||||
{
|
||||
var evtMsgs = EventMessagesFactory.Get();
|
||||
|
||||
IMediaType copy;
|
||||
var uow = UowProvider.GetUnitOfWork();
|
||||
using (var containerRepository = RepositoryFactory.CreateEntityContainerRepository(uow, Constants.ObjectTypes.MediaTypeContainerGuid))
|
||||
using (var repository = RepositoryFactory.CreateMediaTypeRepository(uow))
|
||||
{
|
||||
try
|
||||
{
|
||||
if (containerId > 0)
|
||||
{
|
||||
var container = containerRepository.Get(containerId);
|
||||
if (container == null)
|
||||
throw new DataOperationException<MoveOperationStatusType>(MoveOperationStatusType.FailedParentNotFound);
|
||||
}
|
||||
var alias = repository.GetUniqueAlias(toCopy.Alias);
|
||||
copy = toCopy.DeepCloneWithResetIdentities(alias);
|
||||
copy.Name = copy.Name + " (copy)"; // might not be unique
|
||||
|
||||
// if it has a parent, and the parent is a content type, unplug composition
|
||||
// all other compositions remain in place in the copied content type
|
||||
if (copy.ParentId > 0)
|
||||
{
|
||||
var parent = repository.Get(copy.ParentId);
|
||||
if (parent != null)
|
||||
copy.RemoveContentType(parent.Alias);
|
||||
}
|
||||
|
||||
copy.ParentId = containerId;
|
||||
repository.AddOrUpdate(copy);
|
||||
}
|
||||
catch (DataOperationException<MoveOperationStatusType> ex)
|
||||
{
|
||||
return Attempt.Fail(new OperationStatus<IMediaType, MoveOperationStatusType>(null, ex.Operation, evtMsgs));
|
||||
}
|
||||
uow.Commit();
|
||||
}
|
||||
|
||||
return Attempt.Succeed(new OperationStatus<IMediaType, MoveOperationStatusType>(copy, MoveOperationStatusType.Success, evtMsgs));
|
||||
}
|
||||
|
||||
public Attempt<OperationStatus<IContentType, MoveOperationStatusType>> CopyContentType(IContentType toCopy, int containerId)
|
||||
{
|
||||
var evtMsgs = EventMessagesFactory.Get();
|
||||
|
||||
IContentType copy;
|
||||
var uow = UowProvider.GetUnitOfWork();
|
||||
using (var containerRepository = RepositoryFactory.CreateEntityContainerRepository(uow, Constants.ObjectTypes.DocumentTypeContainerGuid))
|
||||
using (var repository = RepositoryFactory.CreateContentTypeRepository(uow))
|
||||
{
|
||||
try
|
||||
{
|
||||
if (containerId > 0)
|
||||
{
|
||||
var container = containerRepository.Get(containerId);
|
||||
if (container == null)
|
||||
throw new DataOperationException<MoveOperationStatusType>(MoveOperationStatusType.FailedParentNotFound);
|
||||
}
|
||||
var alias = repository.GetUniqueAlias(toCopy.Alias);
|
||||
copy = toCopy.DeepCloneWithResetIdentities(alias);
|
||||
copy.Name = copy.Name + " (copy)"; // might not be unique
|
||||
|
||||
// if it has a parent, and the parent is a content type, unplug composition
|
||||
// all other compositions remain in place in the copied content type
|
||||
if (copy.ParentId > 0)
|
||||
{
|
||||
var parent = repository.Get(copy.ParentId);
|
||||
if (parent != null)
|
||||
copy.RemoveContentType(parent.Alias);
|
||||
}
|
||||
|
||||
copy.ParentId = containerId;
|
||||
repository.AddOrUpdate(copy);
|
||||
}
|
||||
catch (DataOperationException<MoveOperationStatusType> ex)
|
||||
{
|
||||
return Attempt.Fail(new OperationStatus<IContentType, MoveOperationStatusType>(null, ex.Operation, evtMsgs));
|
||||
}
|
||||
uow.Commit();
|
||||
}
|
||||
|
||||
return Attempt.Succeed(new OperationStatus<IContentType, MoveOperationStatusType>(copy, MoveOperationStatusType.Success, evtMsgs));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Saves a single <see cref="IMediaType"/> object
|
||||
/// </summary>
|
||||
|
||||
@@ -267,11 +267,15 @@ namespace Umbraco.Core.Services
|
||||
structure.Add(new XElement("MediaType", allowedType.Alias));
|
||||
}
|
||||
|
||||
var genericProperties = new XElement("GenericProperties");
|
||||
var genericProperties = new XElement("GenericProperties"); // actually, all of them
|
||||
foreach (var propertyType in mediaType.PropertyTypes)
|
||||
{
|
||||
var definition = dataTypeService.GetDataTypeDefinitionById(propertyType.DataTypeDefinitionId);
|
||||
var propertyGroup = mediaType.PropertyGroups.FirstOrDefault(x => x.Id == propertyType.PropertyGroupId.Value);
|
||||
|
||||
var propertyGroup = propertyType.PropertyGroupId == null // true generic property
|
||||
? null
|
||||
: mediaType.PropertyGroups.FirstOrDefault(x => x.Id == propertyType.PropertyGroupId.Value);
|
||||
|
||||
var genericProperty = new XElement("GenericProperty",
|
||||
new XElement("Name", propertyType.Name),
|
||||
new XElement("Alias", propertyType.Alias),
|
||||
@@ -381,14 +385,14 @@ namespace Umbraco.Core.Services
|
||||
structure.Add(new XElement("DocumentType", allowedType.Alias));
|
||||
}
|
||||
|
||||
var genericProperties = new XElement("GenericProperties");
|
||||
var genericProperties = new XElement("GenericProperties"); // actually, all of them
|
||||
foreach (var propertyType in contentType.PropertyTypes)
|
||||
{
|
||||
var definition = dataTypeService.GetDataTypeDefinitionById(propertyType.DataTypeDefinitionId);
|
||||
|
||||
var propertyGroup = propertyType.PropertyGroupId == null
|
||||
? null
|
||||
: contentType.PropertyGroups.FirstOrDefault(x => x.Id == propertyType.PropertyGroupId.Value);
|
||||
var propertyGroup = propertyType.PropertyGroupId == null // true generic property
|
||||
? null
|
||||
: contentType.PropertyGroups.FirstOrDefault(x => x.Id == propertyType.PropertyGroupId.Value);
|
||||
|
||||
var genericProperty = new XElement("GenericProperty",
|
||||
new XElement("Name", propertyType.Name),
|
||||
|
||||
@@ -255,7 +255,12 @@ namespace Umbraco.Core.Services
|
||||
/// </returns>
|
||||
public Attempt<OperationStatus<ITemplate, OperationStatusType>> CreateTemplateForContentType(string contentTypeAlias, string contentTypeName, int userId = 0)
|
||||
{
|
||||
var template = new Template(contentTypeName, contentTypeAlias);
|
||||
var template = new Template(contentTypeName,
|
||||
//NOTE: We are NOT passing in the content type alias here, we want to use it's name since we don't
|
||||
// want to save template file names as camelCase, the Template ctor will clean the alias as
|
||||
// `alias.ToCleanString(CleanStringType.UnderscoreAlias)` which has been the default.
|
||||
// This fixes: http://issues.umbraco.org/issue/U4-7953
|
||||
contentTypeName);
|
||||
|
||||
var evtMsgs = EventMessagesFactory.Get();
|
||||
|
||||
|
||||
@@ -291,5 +291,7 @@ namespace Umbraco.Core.Services
|
||||
|
||||
Attempt<OperationStatus<MoveOperationStatusType>> MoveMediaType(IMediaType toMove, int containerId);
|
||||
Attempt<OperationStatus<MoveOperationStatusType>> MoveContentType(IContentType toMove, int containerId);
|
||||
Attempt<OperationStatus<IMediaType, MoveOperationStatusType>> CopyMediaType(IMediaType toCopy, int containerId);
|
||||
Attempt<OperationStatus<IContentType, MoveOperationStatusType>> CopyContentType(IContentType toCopy, int containerId);
|
||||
}
|
||||
}
|
||||
@@ -1380,6 +1380,30 @@ namespace Umbraco.Core
|
||||
*/
|
||||
}
|
||||
|
||||
public static string EscapeRegexSpecialCharacters(this string text)
|
||||
{
|
||||
var regexSpecialCharacters = new Dictionary<string, string>
|
||||
{
|
||||
{".", @"\."},
|
||||
{"(", @"\("},
|
||||
{")", @"\)"},
|
||||
{"]", @"\]"},
|
||||
{"[", @"\["},
|
||||
{"{", @"\{"},
|
||||
{"}", @"\}"},
|
||||
{"?", @"\?"},
|
||||
{"!", @"\!"},
|
||||
{"$", @"\$"},
|
||||
{"^", @"\^"},
|
||||
{"+", @"\+"},
|
||||
{"*", @"\*"},
|
||||
{"|", @"\|"},
|
||||
{"<", @"\<"},
|
||||
{">", @"\>"}
|
||||
};
|
||||
return ReplaceMany(text, regexSpecialCharacters);
|
||||
}
|
||||
|
||||
public static bool ContainsAny(this string haystack, IEnumerable<string> needles, StringComparison comparison = StringComparison.CurrentCulture)
|
||||
{
|
||||
if (haystack == null) throw new ArgumentNullException("haystack");
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace Umbraco.Core.Strings.Css
|
||||
public static string ReplaceRule(string input, string oldRuleName, StylesheetRule rule)
|
||||
{
|
||||
var contents = input;
|
||||
var ruleRegex = new Regex(string.Format(RuleRegexFormat, oldRuleName), RegexOptions.IgnoreCase | RegexOptions.Singleline);
|
||||
var ruleRegex = new Regex(string.Format(RuleRegexFormat, oldRuleName.EscapeRegexSpecialCharacters()), RegexOptions.IgnoreCase | RegexOptions.Singleline);
|
||||
contents = ruleRegex.Replace(contents, rule != null ? rule.ToString() : "");
|
||||
return contents;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace Umbraco.Core
|
||||
|
||||
/// <summary>
|
||||
/// A utility class to find all classes of a certain type by reflection in the current bin folder
|
||||
/// of the web application.
|
||||
/// of the web application.
|
||||
/// </summary>
|
||||
public static class TypeFinder
|
||||
{
|
||||
@@ -34,7 +34,7 @@ namespace Umbraco.Core
|
||||
/// This is a modified version of: http://www.dominicpettifer.co.uk/Blog/44/how-to-get-a-reference-to-all-assemblies-in-the--bin-folder
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// We do this because we cannot use AppDomain.Current.GetAssemblies() as this will return only assemblies that have been
|
||||
/// We do this because we cannot use AppDomain.Current.GetAssemblies() as this will return only assemblies that have been
|
||||
/// loaded in the CLR, not all assemblies.
|
||||
/// See these threads:
|
||||
/// http://issues.umbraco.org/issue/U5-198
|
||||
@@ -136,7 +136,7 @@ namespace Umbraco.Core
|
||||
});
|
||||
|
||||
/// <summary>
|
||||
/// Return a list of found local Assemblies excluding the known assemblies we don't want to scan
|
||||
/// Return a list of found local Assemblies excluding the known assemblies we don't want to scan
|
||||
/// and exluding the ones passed in and excluding the exclusion list filter, the results of this are
|
||||
/// cached for perforance reasons.
|
||||
/// </summary>
|
||||
@@ -190,6 +190,7 @@ namespace Umbraco.Core
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// NOTE the comma vs period... comma delimits the name in an Assembly FullName property so if it ends with comma then its an exact name match
|
||||
/// NOTE this means that "foo." will NOT exclude "foo.dll" but only "foo.*.dll"
|
||||
/// </remarks>
|
||||
internal static readonly string[] KnownAssemblyExclusionFilter = new[]
|
||||
{
|
||||
@@ -214,7 +215,7 @@ namespace Umbraco.Core
|
||||
"RouteDebugger,",
|
||||
"SqlCE4Umbraco,",
|
||||
"umbraco.datalayer,",
|
||||
"umbraco.interfaces,",
|
||||
"umbraco.interfaces,",
|
||||
//"umbraco.providers,",
|
||||
//"Umbraco.Web.UI,",
|
||||
"umbraco.webservices",
|
||||
@@ -230,9 +231,9 @@ namespace Umbraco.Core
|
||||
"AutoMapper,",
|
||||
"AutoMapper.",
|
||||
"AzureDirectory,",
|
||||
"itextsharp,",
|
||||
"itextsharp,",
|
||||
"UrlRewritingNet.",
|
||||
"HtmlAgilityPack,",
|
||||
"HtmlAgilityPack,",
|
||||
"MiniProfiler,",
|
||||
"Moq,",
|
||||
"nunit.framework,",
|
||||
@@ -371,7 +372,7 @@ namespace Umbraco.Core
|
||||
|
||||
var assemblyList = assemblies.ToArray();
|
||||
|
||||
//find all assembly references that are referencing the attribute type's assembly since we
|
||||
//find all assembly references that are referencing the attribute type's assembly since we
|
||||
//should only be scanning those assemblies because any other assembly will definitely not
|
||||
//contain a class that has this attribute.
|
||||
var referencedAssemblies = TypeHelper.GetReferencedAssemblies(attributeType, assemblyList);
|
||||
@@ -418,7 +419,7 @@ namespace Umbraco.Core
|
||||
foreach (var subTypesInAssembly in allAttributeTypes.GroupBy(x => x.Assembly))
|
||||
{
|
||||
|
||||
//So that we are not scanning too much, we need to group the sub types:
|
||||
//So that we are not scanning too much, we need to group the sub types:
|
||||
// * if there is more than 1 sub type in the same assembly then we should only search on the 'lowest base' type.
|
||||
// * We should also not search for sub types if the type is sealed since you cannot inherit from a sealed class
|
||||
// * We should not search for sub types if the type is static since you cannot inherit from them.
|
||||
@@ -489,7 +490,7 @@ namespace Umbraco.Core
|
||||
|
||||
/// <summary>
|
||||
/// Finds types that are assignable from the assignTypeFrom parameter and will scan for these types in the assembly
|
||||
/// list passed in, however we will only scan assemblies that have a reference to the assignTypeFrom Type or any type
|
||||
/// list passed in, however we will only scan assemblies that have a reference to the assignTypeFrom Type or any type
|
||||
/// deriving from the base type.
|
||||
/// </summary>
|
||||
/// <param name="assignTypeFrom"></param>
|
||||
@@ -513,7 +514,7 @@ namespace Umbraco.Core
|
||||
|
||||
var assemblyList = assemblies.ToArray();
|
||||
|
||||
//find all assembly references that are referencing the current type's assembly since we
|
||||
//find all assembly references that are referencing the current type's assembly since we
|
||||
//should only be scanning those assemblies because any other assembly will definitely not
|
||||
//contain sub type's of the one we're currently looking for
|
||||
var referencedAssemblies = TypeHelper.GetReferencedAssemblies(assignTypeFrom, assemblyList);
|
||||
@@ -560,7 +561,7 @@ namespace Umbraco.Core
|
||||
foreach (var subTypesInAssembly in allSubTypes.GroupBy(x => x.Assembly))
|
||||
{
|
||||
|
||||
//So that we are not scanning too much, we need to group the sub types:
|
||||
//So that we are not scanning too much, we need to group the sub types:
|
||||
// * if there is more than 1 sub type in the same assembly then we should only search on the 'lowest base' type.
|
||||
// * We should also not search for sub types if the type is sealed since you cannot inherit from a sealed class
|
||||
// * We should not search for sub types if the type is static since you cannot inherit from them.
|
||||
@@ -602,39 +603,69 @@ namespace Umbraco.Core
|
||||
return foundAssignableTypes;
|
||||
}
|
||||
|
||||
private static IEnumerable<Type> GetTypesWithFormattedException(Assembly a)
|
||||
internal static IEnumerable<Type> GetTypesWithFormattedException(Assembly a)
|
||||
{
|
||||
//if the assembly is dynamic, do not try to scan it
|
||||
if (a.IsDynamic)
|
||||
return Enumerable.Empty<Type>();
|
||||
|
||||
var getAll = a.GetCustomAttribute<AllowPartiallyTrustedCallersAttribute>() == null;
|
||||
|
||||
try
|
||||
{
|
||||
//we need to detect if an assembly is partially trusted, if so we cannot go interrogating all of it's types
|
||||
//only its exported types, otherwise we'll get exceptions.
|
||||
if (a.GetCustomAttribute<AllowPartiallyTrustedCallersAttribute>() == null)
|
||||
{
|
||||
return a.GetTypes();
|
||||
}
|
||||
else
|
||||
{
|
||||
return a.GetExportedTypes();
|
||||
}
|
||||
return getAll ? a.GetTypes() : a.GetExportedTypes();
|
||||
}
|
||||
catch (ReflectionTypeLoadException ex)
|
||||
catch (TypeLoadException ex) // GetExportedTypes *can* throw TypeLoadException!
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
sb.AppendLine("Could not load types from assembly " + a.FullName + ", errors:");
|
||||
foreach (var loaderException in ex.LoaderExceptions.WhereNotNull())
|
||||
{
|
||||
sb.AppendLine("Exception: " + loaderException);
|
||||
}
|
||||
throw new ReflectionTypeLoadException(ex.Types, ex.LoaderExceptions, sb.ToString());
|
||||
AppendCouldNotLoad(sb, a, getAll);
|
||||
AppendLoaderException(sb, ex);
|
||||
|
||||
// rethrow as ReflectionTypeLoadException (for consistency) with new message
|
||||
throw new ReflectionTypeLoadException(new Type[0], new Exception[] { ex }, sb.ToString());
|
||||
}
|
||||
catch (ReflectionTypeLoadException rex) // GetTypes throws ReflectionTypeLoadException
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
AppendCouldNotLoad(sb, a, getAll);
|
||||
foreach (var loaderException in rex.LoaderExceptions.WhereNotNull())
|
||||
AppendLoaderException(sb, loaderException);
|
||||
|
||||
// rethrow with new message
|
||||
throw new ReflectionTypeLoadException(rex.Types, rex.LoaderExceptions, sb.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
private static void AppendCouldNotLoad(StringBuilder sb, Assembly a, bool getAll)
|
||||
{
|
||||
sb.Append("Could not load ");
|
||||
sb.Append(getAll ? "all" : "exported");
|
||||
sb.Append(" types from \"");
|
||||
sb.Append(a.FullName);
|
||||
sb.AppendLine("\" due to LoaderExceptions, skipping:");
|
||||
}
|
||||
|
||||
private static void AppendLoaderException(StringBuilder sb, Exception loaderException)
|
||||
{
|
||||
sb.Append(". ");
|
||||
sb.Append(loaderException.GetType().FullName);
|
||||
|
||||
var tloadex = loaderException as TypeLoadException;
|
||||
if (tloadex != null)
|
||||
{
|
||||
sb.Append(" on ");
|
||||
sb.Append(tloadex.TypeName);
|
||||
}
|
||||
|
||||
sb.Append(": ");
|
||||
sb.Append(loaderException.Message);
|
||||
sb.AppendLine();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
public static Type GetTypeByName(string typeName)
|
||||
{
|
||||
|
||||
@@ -102,13 +102,13 @@
|
||||
<Reference Include="System.ComponentModel.DataAnnotations" />
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Data.Entity" />
|
||||
<Reference Include="System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
|
||||
<Reference Include="System.Data.SqlServerCe, Version=4.0.0.1, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\SqlServerCE.4.0.0.0\lib\System.Data.SqlServerCe.dll</HintPath>
|
||||
<HintPath>..\packages\SqlServerCE.4.0.0.1\lib\System.Data.SqlServerCe.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Data.SqlServerCe.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
|
||||
<Reference Include="System.Data.SqlServerCe.Entity, Version=4.0.0.1, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\SqlServerCE.4.0.0.0\lib\System.Data.SqlServerCe.Entity.dll</HintPath>
|
||||
<HintPath>..\packages\SqlServerCE.4.0.0.1\lib\System.Data.SqlServerCe.Entity.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
@@ -478,6 +478,7 @@
|
||||
<Compile Include="PropertyEditors\DecimalValidator.cs" />
|
||||
<Compile Include="PropertyEditors\ValueConverters\GridValueConverter.cs" />
|
||||
<Compile Include="PropertyEditors\ValueConverters\DecimalValueConverter.cs" />
|
||||
<Compile Include="PropertyEditors\ValueConverters\LabelValueConverter.cs" />
|
||||
<Compile Include="PropertyEditors\ValueConverters\ImageCropperValueConverter.cs" />
|
||||
<Compile Include="Publishing\UnPublishedStatusType.cs" />
|
||||
<Compile Include="Publishing\UnPublishStatus.cs" />
|
||||
|
||||
@@ -72,6 +72,11 @@ namespace Umbraco.Core
|
||||
/// <summary>
|
||||
/// Override init and raise the event
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// DID YOU KNOW? The Global.asax Init call is the thing that initializes all of the httpmodules, ties up a bunch of stuff with IIS, etc...
|
||||
/// Therefore, since OWIN is an HttpModule when running in IIS/ASP.Net the OWIN startup is not executed until this method fires and by that
|
||||
/// time, Umbraco has performed it's bootup sequence.
|
||||
/// </remarks>
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
|
||||
@@ -15,5 +15,5 @@
|
||||
<package id="Owin" version="1.0" targetFramework="net45" />
|
||||
<package id="semver" version="1.1.2" targetFramework="net45" />
|
||||
<package id="SharpZipLib" version="0.86.0" targetFramework="net4" />
|
||||
<package id="SqlServerCE" version="4.0.0.0" targetFramework="net4" />
|
||||
<package id="SqlServerCE" version="4.0.0.1" targetFramework="net45" />
|
||||
</packages>
|
||||
@@ -72,7 +72,7 @@
|
||||
<system.data>
|
||||
<DbProviderFactories>
|
||||
<remove invariant="System.Data.SqlServerCe.4.0" />
|
||||
<add name="Microsoft SQL Server Compact Data Provider 4.0" invariant="System.Data.SqlServerCe.4.0" description=".NET Framework Data Provider for Microsoft SQL Server Compact" type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" />
|
||||
<add name="Microsoft SQL Server Compact Data Provider 4.0" invariant="System.Data.SqlServerCe.4.0" description=".NET Framework Data Provider for Microsoft SQL Server Compact" type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=4.0.0.1, Culture=neutral, PublicKeyToken=89845dcd8080cc91" />
|
||||
<remove invariant="MySql.Data.MySqlClient" />
|
||||
<add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.6.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
|
||||
</DbProviderFactories>
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace Umbraco.Tests.Cache.DistributedCache
|
||||
{
|
||||
for (var i = 1; i < 11; i++)
|
||||
{
|
||||
Web.Cache.DistributedCache.Instance.Refresh(Guid.Parse("E0F452CB-DCB2-4E84-B5A5-4F01744C5C73"), i);
|
||||
global::Umbraco.Web.Cache.DistributedCache.Instance.Refresh(Guid.Parse("E0F452CB-DCB2-4E84-B5A5-4F01744C5C73"), i);
|
||||
}
|
||||
Assert.AreEqual(10, ((TestServerMessenger)ServerMessengerResolver.Current.Messenger).IntIdsRefreshed.Count);
|
||||
}
|
||||
@@ -52,7 +52,7 @@ namespace Umbraco.Tests.Cache.DistributedCache
|
||||
{
|
||||
for (var i = 0; i < 10; i++)
|
||||
{
|
||||
Web.Cache.DistributedCache.Instance.Refresh(
|
||||
global::Umbraco.Web.Cache.DistributedCache.Instance.Refresh(
|
||||
Guid.Parse("E0F452CB-DCB2-4E84-B5A5-4F01744C5C73"),
|
||||
x => x.Id,
|
||||
new TestObjectWithId{Id = i});
|
||||
@@ -65,7 +65,7 @@ namespace Umbraco.Tests.Cache.DistributedCache
|
||||
{
|
||||
for (var i = 0; i < 11; i++)
|
||||
{
|
||||
Web.Cache.DistributedCache.Instance.Refresh(Guid.Parse("E0F452CB-DCB2-4E84-B5A5-4F01744C5C73"), Guid.NewGuid());
|
||||
global::Umbraco.Web.Cache.DistributedCache.Instance.Refresh(Guid.Parse("E0F452CB-DCB2-4E84-B5A5-4F01744C5C73"), Guid.NewGuid());
|
||||
}
|
||||
Assert.AreEqual(11, ((TestServerMessenger)ServerMessengerResolver.Current.Messenger).GuidIdsRefreshed.Count);
|
||||
}
|
||||
@@ -75,7 +75,7 @@ namespace Umbraco.Tests.Cache.DistributedCache
|
||||
{
|
||||
for (var i = 1; i < 13; i++)
|
||||
{
|
||||
Web.Cache.DistributedCache.Instance.Remove(Guid.Parse("E0F452CB-DCB2-4E84-B5A5-4F01744C5C73"), i);
|
||||
global::Umbraco.Web.Cache.DistributedCache.Instance.Remove(Guid.Parse("E0F452CB-DCB2-4E84-B5A5-4F01744C5C73"), i);
|
||||
}
|
||||
Assert.AreEqual(12, ((TestServerMessenger)ServerMessengerResolver.Current.Messenger).IntIdsRemoved.Count);
|
||||
}
|
||||
@@ -85,7 +85,7 @@ namespace Umbraco.Tests.Cache.DistributedCache
|
||||
{
|
||||
for (var i = 0; i < 13; i++)
|
||||
{
|
||||
Web.Cache.DistributedCache.Instance.RefreshAll(Guid.Parse("E0F452CB-DCB2-4E84-B5A5-4F01744C5C73"));
|
||||
global::Umbraco.Web.Cache.DistributedCache.Instance.RefreshAll(Guid.Parse("E0F452CB-DCB2-4E84-B5A5-4F01744C5C73"));
|
||||
}
|
||||
Assert.AreEqual(13, ((TestServerMessenger)ServerMessengerResolver.Current.Messenger).CountOfFullRefreshes);
|
||||
}
|
||||
|
||||
@@ -56,19 +56,19 @@ namespace Umbraco.Tests.Integration
|
||||
ServiceContext.DomainService.Save(new UmbracoDomain("*100112") { DomainName = "*100112", RootContentId = c3.Id, LanguageId = l2.Id });
|
||||
|
||||
var content = c2;
|
||||
var culture = Web.Models.ContentExtensions.GetCulture(null,
|
||||
var culture = global::Umbraco.Web.Models.ContentExtensions.GetCulture(null,
|
||||
ServiceContext.DomainService, ServiceContext.LocalizationService, ServiceContext.ContentService,
|
||||
content.Id, content.Path, new Uri("http://domain1.com/"));
|
||||
Assert.AreEqual("en-US", culture.Name);
|
||||
|
||||
content = c2;
|
||||
culture = Web.Models.ContentExtensions.GetCulture(null,
|
||||
culture = global::Umbraco.Web.Models.ContentExtensions.GetCulture(null,
|
||||
ServiceContext.DomainService, ServiceContext.LocalizationService, ServiceContext.ContentService,
|
||||
content.Id, content.Path, new Uri("http://domain1.fr/"));
|
||||
Assert.AreEqual("fr-FR", culture.Name);
|
||||
|
||||
content = c4;
|
||||
culture = Web.Models.ContentExtensions.GetCulture(null,
|
||||
culture = global::Umbraco.Web.Models.ContentExtensions.GetCulture(null,
|
||||
ServiceContext.DomainService, ServiceContext.LocalizationService, ServiceContext.ContentService,
|
||||
content.Id, content.Path, new Uri("http://domain1.fr/"));
|
||||
Assert.AreEqual("de-DE", culture.Name);
|
||||
@@ -104,13 +104,13 @@ namespace Umbraco.Tests.Integration
|
||||
//ServiceContext.DomainService.Save(new UmbracoDomain("*100112") { DomainName = "*100112", RootContentId = c3.Id, LanguageId = l2.Id });
|
||||
|
||||
var content = c2;
|
||||
var culture = Web.Models.ContentExtensions.GetCulture(null,
|
||||
var culture = Umbraco.Web.Models.ContentExtensions.GetCulture(null,
|
||||
ServiceContext.DomainService, ServiceContext.LocalizationService, ServiceContext.ContentService,
|
||||
content.Id, content.Path, new Uri("http://domain1.com/"));
|
||||
Assert.AreEqual("de-DE", culture.Name);
|
||||
|
||||
content = c4;
|
||||
culture = Web.Models.ContentExtensions.GetCulture(null,
|
||||
culture = Umbraco.Web.Models.ContentExtensions.GetCulture(null,
|
||||
ServiceContext.DomainService, ServiceContext.LocalizationService, ServiceContext.ContentService,
|
||||
content.Id, content.Path, new Uri("http://domain1.fr/"));
|
||||
Assert.AreEqual("fr-FR", culture.Name);
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using Semver;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Events;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Persistence;
|
||||
using Umbraco.Core.Persistence.Migrations;
|
||||
using Umbraco.Core.Profiling;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Web.Strategies.Migrations;
|
||||
|
||||
namespace Umbraco.Tests.Persistence.Migrations
|
||||
{
|
||||
[TestFixture]
|
||||
public class MigrationStartupHandlerTests
|
||||
{
|
||||
[Test]
|
||||
public void Executes_For_Any_Product_Name_When_Not_Specified()
|
||||
{
|
||||
var changed1 = new Args { CountExecuted = 0 };
|
||||
var testHandler1 = new TestMigrationHandler(changed1);
|
||||
testHandler1.OnApplicationStarting(Mock.Of<UmbracoApplicationBase>(), new ApplicationContext(CacheHelper.CreateDisabledCacheHelper(), new ProfilingLogger(Mock.Of<ILogger>(), Mock.Of<IProfiler>())));
|
||||
|
||||
var conn = new Mock<IDbConnection>();
|
||||
conn.Setup(x => x.BeginTransaction(It.IsAny<IsolationLevel>())).Returns(Mock.Of<IDbTransaction>());
|
||||
var db = new Mock<Database>(conn.Object);
|
||||
|
||||
var runner1 = new MigrationRunner(Mock.Of<IMigrationEntryService>(), Mock.Of<ILogger>(), new SemVersion(1), new SemVersion(2), "Test1",
|
||||
new IMigration[] { Mock.Of<IMigration>() });
|
||||
var result1 = runner1.Execute(db.Object, DatabaseProviders.SqlServerCE, false);
|
||||
Assert.AreEqual(1, changed1.CountExecuted);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Executes_Only_For_Specified_Product_Name()
|
||||
{
|
||||
var changed1 = new Args { CountExecuted = 0};
|
||||
var testHandler1 = new TestMigrationHandler("Test1", changed1);
|
||||
testHandler1.OnApplicationStarting(Mock.Of<UmbracoApplicationBase>(), new ApplicationContext(CacheHelper.CreateDisabledCacheHelper(), new ProfilingLogger(Mock.Of<ILogger>(), Mock.Of<IProfiler>())));
|
||||
var changed2 = new Args { CountExecuted = 0 };
|
||||
var testHandler2 = new TestMigrationHandler("Test2", changed2);
|
||||
testHandler2.OnApplicationStarting(Mock.Of<UmbracoApplicationBase>(), new ApplicationContext(CacheHelper.CreateDisabledCacheHelper(), new ProfilingLogger(Mock.Of<ILogger>(), Mock.Of<IProfiler>())));
|
||||
|
||||
var conn = new Mock<IDbConnection>();
|
||||
conn.Setup(x => x.BeginTransaction(It.IsAny<IsolationLevel>())).Returns(Mock.Of<IDbTransaction>());
|
||||
var db = new Mock<Database>(conn.Object);
|
||||
|
||||
var runner1 = new MigrationRunner(Mock.Of<IMigrationEntryService>(), Mock.Of<ILogger>(), new SemVersion(1), new SemVersion(2), "Test1",
|
||||
new IMigration[] { Mock.Of<IMigration>()});
|
||||
var result1 = runner1.Execute(db.Object, DatabaseProviders.SqlServerCE, false);
|
||||
Assert.AreEqual(1, changed1.CountExecuted);
|
||||
Assert.AreEqual(0, changed2.CountExecuted);
|
||||
|
||||
var runner2 = new MigrationRunner(Mock.Of<IMigrationEntryService>(), Mock.Of<ILogger>(), new SemVersion(1), new SemVersion(2), "Test2",
|
||||
new IMigration[] { Mock.Of<IMigration>() });
|
||||
var result2 = runner2.Execute(db.Object, DatabaseProviders.SqlServerCE, false);
|
||||
Assert.AreEqual(1, changed1.CountExecuted);
|
||||
Assert.AreEqual(1, changed2.CountExecuted);
|
||||
}
|
||||
|
||||
public class Args
|
||||
{
|
||||
public int CountExecuted { get; set; }
|
||||
}
|
||||
|
||||
public class TestMigrationHandler : MigrationStartupHander
|
||||
{
|
||||
private readonly string _prodName;
|
||||
private readonly Args _changed;
|
||||
|
||||
public TestMigrationHandler(Args changed)
|
||||
{
|
||||
_changed = changed;
|
||||
}
|
||||
|
||||
public TestMigrationHandler(string prodName, Args changed)
|
||||
{
|
||||
_prodName = prodName;
|
||||
_changed = changed;
|
||||
}
|
||||
|
||||
protected override void AfterMigration(MigrationRunner sender, MigrationEventArgs e)
|
||||
{
|
||||
_changed.CountExecuted++;
|
||||
}
|
||||
|
||||
public override string[] TargetProductNames
|
||||
{
|
||||
get { return _prodName.IsNullOrWhiteSpace() ? new string[] {} : new[] {_prodName}; }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,7 @@ namespace Umbraco.Tests.Persistence.Querying
|
||||
.InnerJoin("[cmsContentVersion]").On("[cmsDocument].[versionId] = [cmsContentVersion].[VersionId]")
|
||||
.InnerJoin("[cmsContent]").On("[cmsContentVersion].[ContentId] = [cmsContent].[nodeId]")
|
||||
.InnerJoin("[umbracoNode]").On("[cmsContent].[nodeId] = [umbracoNode].[id]")
|
||||
.Where("[umbracoNode].[nodeObjectType] = @0", new Guid("c66ba18e-eaf3-4cff-8a22-41b16d66a972"));
|
||||
.Where("([umbracoNode].[nodeObjectType] = @0)", new Guid("c66ba18e-eaf3-4cff-8a22-41b16d66a972"));
|
||||
|
||||
var sql = new Sql();
|
||||
sql.Select("*")
|
||||
@@ -56,8 +56,8 @@ namespace Umbraco.Tests.Persistence.Querying
|
||||
.InnerJoin("[cmsContentVersion]").On("[cmsDocument].[versionId] = [cmsContentVersion].[VersionId]")
|
||||
.InnerJoin("[cmsContent]").On("[cmsContentVersion].[ContentId] = [cmsContent].[nodeId]")
|
||||
.InnerJoin("[umbracoNode]").On("[cmsContent].[nodeId] = [umbracoNode].[id]")
|
||||
.Where("[umbracoNode].[nodeObjectType] = @0", new Guid("c66ba18e-eaf3-4cff-8a22-41b16d66a972"))
|
||||
.Where("[umbracoNode].[id] = @0", 1050);
|
||||
.Where("([umbracoNode].[nodeObjectType] = @0)", new Guid("c66ba18e-eaf3-4cff-8a22-41b16d66a972"))
|
||||
.Where("([umbracoNode].[id] = @0)", 1050);
|
||||
|
||||
var sql = new Sql();
|
||||
sql.Select("*")
|
||||
@@ -94,9 +94,9 @@ namespace Umbraco.Tests.Persistence.Querying
|
||||
.InnerJoin("[cmsContentVersion]").On("[cmsDocument].[versionId] = [cmsContentVersion].[VersionId]")
|
||||
.InnerJoin("[cmsContent]").On("[cmsContentVersion].[ContentId] = [cmsContent].[nodeId]")
|
||||
.InnerJoin("[umbracoNode]").On("[cmsContent].[nodeId] = [umbracoNode].[id]")
|
||||
.Where("[umbracoNode].[nodeObjectType] = @0", new Guid("c66ba18e-eaf3-4cff-8a22-41b16d66a972"))
|
||||
.Where("[umbracoNode].[id] = @0", 1050)
|
||||
.Where("[cmsContentVersion].[VersionId] = @0", new Guid("2b543516-a944-4ee6-88c6-8813da7aaa07"))
|
||||
.Where("([umbracoNode].[nodeObjectType] = @0)", new Guid("c66ba18e-eaf3-4cff-8a22-41b16d66a972"))
|
||||
.Where("([umbracoNode].[id] = @0)", 1050)
|
||||
.Where("([cmsContentVersion].[VersionId] = @0)", new Guid("2b543516-a944-4ee6-88c6-8813da7aaa07"))
|
||||
.OrderBy("[cmsContentVersion].[VersionDate] DESC");
|
||||
|
||||
var sql = new Sql();
|
||||
@@ -133,8 +133,8 @@ namespace Umbraco.Tests.Persistence.Querying
|
||||
expected.Select("*");
|
||||
expected.From("[cmsPropertyData]");
|
||||
expected.InnerJoin("[cmsPropertyType]").On("[cmsPropertyData].[propertytypeid] = [cmsPropertyType].[id]");
|
||||
expected.Where("[cmsPropertyData].[contentNodeId] = @0", 1050);
|
||||
expected.Where("[cmsPropertyData].[versionId] = @0", new Guid("2b543516-a944-4ee6-88c6-8813da7aaa07"));
|
||||
expected.Where("([cmsPropertyData].[contentNodeId] = @0)", 1050);
|
||||
expected.Where("([cmsPropertyData].[versionId] = @0)", new Guid("2b543516-a944-4ee6-88c6-8813da7aaa07"));
|
||||
|
||||
var sql = new Sql();
|
||||
sql.Select("*")
|
||||
|
||||
@@ -22,8 +22,8 @@ namespace Umbraco.Tests.Persistence.Querying
|
||||
.On("[cmsContentType].[nodeId] = [cmsDocumentType].[contentTypeNodeId]")
|
||||
.InnerJoin("[umbracoNode]")
|
||||
.On("[cmsContentType].[nodeId] = [umbracoNode].[id]")
|
||||
.Where("[umbracoNode].[nodeObjectType] = @0", new Guid("a2cb7800-f571-4787-9638-bc48539a0efb"))
|
||||
.Where("[cmsDocumentType].[IsDefault] = @0", true);
|
||||
.Where("([umbracoNode].[nodeObjectType] = @0)", new Guid("a2cb7800-f571-4787-9638-bc48539a0efb"))
|
||||
.Where("([cmsDocumentType].[IsDefault] = @0)", true);
|
||||
|
||||
var sql = new Sql();
|
||||
sql.Select("*")
|
||||
@@ -58,9 +58,9 @@ namespace Umbraco.Tests.Persistence.Querying
|
||||
.On("[cmsContentType].[nodeId] = [cmsDocumentType].[contentTypeNodeId]")
|
||||
.InnerJoin("[umbracoNode]")
|
||||
.On("[cmsContentType].[nodeId] = [umbracoNode].[id]")
|
||||
.Where("[umbracoNode].[nodeObjectType] = @0", new Guid("a2cb7800-f571-4787-9638-bc48539a0efb"))
|
||||
.Where("([umbracoNode].[nodeObjectType] = @0)", new Guid("a2cb7800-f571-4787-9638-bc48539a0efb"))
|
||||
.Where("[cmsDocumentType].[IsDefault] = @0", true)
|
||||
.Where("[umbracoNode].[id] = @0", 1050);
|
||||
.Where("([umbracoNode].[id] = @0)", 1050);
|
||||
|
||||
var sql = new Sql();
|
||||
sql.Select("*")
|
||||
@@ -112,7 +112,7 @@ namespace Umbraco.Tests.Persistence.Querying
|
||||
var expected = new Sql();
|
||||
expected.Select("*")
|
||||
.From("[cmsContentTypeAllowedContentType]")
|
||||
.Where("[cmsContentTypeAllowedContentType].[Id] = @0", 1050);
|
||||
.Where("([cmsContentTypeAllowedContentType].[Id] = @0)", 1050);
|
||||
|
||||
var sql = new Sql();
|
||||
sql.Select("*")
|
||||
@@ -138,7 +138,7 @@ namespace Umbraco.Tests.Persistence.Querying
|
||||
.From("[cmsPropertyTypeGroup]")
|
||||
.RightJoin("[cmsPropertyType]").On("[cmsPropertyTypeGroup].[id] = [cmsPropertyType].[propertyTypeGroupId]")
|
||||
.InnerJoin("[cmsDataType]").On("[cmsPropertyType].[dataTypeId] = [cmsDataType].[nodeId]")
|
||||
.Where("[cmsPropertyType].[contentTypeId] = @0", 1050);
|
||||
.Where("([cmsPropertyType].[contentTypeId] = @0)", 1050);
|
||||
|
||||
var sql = new Sql();
|
||||
sql.Select("*")
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ namespace Umbraco.Tests.Persistence.Querying
|
||||
expected.Select("*")
|
||||
.From("[cmsDataType]")
|
||||
.InnerJoin("[umbracoNode]").On("[cmsDataType].[nodeId] = [umbracoNode].[id]")
|
||||
.Where("[umbracoNode].[nodeObjectType] = @0", new Guid("30a2a501-1978-4ddb-a57b-f7efed43ba3c"));
|
||||
.Where("([umbracoNode].[nodeObjectType] = @0)", new Guid("30a2a501-1978-4ddb-a57b-f7efed43ba3c"));
|
||||
|
||||
var sql = new Sql();
|
||||
sql.Select("*")
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace Umbraco.Tests.Persistence.Querying
|
||||
|
||||
Console.WriteLine("Model to Sql ExpressionHelper: \n" + result);
|
||||
|
||||
Assert.AreEqual("[umbracoNode].[parentID] = @0", result);
|
||||
Assert.AreEqual("([umbracoNode].[parentID] = @0)", result);
|
||||
Assert.AreEqual(-1, modelToSqlExpressionHelper.GetSqlParameters()[0]);
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace Umbraco.Tests.Persistence.Querying
|
||||
|
||||
Console.WriteLine("Model to Sql ExpressionHelper: \n" + result);
|
||||
|
||||
Assert.AreEqual("[umbracoUser].[userLogin] = @0", result);
|
||||
Assert.AreEqual("([umbracoUser].[userLogin] = @0)", result);
|
||||
Assert.AreEqual("hello@world.com", modelToSqlExpressionHelper.GetSqlParameters()[0]);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace Umbraco.Tests.Persistence.Querying
|
||||
.From("[cmsContentVersion]")
|
||||
.InnerJoin("[cmsContent]").On("[cmsContentVersion].[ContentId] = [cmsContent].[nodeId]")
|
||||
.InnerJoin("[umbracoNode]").On("[cmsContent].[nodeId] = [umbracoNode].[id]")
|
||||
.Where("[umbracoNode].[nodeObjectType] = @0", new Guid("b796f64c-1f99-4ffb-b886-4bf4bc011a9c"));
|
||||
.Where("([umbracoNode].[nodeObjectType] = @0)", new Guid("b796f64c-1f99-4ffb-b886-4bf4bc011a9c"));
|
||||
|
||||
var sql = new Sql();
|
||||
sql.Select("*")
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace Umbraco.Tests.Persistence.Querying
|
||||
expected.Select("*")
|
||||
.From("[cmsContentType]")
|
||||
.InnerJoin("[umbracoNode]").On("[cmsContentType].[nodeId] = [umbracoNode].[id]")
|
||||
.Where("[umbracoNode].[nodeObjectType] = @0", new Guid("4ea4382b-2f5a-4c2b-9587-ae9b3cf3602e"));
|
||||
.Where("([umbracoNode].[nodeObjectType] = @0)", new Guid("4ea4382b-2f5a-4c2b-9587-ae9b3cf3602e"));
|
||||
|
||||
var sql = new Sql();
|
||||
sql.Select("*")
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace Umbraco.Tests.Persistence.Querying
|
||||
var content = new NodeDto() {NodeId = 123, Path = "-1,123"};
|
||||
var sql = new Sql("SELECT *").From<NodeDto>().Where<NodeDto>(x => x.Path.StartsWith(content.Path) && x.NodeId != content.NodeId);
|
||||
|
||||
Assert.AreEqual("SELECT * FROM [umbracoNode] WHERE (upper([umbracoNode].[path]) LIKE upper(@0) AND [umbracoNode].[id] <> @1)", sql.SQL.Replace("\n", " "));
|
||||
Assert.AreEqual("SELECT * FROM [umbracoNode] WHERE ((upper([umbracoNode].[path]) LIKE upper(@0) AND ([umbracoNode].[id] <> @1)))", sql.SQL.Replace("\n", " "));
|
||||
Assert.AreEqual(2, sql.Arguments.Length);
|
||||
Assert.AreEqual(content.Path + "%", sql.Arguments[0]);
|
||||
Assert.AreEqual(content.NodeId, sql.Arguments[1]);
|
||||
@@ -45,7 +45,19 @@ namespace Umbraco.Tests.Persistence.Querying
|
||||
var level = 1;
|
||||
var sql = new Sql("SELECT *").From<NodeDto>().Where<NodeDto>(x => x.Level == level && !x.Path.StartsWith("-20"));
|
||||
|
||||
Assert.AreEqual("SELECT * FROM [umbracoNode] WHERE ([umbracoNode].[level] = @0 AND NOT (upper([umbracoNode].[path]) LIKE upper(@1)))", sql.SQL.Replace("\n", " "));
|
||||
Assert.AreEqual("SELECT * FROM [umbracoNode] WHERE ((([umbracoNode].[level] = @0) AND NOT (upper([umbracoNode].[path]) LIKE upper(@1))))", sql.SQL.Replace("\n", " "));
|
||||
Assert.AreEqual(2, sql.Arguments.Length);
|
||||
Assert.AreEqual(level, sql.Arguments[0]);
|
||||
Assert.AreEqual("-20%", sql.Arguments[1]);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Where_Clause_With_EqualsFalse_Starts_With()
|
||||
{
|
||||
var level = 1;
|
||||
var sql = new Sql("SELECT *").From<NodeDto>().Where<NodeDto>(x => x.Level == level && x.Path.StartsWith("-20") == false);
|
||||
|
||||
Assert.AreEqual("SELECT * FROM [umbracoNode] WHERE ((([umbracoNode].[level] = @0) AND NOT (upper([umbracoNode].[path]) LIKE upper(@1))))", sql.SQL.Replace("\n", " "));
|
||||
Assert.AreEqual(2, sql.Arguments.Length);
|
||||
Assert.AreEqual(level, sql.Arguments[0]);
|
||||
Assert.AreEqual("-20%", sql.Arguments[1]);
|
||||
@@ -71,6 +83,16 @@ namespace Umbraco.Tests.Persistence.Querying
|
||||
Assert.AreEqual(true, sql.Arguments[0]);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Where_Clause_With_EqualsFalse_Boolean()
|
||||
{
|
||||
var sql = new Sql("SELECT *").From<NodeDto>().Where<NodeDto>(x => x.Trashed == false);
|
||||
|
||||
Assert.AreEqual("SELECT * FROM [umbracoNode] WHERE (NOT ([umbracoNode].[trashed] = @0))", sql.SQL.Replace("\n", " "));
|
||||
Assert.AreEqual(1, sql.Arguments.Length);
|
||||
Assert.AreEqual(true, sql.Arguments[0]);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Where_Clause_With_Boolean()
|
||||
{
|
||||
@@ -86,7 +108,7 @@ namespace Umbraco.Tests.Persistence.Querying
|
||||
{
|
||||
var sql = new Sql("SELECT *").From<NodeDto>().Where<NodeDto>(x => x.Text.ToUpper() == "hello".ToUpper());
|
||||
|
||||
Assert.AreEqual("SELECT * FROM [umbracoNode] WHERE (upper([umbracoNode].[text]) = upper(@0))", sql.SQL.Replace("\n", " "));
|
||||
Assert.AreEqual("SELECT * FROM [umbracoNode] WHERE ((upper([umbracoNode].[text]) = upper(@0)))", sql.SQL.Replace("\n", " "));
|
||||
Assert.AreEqual(1, sql.Arguments.Length);
|
||||
Assert.AreEqual("hello", sql.Arguments[0]);
|
||||
}
|
||||
@@ -96,7 +118,7 @@ namespace Umbraco.Tests.Persistence.Querying
|
||||
{
|
||||
var sql = new Sql("SELECT *").From<NodeDto>().Where<NodeDto>(x => x.Text == 1.ToString());
|
||||
|
||||
Assert.AreEqual("SELECT * FROM [umbracoNode] WHERE ([umbracoNode].[text] = @0)", sql.SQL.Replace("\n", " "));
|
||||
Assert.AreEqual("SELECT * FROM [umbracoNode] WHERE (([umbracoNode].[text] = @0))", sql.SQL.Replace("\n", " "));
|
||||
Assert.AreEqual(1, sql.Arguments.Length);
|
||||
Assert.AreEqual("1", sql.Arguments[0]);
|
||||
}
|
||||
@@ -116,7 +138,7 @@ namespace Umbraco.Tests.Persistence.Querying
|
||||
{
|
||||
var sql = new Sql("SELECT *").From<NodeDto>().Where<NodeDto>(x => x.NodeId == 2);
|
||||
|
||||
Assert.AreEqual("SELECT * FROM [umbracoNode] WHERE ([umbracoNode].[id] = @0)", sql.SQL.Replace("\n", " "));
|
||||
Assert.AreEqual("SELECT * FROM [umbracoNode] WHERE (([umbracoNode].[id] = @0))", sql.SQL.Replace("\n", " "));
|
||||
Assert.AreEqual(1, sql.Arguments.Length);
|
||||
Assert.AreEqual(2, sql.Arguments[0]);
|
||||
}
|
||||
@@ -126,7 +148,7 @@ namespace Umbraco.Tests.Persistence.Querying
|
||||
{
|
||||
var sql = new Sql("SELECT *").From<NodeDto>().Where<NodeDto>(x => x.NodeId != 2 && x.NodeId != 3);
|
||||
|
||||
Assert.AreEqual("SELECT * FROM [umbracoNode] WHERE ([umbracoNode].[id] <> @0 AND [umbracoNode].[id] <> @1)", sql.SQL.Replace("\n", " "));
|
||||
Assert.AreEqual("SELECT * FROM [umbracoNode] WHERE ((([umbracoNode].[id] <> @0) AND ([umbracoNode].[id] <> @1)))", sql.SQL.Replace("\n", " "));
|
||||
Assert.AreEqual(2, sql.Arguments.Length);
|
||||
Assert.AreEqual(2, sql.Arguments[0]);
|
||||
Assert.AreEqual(3, sql.Arguments[1]);
|
||||
@@ -137,7 +159,7 @@ namespace Umbraco.Tests.Persistence.Querying
|
||||
{
|
||||
var sql = new Sql("SELECT *").From<NodeDto>().Where<NodeDto>(x => x.Text == "hello" || x.NodeId == 3);
|
||||
|
||||
Assert.AreEqual("SELECT * FROM [umbracoNode] WHERE ([umbracoNode].[text] = @0 OR [umbracoNode].[id] = @1)", sql.SQL.Replace("\n", " "));
|
||||
Assert.AreEqual("SELECT * FROM [umbracoNode] WHERE ((([umbracoNode].[text] = @0) OR ([umbracoNode].[id] = @1)))", sql.SQL.Replace("\n", " "));
|
||||
Assert.AreEqual(2, sql.Arguments.Length);
|
||||
Assert.AreEqual("hello", sql.Arguments[0]);
|
||||
Assert.AreEqual(3, sql.Arguments[1]);
|
||||
@@ -208,7 +230,7 @@ namespace Umbraco.Tests.Persistence.Querying
|
||||
public void Can_Use_Where_Predicate()
|
||||
{
|
||||
var expected = new Sql();
|
||||
expected.Select("*").From("[cmsContent]").Where("[cmsContent].[nodeId] = @0", 1045);
|
||||
expected.Select("*").From("[cmsContent]").Where("([cmsContent].[nodeId] = @0)", 1045);
|
||||
|
||||
var sql = new Sql();
|
||||
sql.Select("*").From<ContentDto>().Where<ContentDto>(x => x.NodeId == 1045);
|
||||
@@ -224,8 +246,8 @@ namespace Umbraco.Tests.Persistence.Querying
|
||||
var expected = new Sql();
|
||||
expected.Select("*")
|
||||
.From("[cmsContent]")
|
||||
.Where("[cmsContent].[nodeId] = @0", 1045)
|
||||
.Where("[cmsContent].[contentType] = @0", 1050);
|
||||
.Where("([cmsContent].[nodeId] = @0)", 1045)
|
||||
.Where("([cmsContent].[contentType] = @0)", 1050);
|
||||
|
||||
var sql = new Sql();
|
||||
sql.Select("*")
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace Umbraco.Tests.Persistence.Querying
|
||||
var result = translator.Translate();
|
||||
var strResult = result.SQL;
|
||||
|
||||
string expectedResult = "SELECT *\nFROM umbracoNode\nWHERE ([umbracoNode].[parentID] = @0)";
|
||||
string expectedResult = "SELECT *\nFROM umbracoNode\nWHERE (([umbracoNode].[parentID] = @0))";
|
||||
|
||||
// Assert
|
||||
Assert.That(strResult, Is.Not.Empty);
|
||||
@@ -83,7 +83,7 @@ namespace Umbraco.Tests.Persistence.Querying
|
||||
var result = translator.Translate();
|
||||
var strResult = result.SQL;
|
||||
|
||||
string expectedResult = "SELECT *\nFROM umbracoNode\nWHERE ([cmsContentType].[alias] = @0)";
|
||||
string expectedResult = "SELECT *\nFROM umbracoNode\nWHERE (([cmsContentType].[alias] = @0))";
|
||||
|
||||
// Assert
|
||||
Assert.That(strResult, Is.Not.Empty);
|
||||
|
||||
@@ -90,7 +90,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
templateRepo.AddOrUpdate(template);
|
||||
}
|
||||
unitOfWork.Commit();
|
||||
|
||||
|
||||
var contentType = MockedContentTypes.CreateSimpleContentType();
|
||||
contentType.AllowedTemplates = new[] {templates[0], templates[1]};
|
||||
contentType.SetDefaultTemplate(templates[0]);
|
||||
@@ -127,7 +127,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
repository.AddOrUpdate(contentType);
|
||||
unitOfWork.Commit();
|
||||
|
||||
//create a
|
||||
//create a
|
||||
var contentType2 = (IContentType)new ContentType(contentType, "hello")
|
||||
{
|
||||
Name = "Blahasdfsadf"
|
||||
@@ -293,7 +293,9 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
using (var repository = CreateRepository(unitOfWork))
|
||||
{
|
||||
// Act
|
||||
var contentType = (IContentType)MockedContentTypes.CreateSimpleContentType("test", "Test", propertyGroupName: "testGroup");
|
||||
var contentType = (IContentType)MockedContentTypes.CreateSimpleContentType2("test", "Test", propertyGroupName: "testGroup");
|
||||
|
||||
Assert.AreEqual(4, contentType.PropertyTypes.Count());
|
||||
|
||||
// there is NO mapping from display to contentType, but only from save
|
||||
// to contentType, so if we want to test, let's to it properly!
|
||||
@@ -301,12 +303,18 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
var save = MapToContentTypeSave(display);
|
||||
var mapped = Mapper.Map<IContentType>(save);
|
||||
|
||||
Assert.AreEqual(4, mapped.PropertyTypes.Count());
|
||||
|
||||
repository.AddOrUpdate(mapped);
|
||||
unitOfWork.Commit();
|
||||
|
||||
Assert.AreEqual(4, mapped.PropertyTypes.Count());
|
||||
|
||||
//re-get
|
||||
contentType = repository.Get(mapped.Id);
|
||||
|
||||
Assert.AreEqual(4, contentType.PropertyTypes.Count());
|
||||
|
||||
// Assert
|
||||
Assert.That(contentType.HasIdentity, Is.True);
|
||||
Assert.That(contentType.PropertyGroups.All(x => x.HasIdentity), Is.True);
|
||||
@@ -316,7 +324,11 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
Assert.That(contentType.PropertyGroups.ElementAt(0).Name == "testGroup", Is.True);
|
||||
var groupId = contentType.PropertyGroups.ElementAt(0).Id;
|
||||
Assert.That(contentType.PropertyTypes.All(x => x.PropertyGroupId.Value == groupId), Is.True);
|
||||
|
||||
var propertyTypes = contentType.PropertyTypes.ToArray();
|
||||
Assert.AreEqual("gen", propertyTypes[0].Alias); // just to be sure
|
||||
Assert.IsNull(propertyTypes[0].PropertyGroupId);
|
||||
Assert.IsTrue(propertyTypes.Skip(1).All((x => x.PropertyGroupId.Value == groupId)));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -353,7 +365,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
Assert.That(contentType.PropertyTypes.Any(x => x.Alias == "subtitle"), Is.True);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
// this is for tests only because it makes no sense at all to have such a
|
||||
@@ -491,16 +503,16 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
var provider = new PetaPocoUnitOfWorkProvider(Logger);
|
||||
var unitOfWork = provider.GetUnitOfWork();
|
||||
using (var repository = CreateRepository(unitOfWork))
|
||||
{
|
||||
{
|
||||
var ctMain = MockedContentTypes.CreateSimpleContentType();
|
||||
var ctChild1 = MockedContentTypes.CreateSimpleContentType("child1", "Child 1", ctMain, true);
|
||||
var ctChild2 = MockedContentTypes.CreateSimpleContentType("child2", "Child 2", ctChild1, true);
|
||||
|
||||
|
||||
repository.AddOrUpdate(ctMain);
|
||||
repository.AddOrUpdate(ctChild1);
|
||||
repository.AddOrUpdate(ctChild2);
|
||||
repository.AddOrUpdate(ctChild2);
|
||||
unitOfWork.Commit();
|
||||
|
||||
|
||||
// Act
|
||||
|
||||
var resolvedParent = repository.Get(ctMain.Id);
|
||||
@@ -528,7 +540,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
var child3 = MockedContentTypes.CreateSimpleContentType("zyx", "zyx", contentType, randomizeAliases: true);
|
||||
repository.AddOrUpdate(child3);
|
||||
var child2 = MockedContentTypes.CreateSimpleContentType("a123", "a123", contentType, randomizeAliases: true);
|
||||
repository.AddOrUpdate(child2);
|
||||
repository.AddOrUpdate(child2);
|
||||
unitOfWork.Commit();
|
||||
|
||||
// Act
|
||||
@@ -540,7 +552,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
Assert.AreEqual("aabc", contentTypes.ElementAt(1).Name);
|
||||
Assert.AreEqual("zyx", contentTypes.ElementAt(2).Name);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -671,7 +683,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
{
|
||||
var contentType = repository.Get(NodeDto.NodeIdSeed + 1);
|
||||
|
||||
// Act
|
||||
// Act
|
||||
contentType.PropertyGroups["Meta"].PropertyTypes.Remove("description");
|
||||
repository.AddOrUpdate(contentType);
|
||||
unitOfWork.Commit();
|
||||
@@ -841,7 +853,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
Assert.That(contentType.PropertyTypes.Count(), Is.EqualTo(5));
|
||||
Assert.That(contentType.PropertyTypes.Any(x => x.Alias == "metaAuthor"), Is.True);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
@@ -1,17 +1,20 @@
|
||||
using System;
|
||||
|
||||
using System.Linq;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Models.Rdbms;
|
||||
using Umbraco.Core.Persistence;
|
||||
using Umbraco.Core.Persistence.DatabaseModelDefinitions;
|
||||
using Umbraco.Core.Persistence.Migrations;
|
||||
using Umbraco.Core.Persistence.SqlSyntax;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
|
||||
namespace Umbraco.Tests.Persistence.SyntaxProvider
|
||||
{
|
||||
[NUnit.Framework.Ignore("This doesn't actually test anything")]
|
||||
//[NUnit.Framework.Ignore("This doesn't actually test anything")]
|
||||
[TestFixture]
|
||||
public class MySqlSyntaxProviderTests
|
||||
public class MySqlSyntaxProviderTests : BaseUsingSqlCeSyntax
|
||||
{
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
@@ -20,6 +23,7 @@ namespace Umbraco.Tests.Persistence.SyntaxProvider
|
||||
}
|
||||
|
||||
[Test]
|
||||
[NUnit.Framework.Ignore]
|
||||
public void Can_Generate_Create_Table_Statement()
|
||||
{
|
||||
var type = typeof(TagRelationshipDto);
|
||||
@@ -48,5 +52,40 @@ namespace Umbraco.Tests.Persistence.SyntaxProvider
|
||||
{
|
||||
SqlSyntaxContext.SqlSyntaxProvider = null;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void U4_8017()
|
||||
{
|
||||
var logger = Mock.Of<ILogger>();
|
||||
var migration = new TestMigration(SqlSyntaxContext.SqlSyntaxProvider, logger);
|
||||
var context = new MigrationContext(DatabaseProviders.MySql, null, logger);
|
||||
migration.Context = context;
|
||||
migration.Up();
|
||||
var x = context.Expressions;
|
||||
Assert.AreEqual(1, x.Count);
|
||||
var e = x.First().ToString();
|
||||
|
||||
// SQLCE provider *does* use UniqueIdentifier
|
||||
// MySql using GUID...? because InitColumnTypeMap() missing in provider, fixed
|
||||
|
||||
Assert.AreEqual("ALTER TABLE `cmsPropertyTypeGroup` ADD COLUMN `uniqueID` char(36) NOT NULL", e);
|
||||
}
|
||||
|
||||
[Migration("1.0.0", 0, "Test")]
|
||||
private class TestMigration : MigrationBase
|
||||
{
|
||||
public TestMigration(ISqlSyntaxProvider sqlSyntax, ILogger logger) : base(sqlSyntax, logger)
|
||||
{}
|
||||
|
||||
public override void Up()
|
||||
{
|
||||
Create.Column("uniqueID").OnTable("cmsPropertyTypeGroup").AsGuid().NotNullable().WithDefault(SystemMethods.NewGuid);
|
||||
}
|
||||
|
||||
public override void Down()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,11 +9,12 @@ using Umbraco.Core.Persistence.DatabaseModelDefinitions;
|
||||
using Umbraco.Core.Persistence.Migrations.Syntax.Create.Index;
|
||||
using Umbraco.Core.Persistence.Migrations.Syntax.Expressions;
|
||||
using Umbraco.Core.Persistence.SqlSyntax;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
|
||||
namespace Umbraco.Tests.Persistence.SyntaxProvider
|
||||
{
|
||||
[TestFixture]
|
||||
public class SqlCeSyntaxProviderTests
|
||||
public class SqlCeSyntaxProviderTests : BaseUsingSqlCeSyntax
|
||||
{
|
||||
|
||||
[Test]
|
||||
@@ -35,7 +36,7 @@ namespace Umbraco.Tests.Persistence.SyntaxProvider
|
||||
FROM [cmsContentXml]
|
||||
INNER JOIN [umbracoNode]
|
||||
ON [cmsContentXml].[nodeId] = [umbracoNode].[id]
|
||||
WHERE ([umbracoNode].[nodeObjectType] = @0)) x)".Replace(Environment.NewLine, " ").Replace("\n", " ").Replace("\r", " "),
|
||||
WHERE (([umbracoNode].[nodeObjectType] = @0))) x)".Replace(Environment.NewLine, " ").Replace("\n", " ").Replace("\r", " "),
|
||||
sqlOutput.SQL.Replace(Environment.NewLine, " ").Replace("\n", " ").Replace("\r", " "));
|
||||
|
||||
Assert.AreEqual(1, sqlOutput.Arguments.Length);
|
||||
|
||||
@@ -79,8 +79,8 @@ namespace Umbraco.Tests.Plugins
|
||||
var originalTypesFound = TypeFinderOriginal.FindClassesOfType<IApplicationStartupHandler>(_assemblies);
|
||||
|
||||
Assert.AreEqual(originalTypesFound.Count(), typesFound.Count());
|
||||
Assert.AreEqual(8, typesFound.Count());
|
||||
Assert.AreEqual(8, originalTypesFound.Count());
|
||||
Assert.AreEqual(9, typesFound.Count());
|
||||
Assert.AreEqual(9, originalTypesFound.Count());
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
@@ -147,7 +147,7 @@ namespace Umbraco.Tests.PropertyEditors
|
||||
var dataTypeService = new Mock<IDataTypeService>();
|
||||
dataTypeService.Setup(x => x.GetPreValuesCollectionByDataTypeId(It.IsAny<int>())).Returns(new PreValueCollection(Enumerable.Empty<PreValue>()));
|
||||
|
||||
var converter = new Web.PropertyEditors.ValueConverters.ImageCropperValueConverter(dataTypeService.Object);
|
||||
var converter = new Umbraco.Web.PropertyEditors.ValueConverters.ImageCropperValueConverter(dataTypeService.Object);
|
||||
var result = converter.ConvertDataToSource(new PublishedPropertyType("test", 0, "test"), val1, false); // does not use type for conversion
|
||||
|
||||
var resultShouldMatch = val2.SerializeToCropDataSet();
|
||||
|
||||
@@ -234,9 +234,9 @@ namespace Umbraco.Tests.PublishedContent
|
||||
new PublishedPropertyType("prop1", 1, "?"),
|
||||
};
|
||||
|
||||
var contentType1 = new PublishedContentType(1, "ContentType1", props);
|
||||
var contentType2 = new PublishedContentType(2, "ContentType2", props);
|
||||
var contentType2s = new PublishedContentType(3, "ContentType2Sub", props);
|
||||
var contentType1 = new PublishedContentType(1, "ContentType1", Enumerable.Empty<string>(), props);
|
||||
var contentType2 = new PublishedContentType(2, "ContentType2", Enumerable.Empty<string>(), props);
|
||||
var contentType2s = new PublishedContentType(3, "ContentType2Sub", Enumerable.Empty<string>(), props);
|
||||
|
||||
cache.Add(new SolidPublishedContent(contentType1)
|
||||
{
|
||||
|
||||
@@ -355,7 +355,11 @@ namespace Umbraco.Tests.PublishedContent
|
||||
private static readonly PublishedPropertyType Default = new PublishedPropertyType("*", 0, "?");
|
||||
|
||||
public AutoPublishedContentType(int id, string alias, IEnumerable<PublishedPropertyType> propertyTypes)
|
||||
: base(id, alias, propertyTypes)
|
||||
: base(id, alias, Enumerable.Empty<string>(), propertyTypes)
|
||||
{ }
|
||||
|
||||
public AutoPublishedContentType(int id, string alias, IEnumerable<string> compositionAliases, IEnumerable<PublishedPropertyType> propertyTypes)
|
||||
: base(id, alias, compositionAliases, propertyTypes)
|
||||
{ }
|
||||
|
||||
public override PublishedPropertyType GetPropertyType(string alias)
|
||||
|
||||
@@ -50,7 +50,8 @@ namespace Umbraco.Tests.PublishedContent
|
||||
new PublishedPropertyType("content", 0, Constants.PropertyEditors.TinyMCEAlias),
|
||||
new PublishedPropertyType("testRecursive", 0, "?"),
|
||||
};
|
||||
var type = new AutoPublishedContentType(0, "anything", propertyTypes);
|
||||
var compositionAliases = new[] {"MyCompositionAlias"};
|
||||
var type = new AutoPublishedContentType(0, "anything", compositionAliases, propertyTypes);
|
||||
PublishedContentType.GetPublishedContentTypeCallback = (alias) => type;
|
||||
}
|
||||
|
||||
@@ -468,6 +469,16 @@ namespace Umbraco.Tests.PublishedContent
|
||||
Assert.IsNull(doc.FirstChild<IPublishedContent>());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IsComposedOf()
|
||||
{
|
||||
var doc = GetNode(1173);
|
||||
|
||||
var isComposedOf = doc.IsComposedOf("MyCompositionAlias");
|
||||
|
||||
Assert.IsTrue(isComposedOf);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void HasProperty()
|
||||
{
|
||||
@@ -475,8 +486,7 @@ namespace Umbraco.Tests.PublishedContent
|
||||
|
||||
var hasProp = doc.HasProperty(Constants.Conventions.Content.UrlAlias);
|
||||
|
||||
Assert.AreEqual(true, (bool)hasProp);
|
||||
|
||||
Assert.IsTrue(hasProp);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
@@ -380,7 +380,7 @@ namespace Umbraco.Tests.Routing
|
||||
var content = umbracoContext.ContentCache.GetById(nodeId);
|
||||
Assert.IsNotNull(content);
|
||||
|
||||
var culture = Web.Models.ContentExtensions.GetCulture(umbracoContext, domainService, ServiceContext.LocalizationService, null, content.Id, content.Path, new Uri(currentUrl));
|
||||
var culture = global::Umbraco.Web.Models.ContentExtensions.GetCulture(umbracoContext, domainService, ServiceContext.LocalizationService, null, content.Id, content.Path, new Uri(currentUrl));
|
||||
Assert.AreEqual(expectedCulture, culture.Name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Web;
|
||||
using Microsoft.Owin;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Configuration.UmbracoSettings;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Persistence;
|
||||
using Umbraco.Core.Persistence.SqlSyntax;
|
||||
using Umbraco.Core.Profiling;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
using Umbraco.Web;
|
||||
using Umbraco.Web.Routing;
|
||||
using Umbraco.Web.Security;
|
||||
using Umbraco.Web.Security.Identity;
|
||||
|
||||
namespace Umbraco.Tests.Security
|
||||
{
|
||||
[TestFixture]
|
||||
public class BackOfficeCookieManagerTests
|
||||
{
|
||||
[Test]
|
||||
public void ShouldAuthenticateRequest_When_Not_Configured()
|
||||
{
|
||||
//should force app ctx to show not-configured
|
||||
ConfigurationManager.AppSettings.Set("umbracoConfigurationStatus", "");
|
||||
|
||||
var dbCtx = new Mock<DatabaseContext>(Mock.Of<IDatabaseFactory>(), Mock.Of<ILogger>(), Mock.Of<ISqlSyntaxProvider>(), "test");
|
||||
dbCtx.Setup(x => x.IsDatabaseConfigured).Returns(false);
|
||||
|
||||
var appCtx = new ApplicationContext(
|
||||
dbCtx.Object,
|
||||
MockHelper.GetMockedServiceContext(),
|
||||
CacheHelper.CreateDisabledCacheHelper(),
|
||||
new ProfilingLogger(Mock.Of<ILogger>(), Mock.Of<IProfiler>()));
|
||||
|
||||
var umbCtx = UmbracoContext.CreateContext(
|
||||
Mock.Of<HttpContextBase>(),
|
||||
appCtx,
|
||||
new WebSecurity(Mock.Of<HttpContextBase>(), appCtx),
|
||||
Mock.Of<IUmbracoSettingsSection>(), new List<IUrlProvider>(), false);
|
||||
|
||||
var mgr = new BackOfficeCookieManager(Mock.Of<IUmbracoContextAccessor>(accessor => accessor.Value == umbCtx));
|
||||
|
||||
var result = mgr.ShouldAuthenticateRequest(Mock.Of<IOwinContext>(), new Uri("http://localhost/umbraco"));
|
||||
|
||||
Assert.IsFalse(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ShouldAuthenticateRequest_When_Configured()
|
||||
{
|
||||
var dbCtx = new Mock<DatabaseContext>(Mock.Of<IDatabaseFactory>(), Mock.Of<ILogger>(), Mock.Of<ISqlSyntaxProvider>(), "test");
|
||||
dbCtx.Setup(x => x.IsDatabaseConfigured).Returns(true);
|
||||
|
||||
var appCtx = new ApplicationContext(
|
||||
dbCtx.Object,
|
||||
MockHelper.GetMockedServiceContext(),
|
||||
CacheHelper.CreateDisabledCacheHelper(),
|
||||
new ProfilingLogger(Mock.Of<ILogger>(), Mock.Of<IProfiler>()));
|
||||
|
||||
var umbCtx = UmbracoContext.CreateContext(
|
||||
Mock.Of<HttpContextBase>(),
|
||||
appCtx,
|
||||
new WebSecurity(Mock.Of<HttpContextBase>(), appCtx),
|
||||
Mock.Of<IUmbracoSettingsSection>(), new List<IUrlProvider>(), false);
|
||||
|
||||
var mgr = new BackOfficeCookieManager(Mock.Of<IUmbracoContextAccessor>(accessor => accessor.Value == umbCtx));
|
||||
|
||||
var request = new Mock<OwinRequest>();
|
||||
request.Setup(owinRequest => owinRequest.Uri).Returns(new Uri("http://localhost/umbraco"));
|
||||
|
||||
var result = mgr.ShouldAuthenticateRequest(
|
||||
Mock.Of<IOwinContext>(context => context.Request == request.Object),
|
||||
new Uri("http://localhost/umbraco"));
|
||||
|
||||
Assert.IsTrue(result);
|
||||
}
|
||||
|
||||
//TODO : Write remaining tests for `ShouldAuthenticateRequest`
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using System.Text;
|
||||
@@ -9,6 +8,7 @@ using Newtonsoft.Json;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Security;
|
||||
using Umbraco.Core.Services;
|
||||
|
||||
namespace Umbraco.Tests.Security
|
||||
{
|
||||
|
||||
@@ -164,6 +164,24 @@ namespace Umbraco.Tests.TestHelpers.Entities
|
||||
return contentType;
|
||||
}
|
||||
|
||||
public static ContentType CreateSimpleContentType2(string alias, string name, IContentType parent = null, bool randomizeAliases = false, string propertyGroupName = "Content")
|
||||
{
|
||||
var contentType = CreateSimpleContentType(alias, name, parent, randomizeAliases, propertyGroupName);
|
||||
|
||||
var propertyType = new PropertyType(Constants.PropertyEditors.TextboxAlias, DataTypeDatabaseType.Ntext)
|
||||
{
|
||||
Alias = RandomAlias("gen", randomizeAliases),
|
||||
Name = "Gen",
|
||||
Description = "",
|
||||
Mandatory = false,
|
||||
SortOrder = 1,
|
||||
DataTypeDefinitionId = -88
|
||||
};
|
||||
contentType.AddPropertyType(propertyType);
|
||||
|
||||
return contentType;
|
||||
}
|
||||
|
||||
public static ContentType CreateSimpleContentType(string alias, string name, IContentType parent = null, bool randomizeAliases = false, string propertyGroupName = "Content")
|
||||
{
|
||||
var contentType = parent == null ? new ContentType(-1) : new ContentType(parent, alias);
|
||||
|
||||
@@ -75,6 +75,10 @@
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Lucene.Net.2.9.4.1\lib\net40\Lucene.Net.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Owin, Version=3.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Owin.3.0.1\lib\net45\Microsoft.Owin.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<Private>True</Private>
|
||||
<HintPath>..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath>
|
||||
@@ -94,6 +98,10 @@
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\NUnit.2.6.2\lib\nunit.framework.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Owin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f0ebd12fd5e55cc5, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Owin.1.0\lib\net40\Owin.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Semver">
|
||||
<HintPath>..\packages\semver.1.1.2\lib\net45\Semver.dll</HintPath>
|
||||
</Reference>
|
||||
@@ -102,13 +110,13 @@
|
||||
<Reference Include="System.configuration" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Data.Entity.Design" />
|
||||
<Reference Include="System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
|
||||
<Reference Include="System.Data.SqlServerCe, Version=4.0.0.1, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
|
||||
<Private>True</Private>
|
||||
<HintPath>..\packages\SqlServerCE.4.0.0.0\lib\System.Data.SqlServerCe.dll</HintPath>
|
||||
<HintPath>..\packages\SqlServerCE.4.0.0.1\lib\System.Data.SqlServerCe.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Data.SqlServerCe.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
|
||||
<Reference Include="System.Data.SqlServerCe.Entity, Version=4.0.0.1, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
|
||||
<Private>True</Private>
|
||||
<HintPath>..\packages\SqlServerCE.4.0.0.0\lib\System.Data.SqlServerCe.Entity.dll</HintPath>
|
||||
<HintPath>..\packages\SqlServerCE.4.0.0.1\lib\System.Data.SqlServerCe.Entity.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
@@ -167,10 +175,11 @@
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AngularIntegration\AngularAntiForgeryTests.cs" />
|
||||
<Compile Include="AngularIntegration\ContentModelSerializationTests.cs" />
|
||||
<Compile Include="AngularIntegration\JsInitializationTests.cs" />
|
||||
<Compile Include="AngularIntegration\ServerVariablesParserTests.cs" />
|
||||
<Compile Include="Persistence\Migrations\MigrationStartupHandlerTests.cs" />
|
||||
<Compile Include="Web\AngularIntegration\AngularAntiForgeryTests.cs" />
|
||||
<Compile Include="Web\AngularIntegration\ContentModelSerializationTests.cs" />
|
||||
<Compile Include="Web\AngularIntegration\JsInitializationTests.cs" />
|
||||
<Compile Include="Web\AngularIntegration\ServerVariablesParserTests.cs" />
|
||||
<Compile Include="ApplicationContextTests.cs" />
|
||||
<Compile Include="AttemptTests.cs" />
|
||||
<Compile Include="Cache\CacheRefresherTests.cs" />
|
||||
@@ -180,12 +189,12 @@
|
||||
<Compile Include="Cache\FullDataSetCachePolicyTests.cs" />
|
||||
<Compile Include="Cache\SingleItemsOnlyCachePolicyTests.cs" />
|
||||
<Compile Include="Collections\DeepCloneableListTests.cs" />
|
||||
<Compile Include="Controllers\BackOfficeControllerUnitTests.cs" />
|
||||
<Compile Include="Web\Controllers\BackOfficeControllerUnitTests.cs" />
|
||||
<Compile Include="DelegateExtensionsTests.cs" />
|
||||
<Compile Include="Logging\AsyncRollingFileAppenderTest.cs" />
|
||||
<Compile Include="Logging\DebugAppender.cs" />
|
||||
<Compile Include="Logging\ParallelForwarderTest.cs" />
|
||||
<Compile Include="Mvc\RenderIndexActionSelectorAttributeTests.cs" />
|
||||
<Compile Include="Web\Mvc\RenderIndexActionSelectorAttributeTests.cs" />
|
||||
<Compile Include="Persistence\Repositories\AuditRepositoryTest.cs" />
|
||||
<Compile Include="Persistence\Repositories\DomainRepositoryTest.cs" />
|
||||
<Compile Include="Persistence\Repositories\PartialViewRepositoryTests.cs" />
|
||||
@@ -195,6 +204,7 @@
|
||||
<Compile Include="Resolvers\ResolverBaseTest.cs" />
|
||||
<Compile Include="Routing\RoutesCacheTests.cs" />
|
||||
<Compile Include="Routing\UrlRoutingTestBase.cs" />
|
||||
<Compile Include="Security\BackOfficeCookieManagerTests.cs" />
|
||||
<Compile Include="Security\UmbracoBackOfficeIdentityTests.cs" />
|
||||
<Compile Include="Services\ContentTypeServiceExtensionsTests.cs" />
|
||||
<Compile Include="Services\PublicAccessServiceTests.cs" />
|
||||
@@ -235,8 +245,9 @@
|
||||
<Compile Include="Models\UmbracoEntityTests.cs" />
|
||||
<Compile Include="Models\UserTests.cs" />
|
||||
<Compile Include="Models\UserTypeTests.cs" />
|
||||
<Compile Include="Mvc\SurfaceControllerTests.cs" />
|
||||
<Compile Include="Mvc\UmbracoViewPageTests.cs" />
|
||||
<Compile Include="Web\Mvc\RenderModelBinderTests.cs" />
|
||||
<Compile Include="Web\Mvc\SurfaceControllerTests.cs" />
|
||||
<Compile Include="Web\Mvc\UmbracoViewPageTests.cs" />
|
||||
<Compile Include="BootManagers\CoreBootManagerTests.cs" />
|
||||
<Compile Include="BootManagers\WebBootManagerTests.cs" />
|
||||
<Compile Include="Cache\ObjectCacheProviderTests.cs" />
|
||||
@@ -311,9 +322,9 @@
|
||||
<Compile Include="Configurations\UmbracoSettings\ViewstateMoverModuleElementTests.cs" />
|
||||
<Compile Include="Configurations\UmbracoSettings\WebRoutingElementDefaultTests.cs" />
|
||||
<Compile Include="Configurations\UmbracoSettings\WebRoutingElementTests.cs" />
|
||||
<Compile Include="Controllers\WebApiEditors\ContentControllerUnitTests.cs" />
|
||||
<Compile Include="Controllers\WebApiEditors\FilterAllowedOutgoingContentAttributeTests.cs" />
|
||||
<Compile Include="Controllers\WebApiEditors\MediaControllerUnitTests.cs" />
|
||||
<Compile Include="Web\Controllers\WebApiEditors\ContentControllerUnitTests.cs" />
|
||||
<Compile Include="Web\Controllers\WebApiEditors\FilterAllowedOutgoingContentAttributeTests.cs" />
|
||||
<Compile Include="Web\Controllers\WebApiEditors\MediaControllerUnitTests.cs" />
|
||||
<Compile Include="CoreXml\FrameworkXmlTests.cs" />
|
||||
<Compile Include="DynamicsAndReflection\QueryableExtensionTests.cs" />
|
||||
<Compile Include="DynamicsAndReflection\ExtensionMethodFinderTests.cs" />
|
||||
@@ -323,8 +334,8 @@
|
||||
<Compile Include="Migrations\Upgrades\ValidateV7UpgradeTest.cs" />
|
||||
<Compile Include="Models\ContentExtensionsTests.cs" />
|
||||
<Compile Include="Models\UserExtensionsTests.cs" />
|
||||
<Compile Include="Mvc\MergeParentContextViewDataAttributeTests.cs" />
|
||||
<Compile Include="Mvc\ViewDataDictionaryExtensionTests.cs" />
|
||||
<Compile Include="Web\Mvc\MergeParentContextViewDataAttributeTests.cs" />
|
||||
<Compile Include="Web\Mvc\ViewDataDictionaryExtensionTests.cs" />
|
||||
<Compile Include="Persistence\PetaPocoExtensionsTest.cs" />
|
||||
<Compile Include="Persistence\Querying\ContentTypeSqlMappingTests.cs" />
|
||||
<Compile Include="Persistence\Repositories\MacroRepositoryTest.cs" />
|
||||
@@ -421,7 +432,7 @@
|
||||
<Compile Include="PublishedContent\PublishedContentTests.cs" />
|
||||
<Compile Include="PublishedContent\PublishedMediaTests.cs" />
|
||||
<Compile Include="HashCodeCombinerTests.cs" />
|
||||
<Compile Include="Mvc\HtmlHelperExtensionMethodsTests.cs" />
|
||||
<Compile Include="Web\Mvc\HtmlHelperExtensionMethodsTests.cs" />
|
||||
<Compile Include="IO\IOHelperTest.cs" />
|
||||
<Compile Include="LibraryTests.cs" />
|
||||
<Compile Include="PropertyEditors\PropertyEditorValueConverterTests.cs" />
|
||||
@@ -506,7 +517,7 @@
|
||||
<DependentUpon>ImportResources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Services\ThreadSafetyServiceTest.cs" />
|
||||
<Compile Include="Controllers\PluginControllerAreaTests.cs" />
|
||||
<Compile Include="Web\Controllers\PluginControllerAreaTests.cs" />
|
||||
<Compile Include="Cache\DistributedCache\DistributedCacheTests.cs" />
|
||||
<Compile Include="Templates\MasterPageHelperTests.cs" />
|
||||
<Compile Include="TestHelpers\BaseDatabaseFactoryTest.cs" />
|
||||
@@ -570,6 +581,7 @@
|
||||
<Compile Include="Plugins\TypeFinderTests.cs" />
|
||||
<Compile Include="Routing\UmbracoModuleTests.cs" />
|
||||
<Compile Include="VersionExtensionTests.cs" />
|
||||
<Compile Include="Web\WebExtensionMethodTests.cs" />
|
||||
<Compile Include="XmlExtensionsTests.cs" />
|
||||
<Compile Include="XmlHelperTests.cs" />
|
||||
</ItemGroup>
|
||||
@@ -739,11 +751,16 @@
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>xcopy "$(ProjectDir)"..\packages\SqlServerCE.4.0.0.0\amd64\*.* "$(TargetDir)amd64\" /Y /F /E /D
|
||||
xcopy "$(ProjectDir)"..\packages\SqlServerCE.4.0.0.0\x86\*.* "$(TargetDir)x86\" /Y /F /E /D</PostBuildEvent>
|
||||
<PostBuildEvent>
|
||||
</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(SolutionDir)\.nuget\nuget.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
<PropertyGroup>
|
||||
<PreBuildEvent>xcopy "$(ProjectDir)"..\packages\SqlServerCE.4.0.0.1\amd64\*.* "$(TargetDir)amd64\" /Y /F /E /I /C /D
|
||||
xcopy "$(ProjectDir)"..\packages\SqlServerCE.4.0.0.1\x86\*.* "$(TargetDir)x86\" /Y /F /E /I /C /D</PreBuildEvent>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(SolutionDir)\.nuget\nuget.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
|
||||
+2
-11
@@ -1,20 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Security.Claims;
|
||||
using System.Security.Principal;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using System.Web.Security;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core.Security;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
using Umbraco.Web.WebApi.Filters;
|
||||
|
||||
namespace Umbraco.Tests.AngularIntegration
|
||||
namespace Umbraco.Tests.Web.AngularIntegration
|
||||
{
|
||||
[TestFixture]
|
||||
public class AngularAntiForgeryTests
|
||||
+77
-80
@@ -1,80 +1,77 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using NUnit.Framework;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Web.Models.ContentEditing;
|
||||
|
||||
namespace Umbraco.Tests.AngularIntegration
|
||||
{
|
||||
[TestFixture]
|
||||
public class ContentModelSerializationTests
|
||||
{
|
||||
[Test]
|
||||
public void Content_Display_To_Json()
|
||||
{
|
||||
//create 3 tabs with 3 properties each
|
||||
var tabs = new List<Tab<ContentPropertyDisplay>>();
|
||||
for (var tabIndex = 0; tabIndex < 3; tabIndex ++)
|
||||
{
|
||||
var props = new List<ContentPropertyDisplay>();
|
||||
for (var propertyIndex = 0; propertyIndex < 3; propertyIndex ++)
|
||||
{
|
||||
props.Add(new ContentPropertyDisplay
|
||||
{
|
||||
Alias = "property" + propertyIndex,
|
||||
Label = "Property " + propertyIndex,
|
||||
Id = propertyIndex,
|
||||
Value = "value" + propertyIndex,
|
||||
Config = new Dictionary<string, object> {{ propertyIndex.ToInvariantString(), "value" }},
|
||||
Description = "Description " + propertyIndex,
|
||||
View = "~/Views/View" + propertyIndex,
|
||||
HideLabel = false
|
||||
});
|
||||
}
|
||||
tabs.Add(new Tab<ContentPropertyDisplay>()
|
||||
{
|
||||
Alias = "Tab" + tabIndex,
|
||||
Label = "Tab" + tabIndex,
|
||||
Properties = props
|
||||
});
|
||||
}
|
||||
|
||||
var displayModel = new ContentItemDisplay
|
||||
{
|
||||
Id = 1234,
|
||||
Name = "Test",
|
||||
Tabs = tabs
|
||||
};
|
||||
|
||||
var json = JsonConvert.SerializeObject(displayModel);
|
||||
|
||||
var jObject = JObject.Parse(json);
|
||||
|
||||
Assert.AreEqual("1234", jObject["id"].ToString());
|
||||
Assert.AreEqual("Test", jObject["name"].ToString());
|
||||
Assert.AreEqual(3, jObject["tabs"].Count());
|
||||
for (var tab = 0; tab < jObject["tabs"].Count(); tab++)
|
||||
{
|
||||
Assert.AreEqual("Tab" + tab, jObject["tabs"][tab]["alias"].ToString());
|
||||
Assert.AreEqual("Tab" + tab, jObject["tabs"][tab]["label"].ToString());
|
||||
Assert.AreEqual(3, jObject["tabs"][tab]["properties"].Count());
|
||||
for (var prop = 0; prop < jObject["tabs"][tab]["properties"].Count(); prop++)
|
||||
{
|
||||
Assert.AreEqual("property" + prop, jObject["tabs"][tab]["properties"][prop]["alias"].ToString());
|
||||
Assert.AreEqual("Property " + prop, jObject["tabs"][tab]["properties"][prop]["label"].ToString());
|
||||
Assert.AreEqual(prop, jObject["tabs"][tab]["properties"][prop]["id"].Value<int>());
|
||||
Assert.AreEqual("value" + prop, jObject["tabs"][tab]["properties"][prop]["value"].ToString());
|
||||
Assert.AreEqual("{\"" + prop + "\":\"value\"}", jObject["tabs"][tab]["properties"][prop]["config"].ToString(Formatting.None));
|
||||
Assert.AreEqual("Description " + prop, jObject["tabs"][tab]["properties"][prop]["description"].ToString());
|
||||
Assert.AreEqual(false, jObject["tabs"][tab]["properties"][prop]["hideLabel"].Value<bool>());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Web.Models.ContentEditing;
|
||||
|
||||
namespace Umbraco.Tests.Web.AngularIntegration
|
||||
{
|
||||
[TestFixture]
|
||||
public class ContentModelSerializationTests
|
||||
{
|
||||
[Test]
|
||||
public void Content_Display_To_Json()
|
||||
{
|
||||
//create 3 tabs with 3 properties each
|
||||
var tabs = new List<Tab<ContentPropertyDisplay>>();
|
||||
for (var tabIndex = 0; tabIndex < 3; tabIndex ++)
|
||||
{
|
||||
var props = new List<ContentPropertyDisplay>();
|
||||
for (var propertyIndex = 0; propertyIndex < 3; propertyIndex ++)
|
||||
{
|
||||
props.Add(new ContentPropertyDisplay
|
||||
{
|
||||
Alias = "property" + propertyIndex,
|
||||
Label = "Property " + propertyIndex,
|
||||
Id = propertyIndex,
|
||||
Value = "value" + propertyIndex,
|
||||
Config = new Dictionary<string, object> {{ propertyIndex.ToInvariantString(), "value" }},
|
||||
Description = "Description " + propertyIndex,
|
||||
View = "~/Views/View" + propertyIndex,
|
||||
HideLabel = false
|
||||
});
|
||||
}
|
||||
tabs.Add(new Tab<ContentPropertyDisplay>()
|
||||
{
|
||||
Alias = "Tab" + tabIndex,
|
||||
Label = "Tab" + tabIndex,
|
||||
Properties = props
|
||||
});
|
||||
}
|
||||
|
||||
var displayModel = new ContentItemDisplay
|
||||
{
|
||||
Id = 1234,
|
||||
Name = "Test",
|
||||
Tabs = tabs
|
||||
};
|
||||
|
||||
var json = JsonConvert.SerializeObject(displayModel);
|
||||
|
||||
var jObject = JObject.Parse(json);
|
||||
|
||||
Assert.AreEqual("1234", jObject["id"].ToString());
|
||||
Assert.AreEqual("Test", jObject["name"].ToString());
|
||||
Assert.AreEqual(3, jObject["tabs"].Count());
|
||||
for (var tab = 0; tab < jObject["tabs"].Count(); tab++)
|
||||
{
|
||||
Assert.AreEqual("Tab" + tab, jObject["tabs"][tab]["alias"].ToString());
|
||||
Assert.AreEqual("Tab" + tab, jObject["tabs"][tab]["label"].ToString());
|
||||
Assert.AreEqual(3, jObject["tabs"][tab]["properties"].Count());
|
||||
for (var prop = 0; prop < jObject["tabs"][tab]["properties"].Count(); prop++)
|
||||
{
|
||||
Assert.AreEqual("property" + prop, jObject["tabs"][tab]["properties"][prop]["alias"].ToString());
|
||||
Assert.AreEqual("Property " + prop, jObject["tabs"][tab]["properties"][prop]["label"].ToString());
|
||||
Assert.AreEqual(prop, jObject["tabs"][tab]["properties"][prop]["id"].Value<int>());
|
||||
Assert.AreEqual("value" + prop, jObject["tabs"][tab]["properties"][prop]["value"].ToString());
|
||||
Assert.AreEqual("{\"" + prop + "\":\"value\"}", jObject["tabs"][tab]["properties"][prop]["config"].ToString(Formatting.None));
|
||||
Assert.AreEqual("Description " + prop, jObject["tabs"][tab]["properties"][prop]["description"].ToString());
|
||||
Assert.AreEqual(false, jObject["tabs"][tab]["properties"][prop]["hideLabel"].Value<bool>());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+36
-41
@@ -1,41 +1,36 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using NUnit.Framework;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Umbraco.Core.Manifest;
|
||||
using Umbraco.Web.UI.JavaScript;
|
||||
|
||||
namespace Umbraco.Tests.AngularIntegration
|
||||
{
|
||||
[TestFixture]
|
||||
public class JsInitializationTests
|
||||
{
|
||||
|
||||
[Test]
|
||||
public void Get_Default_Init()
|
||||
{
|
||||
var init = JsInitialization.GetDefaultInitialization();
|
||||
Assert.IsTrue(init.Any());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Parse_Main()
|
||||
{
|
||||
var result = JsInitialization.ParseMain(new[] {"[World]", "Hello" });
|
||||
|
||||
Assert.AreEqual(@"LazyLoad.js([World], function () {
|
||||
//we need to set the legacy UmbClientMgr path
|
||||
UmbClientMgr.setUmbracoPath('Hello');
|
||||
|
||||
jQuery(document).ready(function () {
|
||||
|
||||
angular.bootstrap(document, ['umbraco']);
|
||||
|
||||
});
|
||||
});", result);
|
||||
}
|
||||
}
|
||||
}
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Web.UI.JavaScript;
|
||||
|
||||
namespace Umbraco.Tests.Web.AngularIntegration
|
||||
{
|
||||
[TestFixture]
|
||||
public class JsInitializationTests
|
||||
{
|
||||
|
||||
[Test]
|
||||
public void Get_Default_Init()
|
||||
{
|
||||
var init = JsInitialization.GetDefaultInitialization();
|
||||
Assert.IsTrue(init.Any());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Parse_Main()
|
||||
{
|
||||
var result = JsInitialization.ParseMain(new[] {"[World]", "Hello" });
|
||||
|
||||
Assert.AreEqual(@"LazyLoad.js([World], function () {
|
||||
//we need to set the legacy UmbClientMgr path
|
||||
UmbClientMgr.setUmbracoPath('Hello');
|
||||
|
||||
jQuery(document).ready(function () {
|
||||
|
||||
angular.bootstrap(document, ['umbraco']);
|
||||
|
||||
});
|
||||
});".StripWhitespace(), result.StripWhitespace());
|
||||
}
|
||||
}
|
||||
}
|
||||
+33
-32
@@ -1,33 +1,34 @@
|
||||
using System.Collections.Generic;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Web.UI.JavaScript;
|
||||
|
||||
namespace Umbraco.Tests.AngularIntegration
|
||||
{
|
||||
[TestFixture]
|
||||
public class ServerVariablesParserTests
|
||||
{
|
||||
|
||||
|
||||
[Test]
|
||||
public void Parse()
|
||||
{
|
||||
var d = new Dictionary<string, object>();
|
||||
d.Add("test1", "Test 1");
|
||||
d.Add("test2", "Test 2");
|
||||
d.Add("test3", "Test 3");
|
||||
d.Add("test4", "Test 4");
|
||||
d.Add("test5", "Test 5");
|
||||
|
||||
var output = ServerVariablesParser.Parse(d);
|
||||
|
||||
Assert.IsTrue(output.Contains(@"Umbraco.Sys.ServerVariables = {
|
||||
""test1"": ""Test 1"",
|
||||
""test2"": ""Test 2"",
|
||||
""test3"": ""Test 3"",
|
||||
""test4"": ""Test 4"",
|
||||
""test5"": ""Test 5""
|
||||
} ;"));
|
||||
}
|
||||
}
|
||||
using System.Collections.Generic;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Web.UI.JavaScript;
|
||||
using Umbraco.Core;
|
||||
|
||||
namespace Umbraco.Tests.Web.AngularIntegration
|
||||
{
|
||||
[TestFixture]
|
||||
public class ServerVariablesParserTests
|
||||
{
|
||||
|
||||
|
||||
[Test]
|
||||
public void Parse()
|
||||
{
|
||||
var d = new Dictionary<string, object>();
|
||||
d.Add("test1", "Test 1");
|
||||
d.Add("test2", "Test 2");
|
||||
d.Add("test3", "Test 3");
|
||||
d.Add("test4", "Test 4");
|
||||
d.Add("test5", "Test 5");
|
||||
|
||||
var output = ServerVariablesParser.Parse(d).StripWhitespace();
|
||||
|
||||
Assert.IsTrue(output.Contains(@"Umbraco.Sys.ServerVariables = {
|
||||
""test1"": ""Test 1"",
|
||||
""test2"": ""Test 2"",
|
||||
""test3"": ""Test 3"",
|
||||
""test4"": ""Test 4"",
|
||||
""test5"": ""Test 5""
|
||||
} ;".StripWhitespace()));
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Web.Editors;
|
||||
|
||||
namespace Umbraco.Tests.Controllers
|
||||
namespace Umbraco.Tests.Web.Controllers
|
||||
{
|
||||
[TestFixture]
|
||||
public class BackOfficeControllerUnitTests
|
||||
+1
-1
@@ -4,7 +4,7 @@ using Umbraco.Tests.TestHelpers;
|
||||
using Umbraco.Web;
|
||||
using Umbraco.Web.Mvc;
|
||||
|
||||
namespace Umbraco.Tests.Controllers
|
||||
namespace Umbraco.Tests.Web.Controllers
|
||||
{
|
||||
[TestFixture]
|
||||
public class PluginControllerAreaTests : BaseWebTest
|
||||
+366
-366
@@ -1,366 +1,366 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Web.Http;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Web.Editors;
|
||||
|
||||
namespace Umbraco.Tests.Controllers.WebApiEditors
|
||||
{
|
||||
[TestFixture]
|
||||
public class ContentControllerUnitTests
|
||||
{
|
||||
[Test]
|
||||
public void Access_Allowed_By_Path()
|
||||
{
|
||||
//arrange
|
||||
var userMock = new Mock<IUser>();
|
||||
userMock.Setup(u => u.Id).Returns(9);
|
||||
userMock.Setup(u => u.StartContentId).Returns(-1);
|
||||
var user = userMock.Object;
|
||||
var contentMock = new Mock<IContent>();
|
||||
contentMock.Setup(c => c.Path).Returns("-1,1234,5678");
|
||||
var content = contentMock.Object;
|
||||
var contentServiceMock = new Mock<IContentService>();
|
||||
contentServiceMock.Setup(x => x.GetById(1234)).Returns(content);
|
||||
var contentService = contentServiceMock.Object;
|
||||
|
||||
//act
|
||||
var result = ContentController.CheckPermissions(new Dictionary<string, object>(), user, null, contentService, 1234);
|
||||
|
||||
//assert
|
||||
Assert.IsTrue(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Throws_Exception_When_No_Content_Found()
|
||||
{
|
||||
//arrange
|
||||
var userMock = new Mock<IUser>();
|
||||
userMock.Setup(u => u.Id).Returns(9);
|
||||
userMock.Setup(u => u.StartContentId).Returns(-1);
|
||||
var user = userMock.Object;
|
||||
var contentMock = new Mock<IContent>();
|
||||
contentMock.Setup(c => c.Path).Returns("-1,1234,5678");
|
||||
var content = contentMock.Object;
|
||||
var contentServiceMock = new Mock<IContentService>();
|
||||
contentServiceMock.Setup(x => x.GetById(0)).Returns(content);
|
||||
var contentService = contentServiceMock.Object;
|
||||
var userServiceMock = new Mock<IUserService>();
|
||||
var permissions = new List<EntityPermission>();
|
||||
userServiceMock.Setup(x => x.GetPermissions(user, 1234)).Returns(permissions);
|
||||
var userService = userServiceMock.Object;
|
||||
|
||||
//act/assert
|
||||
Assert.Throws<HttpResponseException>(() => ContentController.CheckPermissions(new Dictionary<string, object>(), user, userService, contentService, 1234, new[] { 'F' }));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void No_Access_By_Path()
|
||||
{
|
||||
//arrange
|
||||
var userMock = new Mock<IUser>();
|
||||
userMock.Setup(u => u.Id).Returns(9);
|
||||
userMock.Setup(u => u.StartContentId).Returns(9876);
|
||||
var user = userMock.Object;
|
||||
var contentMock = new Mock<IContent>();
|
||||
contentMock.Setup(c => c.Path).Returns("-1,1234,5678");
|
||||
var content = contentMock.Object;
|
||||
var contentServiceMock = new Mock<IContentService>();
|
||||
contentServiceMock.Setup(x => x.GetById(1234)).Returns(content);
|
||||
var contentService = contentServiceMock.Object;
|
||||
var userServiceMock = new Mock<IUserService>();
|
||||
var permissions = new List<EntityPermission>();
|
||||
userServiceMock.Setup(x => x.GetPermissions(user, 1234)).Returns(permissions);
|
||||
var userService = userServiceMock.Object;
|
||||
|
||||
//act
|
||||
var result = ContentController.CheckPermissions(new Dictionary<string, object>(), user, userService, contentService, 1234, new[] { 'F'});
|
||||
|
||||
//assert
|
||||
Assert.IsFalse(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void No_Access_By_Permission()
|
||||
{
|
||||
//arrange
|
||||
var userMock = new Mock<IUser>();
|
||||
userMock.Setup(u => u.Id).Returns(9);
|
||||
userMock.Setup(u => u.StartContentId).Returns(-1);
|
||||
var user = userMock.Object;
|
||||
var contentMock = new Mock<IContent>();
|
||||
contentMock.Setup(c => c.Path).Returns("-1,1234,5678");
|
||||
var content = contentMock.Object;
|
||||
var contentServiceMock = new Mock<IContentService>();
|
||||
contentServiceMock.Setup(x => x.GetById(1234)).Returns(content);
|
||||
var contentService = contentServiceMock.Object;
|
||||
var userServiceMock = new Mock<IUserService>();
|
||||
var permissions = new List<EntityPermission>
|
||||
{
|
||||
new EntityPermission(9, 1234, new string[]{ "A", "B", "C" })
|
||||
};
|
||||
userServiceMock.Setup(x => x.GetPermissions(user, 1234)).Returns(permissions);
|
||||
var userService = userServiceMock.Object;
|
||||
|
||||
//act
|
||||
var result = ContentController.CheckPermissions(new Dictionary<string, object>(), user, userService, contentService, 1234, new[] { 'F'});
|
||||
|
||||
//assert
|
||||
Assert.IsFalse(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Access_Allowed_By_Permission()
|
||||
{
|
||||
//arrange
|
||||
var userMock = new Mock<IUser>();
|
||||
userMock.Setup(u => u.Id).Returns(9);
|
||||
userMock.Setup(u => u.StartContentId).Returns(-1);
|
||||
var user = userMock.Object;
|
||||
var contentMock = new Mock<IContent>();
|
||||
contentMock.Setup(c => c.Path).Returns("-1,1234,5678");
|
||||
var content = contentMock.Object;
|
||||
var contentServiceMock = new Mock<IContentService>();
|
||||
contentServiceMock.Setup(x => x.GetById(1234)).Returns(content);
|
||||
var contentService = contentServiceMock.Object;
|
||||
var userServiceMock = new Mock<IUserService>();
|
||||
var permissions = new List<EntityPermission>
|
||||
{
|
||||
new EntityPermission(9, 1234, new string[]{ "A", "F", "C" })
|
||||
};
|
||||
userServiceMock.Setup(x => x.GetPermissions(user, 1234)).Returns(permissions);
|
||||
var userService = userServiceMock.Object;
|
||||
|
||||
//act
|
||||
var result = ContentController.CheckPermissions(new Dictionary<string, object>(), user, userService, contentService, 1234, new[] { 'F'});
|
||||
|
||||
//assert
|
||||
Assert.IsTrue(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Access_To_Root_By_Path()
|
||||
{
|
||||
//arrange
|
||||
var userMock = new Mock<IUser>();
|
||||
userMock.Setup(u => u.Id).Returns(0);
|
||||
userMock.Setup(u => u.StartContentId).Returns(-1);
|
||||
var user = userMock.Object;
|
||||
|
||||
//act
|
||||
var result = ContentController.CheckPermissions(new Dictionary<string, object>(), user, null, null, -1);
|
||||
|
||||
//assert
|
||||
Assert.IsTrue(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Access_To_Recycle_Bin_By_Path()
|
||||
{
|
||||
//arrange
|
||||
var userMock = new Mock<IUser>();
|
||||
userMock.Setup(u => u.Id).Returns(0);
|
||||
userMock.Setup(u => u.StartContentId).Returns(-1);
|
||||
var user = userMock.Object;
|
||||
|
||||
//act
|
||||
var result = ContentController.CheckPermissions(new Dictionary<string, object>(), user, null, null, -20);
|
||||
|
||||
//assert
|
||||
Assert.IsTrue(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void No_Access_To_Recycle_Bin_By_Path()
|
||||
{
|
||||
//arrange
|
||||
var userMock = new Mock<IUser>();
|
||||
userMock.Setup(u => u.Id).Returns(0);
|
||||
userMock.Setup(u => u.StartContentId).Returns(1234);
|
||||
var user = userMock.Object;
|
||||
|
||||
//act
|
||||
var result = ContentController.CheckPermissions(new Dictionary<string, object>(), user, null, null, -20);
|
||||
|
||||
//assert
|
||||
Assert.IsFalse(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void No_Access_To_Root_By_Path()
|
||||
{
|
||||
//arrange
|
||||
var userMock = new Mock<IUser>();
|
||||
userMock.Setup(u => u.Id).Returns(0);
|
||||
userMock.Setup(u => u.StartContentId).Returns(1234);
|
||||
var user = userMock.Object;
|
||||
|
||||
//act
|
||||
var result = ContentController.CheckPermissions(new Dictionary<string, object>(), user, null, null, -1);
|
||||
|
||||
//assert
|
||||
Assert.IsFalse(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Access_To_Root_By_Permission()
|
||||
{
|
||||
//arrange
|
||||
var userMock = new Mock<IUser>();
|
||||
userMock.Setup(u => u.Id).Returns(0);
|
||||
userMock.Setup(u => u.StartContentId).Returns(-1);
|
||||
var user = userMock.Object;
|
||||
|
||||
var userServiceMock = new Mock<IUserService>();
|
||||
var permissions = new List<EntityPermission>
|
||||
{
|
||||
new EntityPermission(9, 1234, new string[]{ "A" })
|
||||
};
|
||||
userServiceMock.Setup(x => x.GetPermissions(user, -1)).Returns(permissions);
|
||||
var userService = userServiceMock.Object;
|
||||
|
||||
//act
|
||||
var result = ContentController.CheckPermissions(new Dictionary<string, object>(), user, userService, null, -1, new[] { 'A'});
|
||||
|
||||
//assert
|
||||
Assert.IsTrue(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void No_Access_To_Root_By_Permission()
|
||||
{
|
||||
//arrange
|
||||
var userMock = new Mock<IUser>();
|
||||
userMock.Setup(u => u.Id).Returns(0);
|
||||
userMock.Setup(u => u.StartContentId).Returns(-1);
|
||||
var user = userMock.Object;
|
||||
|
||||
var userServiceMock = new Mock<IUserService>();
|
||||
var permissions = new List<EntityPermission>
|
||||
{
|
||||
new EntityPermission(9, 1234, new string[]{ "A" })
|
||||
};
|
||||
userServiceMock.Setup(x => x.GetPermissions(user, -1)).Returns(permissions);
|
||||
var userService = userServiceMock.Object;
|
||||
|
||||
//act
|
||||
var result = ContentController.CheckPermissions(new Dictionary<string, object>(), user, userService, null, -1, new[] { 'B'});
|
||||
|
||||
//assert
|
||||
Assert.IsFalse(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Access_To_Recycle_Bin_By_Permission()
|
||||
{
|
||||
//arrange
|
||||
var userMock = new Mock<IUser>();
|
||||
userMock.Setup(u => u.Id).Returns(0);
|
||||
userMock.Setup(u => u.StartContentId).Returns(-1);
|
||||
var user = userMock.Object;
|
||||
|
||||
var userServiceMock = new Mock<IUserService>();
|
||||
var permissions = new List<EntityPermission>
|
||||
{
|
||||
new EntityPermission(9, 1234, new string[]{ "A" })
|
||||
};
|
||||
userServiceMock.Setup(x => x.GetPermissions(user, -20)).Returns(permissions);
|
||||
var userService = userServiceMock.Object;
|
||||
|
||||
//act
|
||||
var result = ContentController.CheckPermissions(new Dictionary<string, object>(), user, userService, null, -20, new[] { 'A'});
|
||||
|
||||
//assert
|
||||
Assert.IsTrue(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void No_Access_To_Recycle_Bin_By_Permission()
|
||||
{
|
||||
//arrange
|
||||
var userMock = new Mock<IUser>();
|
||||
userMock.Setup(u => u.Id).Returns(0);
|
||||
userMock.Setup(u => u.StartContentId).Returns(-1);
|
||||
var user = userMock.Object;
|
||||
|
||||
var userServiceMock = new Mock<IUserService>();
|
||||
var permissions = new List<EntityPermission>
|
||||
{
|
||||
new EntityPermission(9, 1234, new string[]{ "A" })
|
||||
};
|
||||
userServiceMock.Setup(x => x.GetPermissions(user, -20)).Returns(permissions);
|
||||
var userService = userServiceMock.Object;
|
||||
|
||||
//act
|
||||
var result = ContentController.CheckPermissions(new Dictionary<string, object>(), user, userService, null, -20, new[] { 'B'});
|
||||
|
||||
//assert
|
||||
Assert.IsFalse(result);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//NOTE: The below self hosted stuff does work so need to get some tests written. Some are not possible atm because
|
||||
// of the legacy SQL calls like checking permissions.
|
||||
|
||||
//[TestFixture]
|
||||
//public class ContentControllerHostedTests : BaseRoutingTest
|
||||
//{
|
||||
|
||||
// protected override DatabaseBehavior DatabaseTestBehavior
|
||||
// {
|
||||
// get { return DatabaseBehavior.NoDatabasePerFixture; }
|
||||
// }
|
||||
|
||||
// public override void TearDown()
|
||||
// {
|
||||
// base.TearDown();
|
||||
// UmbracoAuthorizeAttribute.Enable = true;
|
||||
// UmbracoApplicationAuthorizeAttribute.Enable = true;
|
||||
// }
|
||||
|
||||
// /// <summary>
|
||||
// /// Tests to ensure that the response filter works so that any items the user
|
||||
// /// doesn't have access to are removed
|
||||
// /// </summary>
|
||||
// [Test]
|
||||
// public async void Get_By_Ids_Response_Filtered()
|
||||
// {
|
||||
// UmbracoAuthorizeAttribute.Enable = false;
|
||||
// UmbracoApplicationAuthorizeAttribute.Enable = false;
|
||||
|
||||
// var baseUrl = string.Format("http://{0}:9876", Environment.MachineName);
|
||||
// var url = baseUrl + "/api/Content/GetByIds?ids=1&ids=2";
|
||||
|
||||
// var routingCtx = GetRoutingContext(url, 1234, null, true);
|
||||
|
||||
// var config = new HttpSelfHostConfiguration(baseUrl);
|
||||
// using (var server = new HttpSelfHostServer(config))
|
||||
// {
|
||||
// var route = config.Routes.MapHttpRoute("test", "api/Content/GetByIds",
|
||||
// new
|
||||
// {
|
||||
// controller = "Content",
|
||||
// action = "GetByIds",
|
||||
// id = RouteParameter.Optional
|
||||
// });
|
||||
// route.DataTokens["Namespaces"] = new string[] { "Umbraco.Web.Editors" };
|
||||
|
||||
// var client = new HttpClient(server);
|
||||
|
||||
// var request = new HttpRequestMessage
|
||||
// {
|
||||
// RequestUri = new Uri(url),
|
||||
// Method = HttpMethod.Get
|
||||
// };
|
||||
|
||||
// var result = await client.SendAsync(request);
|
||||
// }
|
||||
|
||||
// }
|
||||
|
||||
//}
|
||||
}
|
||||
using System.Collections.Generic;
|
||||
using System.Web.Http;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Web.Editors;
|
||||
|
||||
namespace Umbraco.Tests.Web.Controllers.WebApiEditors
|
||||
{
|
||||
[TestFixture]
|
||||
public class ContentControllerUnitTests
|
||||
{
|
||||
[Test]
|
||||
public void Access_Allowed_By_Path()
|
||||
{
|
||||
//arrange
|
||||
var userMock = new Mock<IUser>();
|
||||
userMock.Setup(u => u.Id).Returns(9);
|
||||
userMock.Setup(u => u.StartContentId).Returns(-1);
|
||||
var user = userMock.Object;
|
||||
var contentMock = new Mock<IContent>();
|
||||
contentMock.Setup(c => c.Path).Returns("-1,1234,5678");
|
||||
var content = contentMock.Object;
|
||||
var contentServiceMock = new Mock<IContentService>();
|
||||
contentServiceMock.Setup(x => x.GetById(1234)).Returns(content);
|
||||
var contentService = contentServiceMock.Object;
|
||||
|
||||
//act
|
||||
var result = ContentController.CheckPermissions(new Dictionary<string, object>(), user, null, contentService, 1234);
|
||||
|
||||
//assert
|
||||
Assert.IsTrue(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Throws_Exception_When_No_Content_Found()
|
||||
{
|
||||
//arrange
|
||||
var userMock = new Mock<IUser>();
|
||||
userMock.Setup(u => u.Id).Returns(9);
|
||||
userMock.Setup(u => u.StartContentId).Returns(-1);
|
||||
var user = userMock.Object;
|
||||
var contentMock = new Mock<IContent>();
|
||||
contentMock.Setup(c => c.Path).Returns("-1,1234,5678");
|
||||
var content = contentMock.Object;
|
||||
var contentServiceMock = new Mock<IContentService>();
|
||||
contentServiceMock.Setup(x => x.GetById(0)).Returns(content);
|
||||
var contentService = contentServiceMock.Object;
|
||||
var userServiceMock = new Mock<IUserService>();
|
||||
var permissions = new List<EntityPermission>();
|
||||
userServiceMock.Setup(x => x.GetPermissions(user, 1234)).Returns(permissions);
|
||||
var userService = userServiceMock.Object;
|
||||
|
||||
//act/assert
|
||||
Assert.Throws<HttpResponseException>(() => ContentController.CheckPermissions(new Dictionary<string, object>(), user, userService, contentService, 1234, new[] { 'F' }));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void No_Access_By_Path()
|
||||
{
|
||||
//arrange
|
||||
var userMock = new Mock<IUser>();
|
||||
userMock.Setup(u => u.Id).Returns(9);
|
||||
userMock.Setup(u => u.StartContentId).Returns(9876);
|
||||
var user = userMock.Object;
|
||||
var contentMock = new Mock<IContent>();
|
||||
contentMock.Setup(c => c.Path).Returns("-1,1234,5678");
|
||||
var content = contentMock.Object;
|
||||
var contentServiceMock = new Mock<IContentService>();
|
||||
contentServiceMock.Setup(x => x.GetById(1234)).Returns(content);
|
||||
var contentService = contentServiceMock.Object;
|
||||
var userServiceMock = new Mock<IUserService>();
|
||||
var permissions = new List<EntityPermission>();
|
||||
userServiceMock.Setup(x => x.GetPermissions(user, 1234)).Returns(permissions);
|
||||
var userService = userServiceMock.Object;
|
||||
|
||||
//act
|
||||
var result = ContentController.CheckPermissions(new Dictionary<string, object>(), user, userService, contentService, 1234, new[] { 'F'});
|
||||
|
||||
//assert
|
||||
Assert.IsFalse(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void No_Access_By_Permission()
|
||||
{
|
||||
//arrange
|
||||
var userMock = new Mock<IUser>();
|
||||
userMock.Setup(u => u.Id).Returns(9);
|
||||
userMock.Setup(u => u.StartContentId).Returns(-1);
|
||||
var user = userMock.Object;
|
||||
var contentMock = new Mock<IContent>();
|
||||
contentMock.Setup(c => c.Path).Returns("-1,1234,5678");
|
||||
var content = contentMock.Object;
|
||||
var contentServiceMock = new Mock<IContentService>();
|
||||
contentServiceMock.Setup(x => x.GetById(1234)).Returns(content);
|
||||
var contentService = contentServiceMock.Object;
|
||||
var userServiceMock = new Mock<IUserService>();
|
||||
var permissions = new List<EntityPermission>
|
||||
{
|
||||
new EntityPermission(9, 1234, new string[]{ "A", "B", "C" })
|
||||
};
|
||||
userServiceMock.Setup(x => x.GetPermissions(user, 1234)).Returns(permissions);
|
||||
var userService = userServiceMock.Object;
|
||||
|
||||
//act
|
||||
var result = ContentController.CheckPermissions(new Dictionary<string, object>(), user, userService, contentService, 1234, new[] { 'F'});
|
||||
|
||||
//assert
|
||||
Assert.IsFalse(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Access_Allowed_By_Permission()
|
||||
{
|
||||
//arrange
|
||||
var userMock = new Mock<IUser>();
|
||||
userMock.Setup(u => u.Id).Returns(9);
|
||||
userMock.Setup(u => u.StartContentId).Returns(-1);
|
||||
var user = userMock.Object;
|
||||
var contentMock = new Mock<IContent>();
|
||||
contentMock.Setup(c => c.Path).Returns("-1,1234,5678");
|
||||
var content = contentMock.Object;
|
||||
var contentServiceMock = new Mock<IContentService>();
|
||||
contentServiceMock.Setup(x => x.GetById(1234)).Returns(content);
|
||||
var contentService = contentServiceMock.Object;
|
||||
var userServiceMock = new Mock<IUserService>();
|
||||
var permissions = new List<EntityPermission>
|
||||
{
|
||||
new EntityPermission(9, 1234, new string[]{ "A", "F", "C" })
|
||||
};
|
||||
userServiceMock.Setup(x => x.GetPermissions(user, 1234)).Returns(permissions);
|
||||
var userService = userServiceMock.Object;
|
||||
|
||||
//act
|
||||
var result = ContentController.CheckPermissions(new Dictionary<string, object>(), user, userService, contentService, 1234, new[] { 'F'});
|
||||
|
||||
//assert
|
||||
Assert.IsTrue(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Access_To_Root_By_Path()
|
||||
{
|
||||
//arrange
|
||||
var userMock = new Mock<IUser>();
|
||||
userMock.Setup(u => u.Id).Returns(0);
|
||||
userMock.Setup(u => u.StartContentId).Returns(-1);
|
||||
var user = userMock.Object;
|
||||
|
||||
//act
|
||||
var result = ContentController.CheckPermissions(new Dictionary<string, object>(), user, null, null, -1);
|
||||
|
||||
//assert
|
||||
Assert.IsTrue(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Access_To_Recycle_Bin_By_Path()
|
||||
{
|
||||
//arrange
|
||||
var userMock = new Mock<IUser>();
|
||||
userMock.Setup(u => u.Id).Returns(0);
|
||||
userMock.Setup(u => u.StartContentId).Returns(-1);
|
||||
var user = userMock.Object;
|
||||
|
||||
//act
|
||||
var result = ContentController.CheckPermissions(new Dictionary<string, object>(), user, null, null, -20);
|
||||
|
||||
//assert
|
||||
Assert.IsTrue(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void No_Access_To_Recycle_Bin_By_Path()
|
||||
{
|
||||
//arrange
|
||||
var userMock = new Mock<IUser>();
|
||||
userMock.Setup(u => u.Id).Returns(0);
|
||||
userMock.Setup(u => u.StartContentId).Returns(1234);
|
||||
var user = userMock.Object;
|
||||
|
||||
//act
|
||||
var result = ContentController.CheckPermissions(new Dictionary<string, object>(), user, null, null, -20);
|
||||
|
||||
//assert
|
||||
Assert.IsFalse(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void No_Access_To_Root_By_Path()
|
||||
{
|
||||
//arrange
|
||||
var userMock = new Mock<IUser>();
|
||||
userMock.Setup(u => u.Id).Returns(0);
|
||||
userMock.Setup(u => u.StartContentId).Returns(1234);
|
||||
var user = userMock.Object;
|
||||
|
||||
//act
|
||||
var result = ContentController.CheckPermissions(new Dictionary<string, object>(), user, null, null, -1);
|
||||
|
||||
//assert
|
||||
Assert.IsFalse(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Access_To_Root_By_Permission()
|
||||
{
|
||||
//arrange
|
||||
var userMock = new Mock<IUser>();
|
||||
userMock.Setup(u => u.Id).Returns(0);
|
||||
userMock.Setup(u => u.StartContentId).Returns(-1);
|
||||
var user = userMock.Object;
|
||||
|
||||
var userServiceMock = new Mock<IUserService>();
|
||||
var permissions = new List<EntityPermission>
|
||||
{
|
||||
new EntityPermission(9, 1234, new string[]{ "A" })
|
||||
};
|
||||
userServiceMock.Setup(x => x.GetPermissions(user, -1)).Returns(permissions);
|
||||
var userService = userServiceMock.Object;
|
||||
|
||||
//act
|
||||
var result = ContentController.CheckPermissions(new Dictionary<string, object>(), user, userService, null, -1, new[] { 'A'});
|
||||
|
||||
//assert
|
||||
Assert.IsTrue(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void No_Access_To_Root_By_Permission()
|
||||
{
|
||||
//arrange
|
||||
var userMock = new Mock<IUser>();
|
||||
userMock.Setup(u => u.Id).Returns(0);
|
||||
userMock.Setup(u => u.StartContentId).Returns(-1);
|
||||
var user = userMock.Object;
|
||||
|
||||
var userServiceMock = new Mock<IUserService>();
|
||||
var permissions = new List<EntityPermission>
|
||||
{
|
||||
new EntityPermission(9, 1234, new string[]{ "A" })
|
||||
};
|
||||
userServiceMock.Setup(x => x.GetPermissions(user, -1)).Returns(permissions);
|
||||
var userService = userServiceMock.Object;
|
||||
|
||||
//act
|
||||
var result = ContentController.CheckPermissions(new Dictionary<string, object>(), user, userService, null, -1, new[] { 'B'});
|
||||
|
||||
//assert
|
||||
Assert.IsFalse(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Access_To_Recycle_Bin_By_Permission()
|
||||
{
|
||||
//arrange
|
||||
var userMock = new Mock<IUser>();
|
||||
userMock.Setup(u => u.Id).Returns(0);
|
||||
userMock.Setup(u => u.StartContentId).Returns(-1);
|
||||
var user = userMock.Object;
|
||||
|
||||
var userServiceMock = new Mock<IUserService>();
|
||||
var permissions = new List<EntityPermission>
|
||||
{
|
||||
new EntityPermission(9, 1234, new string[]{ "A" })
|
||||
};
|
||||
userServiceMock.Setup(x => x.GetPermissions(user, -20)).Returns(permissions);
|
||||
var userService = userServiceMock.Object;
|
||||
|
||||
//act
|
||||
var result = ContentController.CheckPermissions(new Dictionary<string, object>(), user, userService, null, -20, new[] { 'A'});
|
||||
|
||||
//assert
|
||||
Assert.IsTrue(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void No_Access_To_Recycle_Bin_By_Permission()
|
||||
{
|
||||
//arrange
|
||||
var userMock = new Mock<IUser>();
|
||||
userMock.Setup(u => u.Id).Returns(0);
|
||||
userMock.Setup(u => u.StartContentId).Returns(-1);
|
||||
var user = userMock.Object;
|
||||
|
||||
var userServiceMock = new Mock<IUserService>();
|
||||
var permissions = new List<EntityPermission>
|
||||
{
|
||||
new EntityPermission(9, 1234, new string[]{ "A" })
|
||||
};
|
||||
userServiceMock.Setup(x => x.GetPermissions(user, -20)).Returns(permissions);
|
||||
var userService = userServiceMock.Object;
|
||||
|
||||
//act
|
||||
var result = ContentController.CheckPermissions(new Dictionary<string, object>(), user, userService, null, -20, new[] { 'B'});
|
||||
|
||||
//assert
|
||||
Assert.IsFalse(result);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//NOTE: The below self hosted stuff does work so need to get some tests written. Some are not possible atm because
|
||||
// of the legacy SQL calls like checking permissions.
|
||||
|
||||
//[TestFixture]
|
||||
//public class ContentControllerHostedTests : BaseRoutingTest
|
||||
//{
|
||||
|
||||
// protected override DatabaseBehavior DatabaseTestBehavior
|
||||
// {
|
||||
// get { return DatabaseBehavior.NoDatabasePerFixture; }
|
||||
// }
|
||||
|
||||
// public override void TearDown()
|
||||
// {
|
||||
// base.TearDown();
|
||||
// UmbracoAuthorizeAttribute.Enable = true;
|
||||
// UmbracoApplicationAuthorizeAttribute.Enable = true;
|
||||
// }
|
||||
|
||||
// /// <summary>
|
||||
// /// Tests to ensure that the response filter works so that any items the user
|
||||
// /// doesn't have access to are removed
|
||||
// /// </summary>
|
||||
// [Test]
|
||||
// public async void Get_By_Ids_Response_Filtered()
|
||||
// {
|
||||
// UmbracoAuthorizeAttribute.Enable = false;
|
||||
// UmbracoApplicationAuthorizeAttribute.Enable = false;
|
||||
|
||||
// var baseUrl = string.Format("http://{0}:9876", Environment.MachineName);
|
||||
// var url = baseUrl + "/api/Content/GetByIds?ids=1&ids=2";
|
||||
|
||||
// var routingCtx = GetRoutingContext(url, 1234, null, true);
|
||||
|
||||
// var config = new HttpSelfHostConfiguration(baseUrl);
|
||||
// using (var server = new HttpSelfHostServer(config))
|
||||
// {
|
||||
// var route = config.Routes.MapHttpRoute("test", "api/Content/GetByIds",
|
||||
// new
|
||||
// {
|
||||
// controller = "Content",
|
||||
// action = "GetByIds",
|
||||
// id = RouteParameter.Optional
|
||||
// });
|
||||
// route.DataTokens["Namespaces"] = new string[] { "Umbraco.Web.Editors" };
|
||||
|
||||
// var client = new HttpClient(server);
|
||||
|
||||
// var request = new HttpRequestMessage
|
||||
// {
|
||||
// RequestUri = new Uri(url),
|
||||
// Method = HttpMethod.Get
|
||||
// };
|
||||
|
||||
// var result = await client.SendAsync(request);
|
||||
// }
|
||||
|
||||
// }
|
||||
|
||||
//}
|
||||
}
|
||||
+135
-135
@@ -1,136 +1,136 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Formatting;
|
||||
using System.Net.Http.Headers;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Web.Models.ContentEditing;
|
||||
using Umbraco.Web.WebApi.Filters;
|
||||
|
||||
namespace Umbraco.Tests.Controllers.WebApiEditors
|
||||
{
|
||||
[TestFixture]
|
||||
public class FilterAllowedOutgoingContentAttributeTests
|
||||
{
|
||||
[Test]
|
||||
public void GetValueFromResponse_Already_EnumerableContent()
|
||||
{
|
||||
var att = new FilterAllowedOutgoingContentAttribute(typeof(IEnumerable<ContentItemBasic>));
|
||||
var val = new List<ContentItemBasic>() {new ContentItemBasic()};
|
||||
var result = att.GetValueFromResponse(
|
||||
new ObjectContent(typeof (IEnumerable<ContentItemBasic>),
|
||||
val,
|
||||
new JsonMediaTypeFormatter(),
|
||||
new MediaTypeHeaderValue("html/text")));
|
||||
|
||||
Assert.AreEqual(val, result);
|
||||
Assert.AreEqual(1, ((IEnumerable<ContentItemBasic>)result).Count());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetValueFromResponse_From_Property()
|
||||
{
|
||||
var att = new FilterAllowedOutgoingContentAttribute(typeof(IEnumerable<ContentItemBasic>), "MyList");
|
||||
var val = new List<ContentItemBasic>() { new ContentItemBasic() };
|
||||
var container = new MyTestClass() {MyList = val};
|
||||
|
||||
var result = att.GetValueFromResponse(
|
||||
new ObjectContent(typeof(MyTestClass),
|
||||
container,
|
||||
new JsonMediaTypeFormatter(),
|
||||
new MediaTypeHeaderValue("html/text")));
|
||||
|
||||
Assert.AreEqual(val, result);
|
||||
Assert.AreEqual(1, ((IEnumerable<ContentItemBasic>)result).Count());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetValueFromResponse_Returns_Null_Not_Found_Property()
|
||||
{
|
||||
var att = new FilterAllowedOutgoingContentAttribute(typeof(IEnumerable<ContentItemBasic>), "DontFind");
|
||||
var val = new List<ContentItemBasic>() { new ContentItemBasic() };
|
||||
var container = new MyTestClass() { MyList = val };
|
||||
|
||||
var result = att.GetValueFromResponse(
|
||||
new ObjectContent(typeof(MyTestClass),
|
||||
container,
|
||||
new JsonMediaTypeFormatter(),
|
||||
new MediaTypeHeaderValue("html/text")));
|
||||
|
||||
Assert.AreEqual(null, result);
|
||||
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Filter_On_Start_Node()
|
||||
{
|
||||
var att = new FilterAllowedOutgoingContentAttribute(typeof(IEnumerable<ContentItemBasic>));
|
||||
var list = new List<dynamic>();
|
||||
var path = "";
|
||||
for (var i = 0; i < 10; i++)
|
||||
{
|
||||
if (i > 0 && path.EndsWith(",") == false)
|
||||
{
|
||||
path += ",";
|
||||
}
|
||||
path += i.ToInvariantString();
|
||||
list.Add(new ContentItemBasic { Id = i, Name = "Test" + i, ParentId = i, Path = path });
|
||||
}
|
||||
|
||||
var userMock = new Mock<IUser>();
|
||||
userMock.Setup(u => u.Id).Returns(9);
|
||||
userMock.Setup(u => u.StartContentId).Returns(5);
|
||||
var user = userMock.Object;
|
||||
|
||||
att.FilterBasedOnStartNode(list, user);
|
||||
|
||||
Assert.AreEqual(5, list.Count);
|
||||
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Filter_On_Permissions()
|
||||
{
|
||||
var att = new FilterAllowedOutgoingContentAttribute(typeof(IEnumerable<ContentItemBasic>));
|
||||
var list = new List<dynamic>();
|
||||
for (var i = 0; i < 10; i++)
|
||||
{
|
||||
list.Add(new ContentItemBasic{Id = i, Name = "Test" + i, ParentId = -1});
|
||||
}
|
||||
var ids = list.Select(x => (int)x.Id).ToArray();
|
||||
|
||||
var userMock = new Mock<IUser>();
|
||||
userMock.Setup(u => u.Id).Returns(9);
|
||||
userMock.Setup(u => u.StartContentId).Returns(-1);
|
||||
var user = userMock.Object;
|
||||
|
||||
var userServiceMock = new Mock<IUserService>();
|
||||
//we're only assigning 3 nodes browse permissions so that is what we expect as a result
|
||||
var permissions = new List<EntityPermission>
|
||||
{
|
||||
new EntityPermission(9, 1, new string[]{ "F" }),
|
||||
new EntityPermission(9, 2, new string[]{ "F" }),
|
||||
new EntityPermission(9, 3, new string[]{ "F" }),
|
||||
new EntityPermission(9, 4, new string[]{ "A" })
|
||||
};
|
||||
userServiceMock.Setup(x => x.GetPermissions(user, ids)).Returns(permissions);
|
||||
var userService = userServiceMock.Object;
|
||||
|
||||
att.FilterBasedOnPermissions(list, user, userService);
|
||||
|
||||
Assert.AreEqual(3, list.Count);
|
||||
Assert.AreEqual(1, list.ElementAt(0).Id);
|
||||
Assert.AreEqual(2, list.ElementAt(1).Id);
|
||||
Assert.AreEqual(3, list.ElementAt(2).Id);
|
||||
}
|
||||
|
||||
private class MyTestClass
|
||||
{
|
||||
public IEnumerable<ContentItemBasic> MyList { get; set; }
|
||||
}
|
||||
}
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Formatting;
|
||||
using System.Net.Http.Headers;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Web.Models.ContentEditing;
|
||||
using Umbraco.Web.WebApi.Filters;
|
||||
|
||||
namespace Umbraco.Tests.Web.Controllers.WebApiEditors
|
||||
{
|
||||
[TestFixture]
|
||||
public class FilterAllowedOutgoingContentAttributeTests
|
||||
{
|
||||
[Test]
|
||||
public void GetValueFromResponse_Already_EnumerableContent()
|
||||
{
|
||||
var att = new FilterAllowedOutgoingContentAttribute(typeof(IEnumerable<ContentItemBasic>));
|
||||
var val = new List<ContentItemBasic>() {new ContentItemBasic()};
|
||||
var result = att.GetValueFromResponse(
|
||||
new ObjectContent(typeof (IEnumerable<ContentItemBasic>),
|
||||
val,
|
||||
new JsonMediaTypeFormatter(),
|
||||
new MediaTypeHeaderValue("html/text")));
|
||||
|
||||
Assert.AreEqual(val, result);
|
||||
Assert.AreEqual(1, ((IEnumerable<ContentItemBasic>)result).Count());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetValueFromResponse_From_Property()
|
||||
{
|
||||
var att = new FilterAllowedOutgoingContentAttribute(typeof(IEnumerable<ContentItemBasic>), "MyList");
|
||||
var val = new List<ContentItemBasic>() { new ContentItemBasic() };
|
||||
var container = new MyTestClass() {MyList = val};
|
||||
|
||||
var result = att.GetValueFromResponse(
|
||||
new ObjectContent(typeof(MyTestClass),
|
||||
container,
|
||||
new JsonMediaTypeFormatter(),
|
||||
new MediaTypeHeaderValue("html/text")));
|
||||
|
||||
Assert.AreEqual(val, result);
|
||||
Assert.AreEqual(1, ((IEnumerable<ContentItemBasic>)result).Count());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetValueFromResponse_Returns_Null_Not_Found_Property()
|
||||
{
|
||||
var att = new FilterAllowedOutgoingContentAttribute(typeof(IEnumerable<ContentItemBasic>), "DontFind");
|
||||
var val = new List<ContentItemBasic>() { new ContentItemBasic() };
|
||||
var container = new MyTestClass() { MyList = val };
|
||||
|
||||
var result = att.GetValueFromResponse(
|
||||
new ObjectContent(typeof(MyTestClass),
|
||||
container,
|
||||
new JsonMediaTypeFormatter(),
|
||||
new MediaTypeHeaderValue("html/text")));
|
||||
|
||||
Assert.AreEqual(null, result);
|
||||
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Filter_On_Start_Node()
|
||||
{
|
||||
var att = new FilterAllowedOutgoingContentAttribute(typeof(IEnumerable<ContentItemBasic>));
|
||||
var list = new List<dynamic>();
|
||||
var path = "";
|
||||
for (var i = 0; i < 10; i++)
|
||||
{
|
||||
if (i > 0 && path.EndsWith(",") == false)
|
||||
{
|
||||
path += ",";
|
||||
}
|
||||
path += i.ToInvariantString();
|
||||
list.Add(new ContentItemBasic { Id = i, Name = "Test" + i, ParentId = i, Path = path });
|
||||
}
|
||||
|
||||
var userMock = new Mock<IUser>();
|
||||
userMock.Setup(u => u.Id).Returns(9);
|
||||
userMock.Setup(u => u.StartContentId).Returns(5);
|
||||
var user = userMock.Object;
|
||||
|
||||
att.FilterBasedOnStartNode(list, user);
|
||||
|
||||
Assert.AreEqual(5, list.Count);
|
||||
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Filter_On_Permissions()
|
||||
{
|
||||
var att = new FilterAllowedOutgoingContentAttribute(typeof(IEnumerable<ContentItemBasic>));
|
||||
var list = new List<dynamic>();
|
||||
for (var i = 0; i < 10; i++)
|
||||
{
|
||||
list.Add(new ContentItemBasic{Id = i, Name = "Test" + i, ParentId = -1});
|
||||
}
|
||||
var ids = list.Select(x => (int)x.Id).ToArray();
|
||||
|
||||
var userMock = new Mock<IUser>();
|
||||
userMock.Setup(u => u.Id).Returns(9);
|
||||
userMock.Setup(u => u.StartContentId).Returns(-1);
|
||||
var user = userMock.Object;
|
||||
|
||||
var userServiceMock = new Mock<IUserService>();
|
||||
//we're only assigning 3 nodes browse permissions so that is what we expect as a result
|
||||
var permissions = new List<EntityPermission>
|
||||
{
|
||||
new EntityPermission(9, 1, new string[]{ "F" }),
|
||||
new EntityPermission(9, 2, new string[]{ "F" }),
|
||||
new EntityPermission(9, 3, new string[]{ "F" }),
|
||||
new EntityPermission(9, 4, new string[]{ "A" })
|
||||
};
|
||||
userServiceMock.Setup(x => x.GetPermissions(user, ids)).Returns(permissions);
|
||||
var userService = userServiceMock.Object;
|
||||
|
||||
att.FilterBasedOnPermissions(list, user, userService);
|
||||
|
||||
Assert.AreEqual(3, list.Count);
|
||||
Assert.AreEqual(1, list.ElementAt(0).Id);
|
||||
Assert.AreEqual(2, list.ElementAt(1).Id);
|
||||
Assert.AreEqual(3, list.ElementAt(2).Id);
|
||||
}
|
||||
|
||||
private class MyTestClass
|
||||
{
|
||||
public IEnumerable<ContentItemBasic> MyList { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
+141
-141
@@ -1,142 +1,142 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Web.Http;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Web.Editors;
|
||||
|
||||
namespace Umbraco.Tests.Controllers.WebApiEditors
|
||||
{
|
||||
[TestFixture]
|
||||
public class MediaControllerUnitTests
|
||||
{
|
||||
[Test]
|
||||
public void Access_Allowed_By_Path()
|
||||
{
|
||||
//arrange
|
||||
var userMock = new Mock<IUser>();
|
||||
userMock.Setup(u => u.Id).Returns(9);
|
||||
userMock.Setup(u => u.StartMediaId).Returns(-1);
|
||||
var user = userMock.Object;
|
||||
var mediaMock = new Mock<IMedia>();
|
||||
mediaMock.Setup(m => m.Path).Returns("-1,1234,5678");
|
||||
var media = mediaMock.Object;
|
||||
var mediaServiceMock = new Mock<IMediaService>();
|
||||
mediaServiceMock.Setup(x => x.GetById(1234)).Returns(media);
|
||||
var mediaService = mediaServiceMock.Object;
|
||||
|
||||
//act
|
||||
var result = MediaController.CheckPermissions(new Dictionary<string, object>(), user, mediaService, 1234);
|
||||
|
||||
//assert
|
||||
Assert.IsTrue(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Throws_Exception_When_No_Media_Found()
|
||||
{
|
||||
//arrange
|
||||
var userMock = new Mock<IUser>();
|
||||
userMock.Setup(u => u.Id).Returns(9);
|
||||
userMock.Setup(u => u.StartMediaId).Returns(-1);
|
||||
var user = userMock.Object;
|
||||
var mediaMock = new Mock<IMedia>();
|
||||
mediaMock.Setup(m => m.Path).Returns("-1,1234,5678");
|
||||
var media = mediaMock.Object;
|
||||
var mediaServiceMock = new Mock<IMediaService>();
|
||||
mediaServiceMock.Setup(x => x.GetById(0)).Returns(media);
|
||||
var mediaService = mediaServiceMock.Object;
|
||||
|
||||
//act/assert
|
||||
Assert.Throws<HttpResponseException>(() => MediaController.CheckPermissions(new Dictionary<string, object>(), user, mediaService, 1234));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void No_Access_By_Path()
|
||||
{
|
||||
//arrange
|
||||
var userMock = new Mock<IUser>();
|
||||
userMock.Setup(u => u.Id).Returns(9);
|
||||
userMock.Setup(u => u.StartMediaId).Returns(9876);
|
||||
var user = userMock.Object;
|
||||
var mediaMock = new Mock<IMedia>();
|
||||
mediaMock.Setup(m => m.Path).Returns("-1,1234,5678");
|
||||
var media = mediaMock.Object;
|
||||
var mediaServiceMock = new Mock<IMediaService>();
|
||||
mediaServiceMock.Setup(x => x.GetById(1234)).Returns(media);
|
||||
var mediaService = mediaServiceMock.Object;
|
||||
|
||||
//act
|
||||
var result = MediaController.CheckPermissions(new Dictionary<string, object>(), user, mediaService, 1234);
|
||||
|
||||
//assert
|
||||
Assert.IsFalse(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Access_To_Root_By_Path()
|
||||
{
|
||||
//arrange
|
||||
var userMock = new Mock<IUser>();
|
||||
userMock.Setup(u => u.Id).Returns(0);
|
||||
userMock.Setup(u => u.StartMediaId).Returns(-1);
|
||||
var user = userMock.Object;
|
||||
|
||||
//act
|
||||
var result = MediaController.CheckPermissions(new Dictionary<string, object>(), user, null, -1);
|
||||
|
||||
//assert
|
||||
Assert.IsTrue(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void No_Access_To_Root_By_Path()
|
||||
{
|
||||
//arrange
|
||||
var userMock = new Mock<IUser>();
|
||||
userMock.Setup(u => u.Id).Returns(0);
|
||||
userMock.Setup(u => u.StartMediaId).Returns(1234);
|
||||
var user = userMock.Object;
|
||||
|
||||
//act
|
||||
var result = MediaController.CheckPermissions(new Dictionary<string, object>(), user, null, -1);
|
||||
|
||||
//assert
|
||||
Assert.IsFalse(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Access_To_Recycle_Bin_By_Path()
|
||||
{
|
||||
//arrange
|
||||
var userMock = new Mock<IUser>();
|
||||
userMock.Setup(u => u.Id).Returns(0);
|
||||
userMock.Setup(u => u.StartMediaId).Returns(-1);
|
||||
var user = userMock.Object;
|
||||
|
||||
//act
|
||||
var result = MediaController.CheckPermissions(new Dictionary<string, object>(), user, null, -21);
|
||||
|
||||
//assert
|
||||
Assert.IsTrue(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void No_Access_To_Recycle_Bin_By_Path()
|
||||
{
|
||||
//arrange
|
||||
var userMock = new Mock<IUser>();
|
||||
userMock.Setup(u => u.Id).Returns(0);
|
||||
userMock.Setup(u => u.StartMediaId).Returns(1234);
|
||||
var user = userMock.Object;
|
||||
|
||||
//act
|
||||
var result = MediaController.CheckPermissions(new Dictionary<string, object>(), user, null, -21);
|
||||
|
||||
//assert
|
||||
Assert.IsFalse(result);
|
||||
}
|
||||
}
|
||||
using System.Collections.Generic;
|
||||
using System.Web.Http;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.Membership;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Web.Editors;
|
||||
|
||||
namespace Umbraco.Tests.Web.Controllers.WebApiEditors
|
||||
{
|
||||
[TestFixture]
|
||||
public class MediaControllerUnitTests
|
||||
{
|
||||
[Test]
|
||||
public void Access_Allowed_By_Path()
|
||||
{
|
||||
//arrange
|
||||
var userMock = new Mock<IUser>();
|
||||
userMock.Setup(u => u.Id).Returns(9);
|
||||
userMock.Setup(u => u.StartMediaId).Returns(-1);
|
||||
var user = userMock.Object;
|
||||
var mediaMock = new Mock<IMedia>();
|
||||
mediaMock.Setup(m => m.Path).Returns("-1,1234,5678");
|
||||
var media = mediaMock.Object;
|
||||
var mediaServiceMock = new Mock<IMediaService>();
|
||||
mediaServiceMock.Setup(x => x.GetById(1234)).Returns(media);
|
||||
var mediaService = mediaServiceMock.Object;
|
||||
|
||||
//act
|
||||
var result = MediaController.CheckPermissions(new Dictionary<string, object>(), user, mediaService, 1234);
|
||||
|
||||
//assert
|
||||
Assert.IsTrue(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Throws_Exception_When_No_Media_Found()
|
||||
{
|
||||
//arrange
|
||||
var userMock = new Mock<IUser>();
|
||||
userMock.Setup(u => u.Id).Returns(9);
|
||||
userMock.Setup(u => u.StartMediaId).Returns(-1);
|
||||
var user = userMock.Object;
|
||||
var mediaMock = new Mock<IMedia>();
|
||||
mediaMock.Setup(m => m.Path).Returns("-1,1234,5678");
|
||||
var media = mediaMock.Object;
|
||||
var mediaServiceMock = new Mock<IMediaService>();
|
||||
mediaServiceMock.Setup(x => x.GetById(0)).Returns(media);
|
||||
var mediaService = mediaServiceMock.Object;
|
||||
|
||||
//act/assert
|
||||
Assert.Throws<HttpResponseException>(() => MediaController.CheckPermissions(new Dictionary<string, object>(), user, mediaService, 1234));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void No_Access_By_Path()
|
||||
{
|
||||
//arrange
|
||||
var userMock = new Mock<IUser>();
|
||||
userMock.Setup(u => u.Id).Returns(9);
|
||||
userMock.Setup(u => u.StartMediaId).Returns(9876);
|
||||
var user = userMock.Object;
|
||||
var mediaMock = new Mock<IMedia>();
|
||||
mediaMock.Setup(m => m.Path).Returns("-1,1234,5678");
|
||||
var media = mediaMock.Object;
|
||||
var mediaServiceMock = new Mock<IMediaService>();
|
||||
mediaServiceMock.Setup(x => x.GetById(1234)).Returns(media);
|
||||
var mediaService = mediaServiceMock.Object;
|
||||
|
||||
//act
|
||||
var result = MediaController.CheckPermissions(new Dictionary<string, object>(), user, mediaService, 1234);
|
||||
|
||||
//assert
|
||||
Assert.IsFalse(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Access_To_Root_By_Path()
|
||||
{
|
||||
//arrange
|
||||
var userMock = new Mock<IUser>();
|
||||
userMock.Setup(u => u.Id).Returns(0);
|
||||
userMock.Setup(u => u.StartMediaId).Returns(-1);
|
||||
var user = userMock.Object;
|
||||
|
||||
//act
|
||||
var result = MediaController.CheckPermissions(new Dictionary<string, object>(), user, null, -1);
|
||||
|
||||
//assert
|
||||
Assert.IsTrue(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void No_Access_To_Root_By_Path()
|
||||
{
|
||||
//arrange
|
||||
var userMock = new Mock<IUser>();
|
||||
userMock.Setup(u => u.Id).Returns(0);
|
||||
userMock.Setup(u => u.StartMediaId).Returns(1234);
|
||||
var user = userMock.Object;
|
||||
|
||||
//act
|
||||
var result = MediaController.CheckPermissions(new Dictionary<string, object>(), user, null, -1);
|
||||
|
||||
//assert
|
||||
Assert.IsFalse(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Access_To_Recycle_Bin_By_Path()
|
||||
{
|
||||
//arrange
|
||||
var userMock = new Mock<IUser>();
|
||||
userMock.Setup(u => u.Id).Returns(0);
|
||||
userMock.Setup(u => u.StartMediaId).Returns(-1);
|
||||
var user = userMock.Object;
|
||||
|
||||
//act
|
||||
var result = MediaController.CheckPermissions(new Dictionary<string, object>(), user, null, -21);
|
||||
|
||||
//assert
|
||||
Assert.IsTrue(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void No_Access_To_Recycle_Bin_By_Path()
|
||||
{
|
||||
//arrange
|
||||
var userMock = new Mock<IUser>();
|
||||
userMock.Setup(u => u.Id).Returns(0);
|
||||
userMock.Setup(u => u.StartMediaId).Returns(1234);
|
||||
var user = userMock.Object;
|
||||
|
||||
//act
|
||||
var result = MediaController.CheckPermissions(new Dictionary<string, object>(), user, null, -21);
|
||||
|
||||
//assert
|
||||
Assert.IsFalse(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -2,7 +2,7 @@ using System.Web.Mvc;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Web;
|
||||
|
||||
namespace Umbraco.Tests.Mvc
|
||||
namespace Umbraco.Tests.Web.Mvc
|
||||
{
|
||||
[TestFixture]
|
||||
public class HtmlHelperExtensionMethodsTests
|
||||
+85
-85
@@ -1,86 +1,86 @@
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Routing;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
using Umbraco.Web.Mvc;
|
||||
|
||||
namespace Umbraco.Tests.Mvc
|
||||
{
|
||||
[TestFixture]
|
||||
public class MergeParentContextViewDataAttributeTests
|
||||
{
|
||||
[Test]
|
||||
public void Ensure_All_Ancestor_ViewData_Is_Merged()
|
||||
{
|
||||
var http = new FakeHttpContextFactory("http://localhost");
|
||||
|
||||
//setup an heirarchy
|
||||
var rootViewCtx = new ViewContext {Controller = new MyController(), RequestContext = http.RequestContext, ViewData = new ViewDataDictionary()};
|
||||
var parentViewCtx = new ViewContext { Controller = new MyController(), RequestContext = http.RequestContext, RouteData = new RouteData(), ViewData = new ViewDataDictionary() };
|
||||
parentViewCtx.RouteData.DataTokens.Add("ParentActionViewContext", rootViewCtx);
|
||||
var controllerCtx = new ControllerContext(http.RequestContext, new MyController()) {RouteData = new RouteData()};
|
||||
controllerCtx.RouteData.DataTokens.Add("ParentActionViewContext", parentViewCtx);
|
||||
|
||||
//set up the view data
|
||||
controllerCtx.Controller.ViewData["Test1"] = "Test1";
|
||||
controllerCtx.Controller.ViewData["Test2"] = "Test2";
|
||||
controllerCtx.Controller.ViewData["Test3"] = "Test3";
|
||||
parentViewCtx.ViewData["Test4"] = "Test4";
|
||||
parentViewCtx.ViewData["Test5"] = "Test5";
|
||||
parentViewCtx.ViewData["Test6"] = "Test6";
|
||||
rootViewCtx.ViewData["Test7"] = "Test7";
|
||||
rootViewCtx.ViewData["Test8"] = "Test8";
|
||||
rootViewCtx.ViewData["Test9"] = "Test9";
|
||||
|
||||
var filter = new ResultExecutingContext(controllerCtx, new ContentResult()) {RouteData = controllerCtx.RouteData};
|
||||
var att = new MergeParentContextViewDataAttribute();
|
||||
|
||||
Assert.IsTrue(filter.IsChildAction);
|
||||
att.OnResultExecuting(filter);
|
||||
|
||||
Assert.AreEqual(9, controllerCtx.Controller.ViewData.Count);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Ensure_All_Ancestor_ViewData_Is_Merged_Without_Data_Loss()
|
||||
{
|
||||
var http = new FakeHttpContextFactory("http://localhost");
|
||||
|
||||
//setup an heirarchy
|
||||
var rootViewCtx = new ViewContext { Controller = new MyController(), RequestContext = http.RequestContext, ViewData = new ViewDataDictionary() };
|
||||
var parentViewCtx = new ViewContext { Controller = new MyController(), RequestContext = http.RequestContext, RouteData = new RouteData(), ViewData = new ViewDataDictionary() };
|
||||
parentViewCtx.RouteData.DataTokens.Add("ParentActionViewContext", rootViewCtx);
|
||||
var controllerCtx = new ControllerContext(http.RequestContext, new MyController()) { RouteData = new RouteData() };
|
||||
controllerCtx.RouteData.DataTokens.Add("ParentActionViewContext", parentViewCtx);
|
||||
|
||||
//set up the view data with overlapping keys
|
||||
controllerCtx.Controller.ViewData["Test1"] = "Test1";
|
||||
controllerCtx.Controller.ViewData["Test2"] = "Test2";
|
||||
controllerCtx.Controller.ViewData["Test3"] = "Test3";
|
||||
parentViewCtx.ViewData["Test2"] = "Test4";
|
||||
parentViewCtx.ViewData["Test3"] = "Test5";
|
||||
parentViewCtx.ViewData["Test4"] = "Test6";
|
||||
rootViewCtx.ViewData["Test3"] = "Test7";
|
||||
rootViewCtx.ViewData["Test4"] = "Test8";
|
||||
rootViewCtx.ViewData["Test5"] = "Test9";
|
||||
|
||||
var filter = new ResultExecutingContext(controllerCtx, new ContentResult()) { RouteData = controllerCtx.RouteData };
|
||||
var att = new MergeParentContextViewDataAttribute();
|
||||
|
||||
Assert.IsTrue(filter.IsChildAction);
|
||||
att.OnResultExecuting(filter);
|
||||
|
||||
Assert.AreEqual(5, controllerCtx.Controller.ViewData.Count);
|
||||
Assert.AreEqual("Test1", controllerCtx.Controller.ViewData["Test1"]);
|
||||
Assert.AreEqual("Test2", controllerCtx.Controller.ViewData["Test2"]);
|
||||
Assert.AreEqual("Test3", controllerCtx.Controller.ViewData["Test3"]);
|
||||
Assert.AreEqual("Test6", controllerCtx.Controller.ViewData["Test4"]);
|
||||
Assert.AreEqual("Test9", controllerCtx.Controller.ViewData["Test5"]);
|
||||
}
|
||||
|
||||
internal class MyController : Controller
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Routing;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
using Umbraco.Web.Mvc;
|
||||
|
||||
namespace Umbraco.Tests.Web.Mvc
|
||||
{
|
||||
[TestFixture]
|
||||
public class MergeParentContextViewDataAttributeTests
|
||||
{
|
||||
[Test]
|
||||
public void Ensure_All_Ancestor_ViewData_Is_Merged()
|
||||
{
|
||||
var http = new FakeHttpContextFactory("http://localhost");
|
||||
|
||||
//setup an heirarchy
|
||||
var rootViewCtx = new ViewContext {Controller = new MyController(), RequestContext = http.RequestContext, ViewData = new ViewDataDictionary()};
|
||||
var parentViewCtx = new ViewContext { Controller = new MyController(), RequestContext = http.RequestContext, RouteData = new RouteData(), ViewData = new ViewDataDictionary() };
|
||||
parentViewCtx.RouteData.DataTokens.Add("ParentActionViewContext", rootViewCtx);
|
||||
var controllerCtx = new ControllerContext(http.RequestContext, new MyController()) {RouteData = new RouteData()};
|
||||
controllerCtx.RouteData.DataTokens.Add("ParentActionViewContext", parentViewCtx);
|
||||
|
||||
//set up the view data
|
||||
controllerCtx.Controller.ViewData["Test1"] = "Test1";
|
||||
controllerCtx.Controller.ViewData["Test2"] = "Test2";
|
||||
controllerCtx.Controller.ViewData["Test3"] = "Test3";
|
||||
parentViewCtx.ViewData["Test4"] = "Test4";
|
||||
parentViewCtx.ViewData["Test5"] = "Test5";
|
||||
parentViewCtx.ViewData["Test6"] = "Test6";
|
||||
rootViewCtx.ViewData["Test7"] = "Test7";
|
||||
rootViewCtx.ViewData["Test8"] = "Test8";
|
||||
rootViewCtx.ViewData["Test9"] = "Test9";
|
||||
|
||||
var filter = new ResultExecutingContext(controllerCtx, new ContentResult()) {RouteData = controllerCtx.RouteData};
|
||||
var att = new MergeParentContextViewDataAttribute();
|
||||
|
||||
Assert.IsTrue(filter.IsChildAction);
|
||||
att.OnResultExecuting(filter);
|
||||
|
||||
Assert.AreEqual(9, controllerCtx.Controller.ViewData.Count);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Ensure_All_Ancestor_ViewData_Is_Merged_Without_Data_Loss()
|
||||
{
|
||||
var http = new FakeHttpContextFactory("http://localhost");
|
||||
|
||||
//setup an heirarchy
|
||||
var rootViewCtx = new ViewContext { Controller = new MyController(), RequestContext = http.RequestContext, ViewData = new ViewDataDictionary() };
|
||||
var parentViewCtx = new ViewContext { Controller = new MyController(), RequestContext = http.RequestContext, RouteData = new RouteData(), ViewData = new ViewDataDictionary() };
|
||||
parentViewCtx.RouteData.DataTokens.Add("ParentActionViewContext", rootViewCtx);
|
||||
var controllerCtx = new ControllerContext(http.RequestContext, new MyController()) { RouteData = new RouteData() };
|
||||
controllerCtx.RouteData.DataTokens.Add("ParentActionViewContext", parentViewCtx);
|
||||
|
||||
//set up the view data with overlapping keys
|
||||
controllerCtx.Controller.ViewData["Test1"] = "Test1";
|
||||
controllerCtx.Controller.ViewData["Test2"] = "Test2";
|
||||
controllerCtx.Controller.ViewData["Test3"] = "Test3";
|
||||
parentViewCtx.ViewData["Test2"] = "Test4";
|
||||
parentViewCtx.ViewData["Test3"] = "Test5";
|
||||
parentViewCtx.ViewData["Test4"] = "Test6";
|
||||
rootViewCtx.ViewData["Test3"] = "Test7";
|
||||
rootViewCtx.ViewData["Test4"] = "Test8";
|
||||
rootViewCtx.ViewData["Test5"] = "Test9";
|
||||
|
||||
var filter = new ResultExecutingContext(controllerCtx, new ContentResult()) { RouteData = controllerCtx.RouteData };
|
||||
var att = new MergeParentContextViewDataAttribute();
|
||||
|
||||
Assert.IsTrue(filter.IsChildAction);
|
||||
att.OnResultExecuting(filter);
|
||||
|
||||
Assert.AreEqual(5, controllerCtx.Controller.ViewData.Count);
|
||||
Assert.AreEqual("Test1", controllerCtx.Controller.ViewData["Test1"]);
|
||||
Assert.AreEqual("Test2", controllerCtx.Controller.ViewData["Test2"]);
|
||||
Assert.AreEqual("Test3", controllerCtx.Controller.ViewData["Test3"]);
|
||||
Assert.AreEqual("Test6", controllerCtx.Controller.ViewData["Test4"]);
|
||||
Assert.AreEqual("Test9", controllerCtx.Controller.ViewData["Test5"]);
|
||||
}
|
||||
|
||||
internal class MyController : Controller
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -17,7 +17,7 @@ using Umbraco.Web.Mvc;
|
||||
using Umbraco.Web.Routing;
|
||||
using Umbraco.Web.Security;
|
||||
|
||||
namespace Umbraco.Tests.Mvc
|
||||
namespace Umbraco.Tests.Web.Mvc
|
||||
{
|
||||
[TestFixture]
|
||||
public class RenderIndexActionSelectorAttributeTests
|
||||
@@ -0,0 +1,171 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Routing;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.PublishedContent;
|
||||
using Umbraco.Web.Models;
|
||||
using Umbraco.Web.Mvc;
|
||||
|
||||
namespace Umbraco.Tests.Web.Mvc
|
||||
{
|
||||
[TestFixture]
|
||||
public class RenderModelBinderTests
|
||||
{
|
||||
[Test]
|
||||
public void Returns_Binder_For_IPublishedContent_And_IRenderModel()
|
||||
{
|
||||
var binder = new RenderModelBinder();
|
||||
var found = binder.GetBinder(typeof (IPublishedContent));
|
||||
Assert.IsNotNull(found);
|
||||
found = binder.GetBinder(typeof(RenderModel));
|
||||
Assert.IsNotNull(found);
|
||||
found = binder.GetBinder(typeof(DynamicPublishedContent));
|
||||
Assert.IsNotNull(found);
|
||||
found = binder.GetBinder(typeof(MyContent));
|
||||
Assert.IsNotNull(found);
|
||||
found = binder.GetBinder(typeof(RenderModel<MyContent>));
|
||||
Assert.IsNotNull(found);
|
||||
|
||||
found = binder.GetBinder(typeof(MyOtherContent));
|
||||
Assert.IsNull(found);
|
||||
found = binder.GetBinder(typeof(MyCustomRenderModel));
|
||||
Assert.IsNull(found);
|
||||
found = binder.GetBinder(typeof(IRenderModel));
|
||||
Assert.IsNull(found);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BindModel_Null_Source_Returns_Null()
|
||||
{
|
||||
Assert.IsNull(RenderModelBinder.BindModel(null, typeof(MyContent), CultureInfo.CurrentCulture));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BindModel_Returns_If_Same_Type()
|
||||
{
|
||||
var content = new MyContent(Mock.Of<IPublishedContent>());
|
||||
var bound = RenderModelBinder.BindModel(content, typeof (IPublishedContent), CultureInfo.CurrentCulture);
|
||||
Assert.AreSame(content, bound);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BindModel_RenderModel_To_IPublishedContent()
|
||||
{
|
||||
var content = new MyContent(Mock.Of<IPublishedContent>());
|
||||
var renderModel = new RenderModel(content, CultureInfo.CurrentCulture);
|
||||
var bound = RenderModelBinder.BindModel(renderModel, typeof(IPublishedContent), CultureInfo.CurrentCulture);
|
||||
Assert.AreSame(content, bound);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BindModel_IPublishedContent_To_RenderModel()
|
||||
{
|
||||
var content = new MyContent(Mock.Of<IPublishedContent>());
|
||||
var bound = (IRenderModel)RenderModelBinder.BindModel(content, typeof(RenderModel), CultureInfo.CurrentCulture);
|
||||
Assert.AreSame(content, bound.Content);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BindModel_IPublishedContent_To_Generic_RenderModel()
|
||||
{
|
||||
var content = new MyContent(Mock.Of<IPublishedContent>());
|
||||
var bound = (IRenderModel)RenderModelBinder.BindModel(content, typeof(RenderModel<MyContent>), CultureInfo.CurrentCulture);
|
||||
Assert.AreSame(content, bound.Content);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void No_DataToken_Returns_Null()
|
||||
{
|
||||
var binder = new RenderModelBinder();
|
||||
var routeData = new RouteData();
|
||||
var result = binder.BindModel(new ControllerContext(Mock.Of<HttpContextBase>(), routeData, Mock.Of<ControllerBase>()),
|
||||
new ModelBindingContext());
|
||||
|
||||
Assert.IsNull(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Invalid_DataToken_Model_Type_Returns_Null()
|
||||
{
|
||||
var binder = new RenderModelBinder();
|
||||
var routeData = new RouteData();
|
||||
routeData.DataTokens[Core.Constants.Web.UmbracoDataToken] = "hello";
|
||||
|
||||
//the value provider is the default implementation
|
||||
var valueProvider = new Mock<IValueProvider>();
|
||||
//also IUnvalidatedValueProvider
|
||||
var invalidatedValueProvider = valueProvider.As<IUnvalidatedValueProvider>();
|
||||
invalidatedValueProvider.Setup(x => x.GetValue(It.IsAny<string>(), It.IsAny<bool>())).Returns(() =>
|
||||
new ValueProviderResult(null, "", CultureInfo.CurrentCulture));
|
||||
|
||||
var controllerCtx = new ControllerContext(
|
||||
Mock.Of<HttpContextBase>(http => http.Items == new Dictionary<object, object>()),
|
||||
routeData,
|
||||
Mock.Of<ControllerBase>());
|
||||
|
||||
var result = binder.BindModel(controllerCtx,
|
||||
new ModelBindingContext
|
||||
{
|
||||
ValueProvider = valueProvider.Object,
|
||||
ModelMetadata = new ModelMetadata(new EmptyModelMetadataProvider(), null, () => null, typeof(IPublishedContent), "content")
|
||||
});
|
||||
|
||||
Assert.IsNull(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IPublishedContent_DataToken_Model_Type_Uses_DefaultImplementation()
|
||||
{
|
||||
var content = new MyContent(Mock.Of<IPublishedContent>());
|
||||
var binder = new RenderModelBinder();
|
||||
var routeData = new RouteData();
|
||||
routeData.DataTokens[Core.Constants.Web.UmbracoDataToken] = content;
|
||||
|
||||
//the value provider is the default implementation
|
||||
var valueProvider = new Mock<IValueProvider>();
|
||||
//also IUnvalidatedValueProvider
|
||||
var invalidatedValueProvider = valueProvider.As<IUnvalidatedValueProvider>();
|
||||
invalidatedValueProvider.Setup(x => x.GetValue(It.IsAny<string>(), It.IsAny<bool>())).Returns(() =>
|
||||
new ValueProviderResult(content, "content", CultureInfo.CurrentCulture));
|
||||
|
||||
var controllerCtx = new ControllerContext(
|
||||
Mock.Of<HttpContextBase>(http => http.Items == new Dictionary<object, object>()),
|
||||
routeData,
|
||||
Mock.Of<ControllerBase>());
|
||||
var result = binder.BindModel(controllerCtx,
|
||||
new ModelBindingContext
|
||||
{
|
||||
ValueProvider = valueProvider.Object,
|
||||
ModelMetadata = new ModelMetadata(new EmptyModelMetadataProvider(), null, () => null, typeof(IPublishedContent), "content")
|
||||
});
|
||||
|
||||
Assert.AreEqual(content, result);
|
||||
}
|
||||
|
||||
public class MyCustomRenderModel : RenderModel
|
||||
{
|
||||
public MyCustomRenderModel(IPublishedContent content, CultureInfo culture) : base(content, culture)
|
||||
{
|
||||
}
|
||||
public MyCustomRenderModel(IPublishedContent content) : base(content)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public class MyOtherContent
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public class MyContent : PublishedContentWrapped
|
||||
{
|
||||
public MyContent(IPublishedContent content) : base(content)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-5
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.CodeDom;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
@@ -12,7 +11,6 @@ using Umbraco.Core.Configuration.UmbracoSettings;
|
||||
using Umbraco.Core.Dictionary;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.ObjectResolution;
|
||||
using Umbraco.Core.Persistence;
|
||||
using Umbraco.Core.Persistence.SqlSyntax;
|
||||
using Umbraco.Core.Profiling;
|
||||
@@ -20,11 +18,10 @@ using Umbraco.Core.Services;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
using Umbraco.Web;
|
||||
using Umbraco.Web.Mvc;
|
||||
using Umbraco.Web.PublishedCache;
|
||||
using Umbraco.Web.Routing;
|
||||
using Umbraco.Web.Security;
|
||||
|
||||
namespace Umbraco.Tests.Mvc
|
||||
namespace Umbraco.Tests.Web.Mvc
|
||||
{
|
||||
[TestFixture]
|
||||
public class SurfaceControllerTests
|
||||
@@ -165,7 +162,7 @@ namespace Umbraco.Tests.Mvc
|
||||
};
|
||||
|
||||
var routeData = new RouteData();
|
||||
routeData.DataTokens.Add("umbraco-route-def", routeDefinition);
|
||||
routeData.DataTokens.Add(Umbraco.Core.Constants.Web.UmbracoRouteDefinitionDataToken, routeDefinition);
|
||||
|
||||
var ctrl = new TestSurfaceController(umbCtx, new UmbracoHelper());
|
||||
ctrl.ControllerContext = new ControllerContext(contextBase, routeData, ctrl);
|
||||
+8
-12
@@ -1,27 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Routing;
|
||||
using System.Xml;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using umbraco.BusinessLogic;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Configuration.UmbracoSettings;
|
||||
using Umbraco.Core.Events;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.PublishedContent;
|
||||
using Umbraco.Core.Persistence;
|
||||
using Umbraco.Core.Persistence.SqlSyntax;
|
||||
using Umbraco.Core.Persistence.UnitOfWork;
|
||||
using Umbraco.Core.Profiling;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Web.Security;
|
||||
using umbraco.BusinessLogic;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Events;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.PublishedContent;
|
||||
using Umbraco.Tests.PublishedContent;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
using Umbraco.Tests.TestHelpers.Stubs;
|
||||
using Umbraco.Web;
|
||||
@@ -30,8 +25,9 @@ using Umbraco.Web.Mvc;
|
||||
using Umbraco.Web.PublishedCache;
|
||||
using Umbraco.Web.PublishedCache.XmlPublishedCache;
|
||||
using Umbraco.Web.Routing;
|
||||
using Umbraco.Web.Security;
|
||||
|
||||
namespace Umbraco.Tests.Mvc
|
||||
namespace Umbraco.Tests.Web.Mvc
|
||||
{
|
||||
[TestFixture]
|
||||
public class UmbracoViewPageTests
|
||||
@@ -445,7 +441,7 @@ namespace Umbraco.Tests.Mvc
|
||||
|
||||
var context = new ViewContext();
|
||||
context.RouteData = new RouteData();
|
||||
context.RouteData.DataTokens.Add("umbraco-context", umbracoContext);
|
||||
context.RouteData.DataTokens.Add(Umbraco.Core.Constants.Web.UmbracoContextDataToken, umbracoContext);
|
||||
|
||||
return context;
|
||||
}
|
||||
+40
-42
@@ -1,42 +1,40 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Web.Mvc;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Web.Mvc;
|
||||
|
||||
namespace Umbraco.Tests.Mvc
|
||||
{
|
||||
[TestFixture]
|
||||
public class ViewDataDictionaryExtensionTests
|
||||
{
|
||||
[Test]
|
||||
public void Merge_View_Data()
|
||||
{
|
||||
var source = new ViewDataDictionary();
|
||||
var dest = new ViewDataDictionary();
|
||||
source.Add("Test1", "Test1");
|
||||
dest.Add("Test2", "Test2");
|
||||
|
||||
dest.MergeViewDataFrom(source);
|
||||
|
||||
Assert.AreEqual(2, dest.Count);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Merge_View_Data_Retains_Destination_Values()
|
||||
{
|
||||
var source = new ViewDataDictionary();
|
||||
var dest = new ViewDataDictionary();
|
||||
source.Add("Test1", "Test1");
|
||||
dest.Add("Test1", "MyValue");
|
||||
dest.Add("Test2", "Test2");
|
||||
|
||||
dest.MergeViewDataFrom(source);
|
||||
|
||||
Assert.AreEqual(2, dest.Count);
|
||||
Assert.AreEqual("MyValue", dest["Test1"]);
|
||||
Assert.AreEqual("Test2", dest["Test2"]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
using System.Web.Mvc;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Web.Mvc;
|
||||
|
||||
namespace Umbraco.Tests.Web.Mvc
|
||||
{
|
||||
[TestFixture]
|
||||
public class ViewDataDictionaryExtensionTests
|
||||
{
|
||||
[Test]
|
||||
public void Merge_View_Data()
|
||||
{
|
||||
var source = new ViewDataDictionary();
|
||||
var dest = new ViewDataDictionary();
|
||||
source.Add("Test1", "Test1");
|
||||
dest.Add("Test2", "Test2");
|
||||
|
||||
dest.MergeViewDataFrom(source);
|
||||
|
||||
Assert.AreEqual(2, dest.Count);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Merge_View_Data_Retains_Destination_Values()
|
||||
{
|
||||
var source = new ViewDataDictionary();
|
||||
var dest = new ViewDataDictionary();
|
||||
source.Add("Test1", "Test1");
|
||||
dest.Add("Test1", "MyValue");
|
||||
dest.Add("Test2", "Test2");
|
||||
|
||||
dest.MergeViewDataFrom(source);
|
||||
|
||||
Assert.AreEqual(2, dest.Count);
|
||||
Assert.AreEqual("MyValue", dest["Test1"]);
|
||||
Assert.AreEqual("Test2", dest["Test2"]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,170 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Routing;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Configuration.UmbracoSettings;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Profiling;
|
||||
using Umbraco.Web;
|
||||
using Umbraco.Web.Mvc;
|
||||
using Umbraco.Web.Routing;
|
||||
using Umbraco.Web.Security;
|
||||
|
||||
namespace Umbraco.Tests.Web
|
||||
{
|
||||
[TestFixture]
|
||||
public class WebExtensionMethodTests
|
||||
{
|
||||
|
||||
[Test]
|
||||
public void UmbracoContextExtensions_GetUmbracoContext()
|
||||
{
|
||||
var appCtx = new ApplicationContext(
|
||||
CacheHelper.CreateDisabledCacheHelper(),
|
||||
new ProfilingLogger(Mock.Of<ILogger>(), Mock.Of<IProfiler>()));
|
||||
var umbCtx = UmbracoContext.CreateContext(
|
||||
Mock.Of<HttpContextBase>(),
|
||||
appCtx,
|
||||
new WebSecurity(Mock.Of<HttpContextBase>(), appCtx),
|
||||
Mock.Of<IUmbracoSettingsSection>(),
|
||||
new List<IUrlProvider>(),
|
||||
false);
|
||||
var items = new Dictionary<object, object>()
|
||||
{
|
||||
{UmbracoContext.HttpContextItemName, umbCtx}
|
||||
};
|
||||
var http = new Mock<HttpContextBase>();
|
||||
http.Setup(x => x.Items).Returns(items);
|
||||
|
||||
var result = http.Object.GetUmbracoContext();
|
||||
|
||||
Assert.IsNotNull(result);
|
||||
Assert.AreSame(umbCtx, result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RouteDataExtensions_GetUmbracoContext()
|
||||
{
|
||||
var appCtx = new ApplicationContext(
|
||||
CacheHelper.CreateDisabledCacheHelper(),
|
||||
new ProfilingLogger(Mock.Of<ILogger>(), Mock.Of<IProfiler>()));
|
||||
var umbCtx = UmbracoContext.CreateContext(
|
||||
Mock.Of<HttpContextBase>(),
|
||||
appCtx,
|
||||
new WebSecurity(Mock.Of<HttpContextBase>(), appCtx),
|
||||
Mock.Of<IUmbracoSettingsSection>(),
|
||||
new List<IUrlProvider>(),
|
||||
false);
|
||||
var r1 = new RouteData();
|
||||
r1.DataTokens.Add(Core.Constants.Web.UmbracoContextDataToken, umbCtx);
|
||||
|
||||
var result = r1.GetUmbracoContext();
|
||||
|
||||
Assert.IsNotNull(result);
|
||||
Assert.AreSame(umbCtx, result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ControllerContextExtensions_GetUmbracoContext_From_RouteValues()
|
||||
{
|
||||
var appCtx = new ApplicationContext(
|
||||
CacheHelper.CreateDisabledCacheHelper(),
|
||||
new ProfilingLogger(Mock.Of<ILogger>(), Mock.Of<IProfiler>()));
|
||||
var umbCtx = UmbracoContext.CreateContext(
|
||||
Mock.Of<HttpContextBase>(),
|
||||
appCtx,
|
||||
new WebSecurity(Mock.Of<HttpContextBase>(), appCtx),
|
||||
Mock.Of<IUmbracoSettingsSection>(),
|
||||
new List<IUrlProvider>(),
|
||||
false);
|
||||
|
||||
var r1 = new RouteData();
|
||||
r1.DataTokens.Add(Core.Constants.Web.UmbracoContextDataToken, umbCtx);
|
||||
var ctx1 = CreateViewContext(new ControllerContext(Mock.Of<HttpContextBase>(), r1, new MyController()));
|
||||
var r2 = new RouteData();
|
||||
r2.DataTokens.Add("ParentActionViewContext", ctx1);
|
||||
var ctx2 = CreateViewContext(new ControllerContext(Mock.Of<HttpContextBase>(), r2, new MyController()));
|
||||
var r3 = new RouteData();
|
||||
r3.DataTokens.Add("ParentActionViewContext", ctx2);
|
||||
var ctx3 = CreateViewContext(new ControllerContext(Mock.Of<HttpContextBase>(), r3, new MyController()));
|
||||
|
||||
var result = ctx3.GetUmbracoContext();
|
||||
|
||||
Assert.IsNotNull(result);
|
||||
Assert.AreSame(umbCtx, result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ControllerContextExtensions_GetUmbracoContext_From_HttpContext()
|
||||
{
|
||||
var appCtx = new ApplicationContext(
|
||||
CacheHelper.CreateDisabledCacheHelper(),
|
||||
new ProfilingLogger(Mock.Of<ILogger>(), Mock.Of<IProfiler>()));
|
||||
var umbCtx = UmbracoContext.CreateContext(
|
||||
Mock.Of<HttpContextBase>(),
|
||||
appCtx,
|
||||
new WebSecurity(Mock.Of<HttpContextBase>(), appCtx),
|
||||
Mock.Of<IUmbracoSettingsSection>(),
|
||||
new List<IUrlProvider>(),
|
||||
false);
|
||||
var items = new Dictionary<object, object>()
|
||||
{
|
||||
{UmbracoContext.HttpContextItemName, umbCtx}
|
||||
};
|
||||
var http = new Mock<HttpContextBase>();
|
||||
http.Setup(x => x.Items).Returns(items);
|
||||
|
||||
var r1 = new RouteData();
|
||||
var ctx1 = CreateViewContext(new ControllerContext(http.Object, r1, new MyController()));
|
||||
var r2 = new RouteData();
|
||||
r2.DataTokens.Add("ParentActionViewContext", ctx1);
|
||||
var ctx2 = CreateViewContext(new ControllerContext(http.Object, r2, new MyController()));
|
||||
var r3 = new RouteData();
|
||||
r3.DataTokens.Add("ParentActionViewContext", ctx2);
|
||||
var ctx3 = CreateViewContext(new ControllerContext(http.Object, r3, new MyController()));
|
||||
|
||||
var result = ctx3.GetUmbracoContext();
|
||||
|
||||
Assert.IsNotNull(result);
|
||||
Assert.AreSame(umbCtx, result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ControllerContextExtensions_GetDataTokenInViewContextHierarchy()
|
||||
{
|
||||
var r1 = new RouteData();
|
||||
r1.DataTokens.Add("hello", "world");
|
||||
var ctx1 = CreateViewContext(new ControllerContext(Mock.Of<HttpContextBase>(), r1, new MyController()));
|
||||
var r2 = new RouteData();
|
||||
r2.DataTokens.Add("ParentActionViewContext", ctx1);
|
||||
var ctx2 = CreateViewContext(new ControllerContext(Mock.Of<HttpContextBase>(), r2, new MyController()));
|
||||
var r3 = new RouteData();
|
||||
r3.DataTokens.Add("ParentActionViewContext", ctx2);
|
||||
var ctx3 = CreateViewContext(new ControllerContext(Mock.Of<HttpContextBase>(), r3, new MyController()));
|
||||
|
||||
var result = ctx3.GetDataTokenInViewContextHierarchy("hello");
|
||||
|
||||
Assert.IsNotNull(result as string);
|
||||
Assert.AreEqual((string)result, "world");
|
||||
}
|
||||
|
||||
private ViewContext CreateViewContext(ControllerContext ctx)
|
||||
{
|
||||
return new ViewContext(ctx, Mock.Of<IView>(),
|
||||
new ViewDataDictionary(), new TempDataDictionary(), new StringWriter());
|
||||
}
|
||||
|
||||
private class MyController : Controller
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,13 +13,15 @@
|
||||
<package id="Microsoft.AspNet.WebApi.SelfHost" version="4.0.30506.0" targetFramework="net45" />
|
||||
<package id="Microsoft.AspNet.WebApi.WebHost" version="5.2.3" targetFramework="net45" />
|
||||
<package id="Microsoft.AspNet.WebPages" version="3.2.3" targetFramework="net45" />
|
||||
<package id="Microsoft.Owin" version="3.0.1" targetFramework="net45" />
|
||||
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net45" />
|
||||
<package id="MiniProfiler" version="2.1.0" targetFramework="net45" />
|
||||
<package id="Moq" version="4.1.1309.0919" targetFramework="net45" />
|
||||
<package id="Newtonsoft.Json" version="6.0.8" targetFramework="net45" />
|
||||
<package id="NUnit" version="2.6.2" targetFramework="net45" />
|
||||
<package id="Owin" version="1.0" targetFramework="net45" />
|
||||
<package id="Selenium.WebDriver" version="2.32.0" targetFramework="net45" />
|
||||
<package id="semver" version="1.1.2" targetFramework="net45" />
|
||||
<package id="SharpZipLib" version="0.86.0" targetFramework="net45" />
|
||||
<package id="SqlServerCE" version="4.0.0.0" targetFramework="net45" />
|
||||
<package id="SqlServerCE" version="4.0.0.1" targetFramework="net45" />
|
||||
</packages>
|
||||
@@ -210,7 +210,7 @@ function submit()
|
||||
if (findDepth(curLineHTML, cc) !== 0) {
|
||||
// Cursor is inside a <tag>, don't set cursor:
|
||||
curLineHTML = curLineHTML.replace(cc, '');
|
||||
doc.setLine(pos.line, curLineHTML);
|
||||
doc.getLineHandle(pos.line).text = curLineHTML;
|
||||
}
|
||||
|
||||
// Submit HTML to TinyMCE:
|
||||
|
||||
@@ -361,6 +361,12 @@ Umbraco.Sys.registerNamespace("Umbraco.Application");
|
||||
rootScope : function(){
|
||||
return getRootScope();
|
||||
},
|
||||
|
||||
reloadLocation: function() {
|
||||
var injector = getRootInjector();
|
||||
var $route = injector.get("$route");
|
||||
$route.reload();
|
||||
},
|
||||
|
||||
closeModalWindow: function(rVal) {
|
||||
|
||||
|
||||
@@ -22,15 +22,35 @@ var packages = angular.module("umbraco.packages", []);
|
||||
//module is initilized.
|
||||
angular.module("umbraco.views", ["umbraco.viewcache"]);
|
||||
angular.module("umbraco.viewcache", [])
|
||||
.run(function($rootScope, $templateCache){
|
||||
/** For debug mode, always clear template cache to cut down on
|
||||
.run(function($rootScope, $templateCache) {
|
||||
/** For debug mode, always clear template cache to cut down on
|
||||
dev frustration and chrome cache on templates */
|
||||
if(Umbraco.Sys.ServerVariables.isDebuggingEnabled){
|
||||
//$rootScope.$on('$viewContentLoaded', function() {
|
||||
$templateCache.removeAll();
|
||||
//});
|
||||
if (Umbraco.Sys.ServerVariables.isDebuggingEnabled) {
|
||||
$templateCache.removeAll();
|
||||
}
|
||||
})
|
||||
})
|
||||
.config([
|
||||
//This ensures that all of our angular views are cache busted, if the path starts with views/ and ends with .html, then
|
||||
// we will append the cache busting value to it. This way all upgraded sites will not have to worry about browser cache.
|
||||
"$provide", function($provide) {
|
||||
return $provide.decorator("$http", [
|
||||
"$delegate", function($delegate) {
|
||||
var get = $delegate.get;
|
||||
$delegate.get = function (url, config) {
|
||||
|
||||
if (Umbraco.Sys.ServerVariables.application && url.startsWith("views/") && url.endsWith(".html")) {
|
||||
var rnd = Umbraco.Sys.ServerVariables.application.version + "." + Umbraco.Sys.ServerVariables.application.cdf;
|
||||
var _op = (url.indexOf("?") > 0) ? "&" : "?";
|
||||
url += _op + "umb__rnd=" + rnd;
|
||||
}
|
||||
|
||||
return get(url, config);
|
||||
};
|
||||
return $delegate;
|
||||
}
|
||||
]);
|
||||
}
|
||||
]);
|
||||
|
||||
//Call a document callback if defined, this is sort of a dodgy hack to
|
||||
// be able to configure angular values in the Default.cshtml
|
||||
|
||||
@@ -1,20 +1,22 @@
|
||||
/**
|
||||
* @ngdoc directive
|
||||
* @name umbraco.directives.directive:autoScale
|
||||
* @element div
|
||||
* @function
|
||||
*
|
||||
* @description
|
||||
* Resize div's automatically to fit to the bottom of the screen, as an optional parameter an y-axis offset can be set
|
||||
* So if you only want to scale the div to 70 pixels from the bottom you pass "70"
|
||||
*
|
||||
* @example
|
||||
<example module="umbraco.directives">
|
||||
<file name="index.html">
|
||||
<div auto-scale="70" class="input-block-level"></div>
|
||||
</file>
|
||||
</example>
|
||||
*/
|
||||
* @ngdoc directive
|
||||
* @name umbraco.directives.directive:autoScale
|
||||
* @element div
|
||||
* @deprecated
|
||||
* We plan to remove this directive in the next major version of umbraco (8.0). The directive is not recommended to use.
|
||||
* @function
|
||||
* @description
|
||||
* Resize div's automatically to fit to the bottom of the screen, as an optional parameter an y-axis offset can be set
|
||||
* So if you only want to scale the div to 70 pixels from the bottom you pass "70"
|
||||
|
||||
* @example
|
||||
* <example module="umbraco.directives">
|
||||
* <file name="index.html">
|
||||
* <div auto-scale="70" class="input-block-level"></div>
|
||||
* </file>
|
||||
* </example>
|
||||
**/
|
||||
|
||||
angular.module("umbraco.directives")
|
||||
.directive('autoScale', function ($window) {
|
||||
return function (scope, el, attrs) {
|
||||
@@ -35,4 +37,4 @@ angular.module("umbraco.directives")
|
||||
});
|
||||
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
/**
|
||||
* @ngdoc directive
|
||||
* @name umbraco.directives.directive:umbPanel
|
||||
* @name umbraco.directives.directive:detectFold
|
||||
* @deprecated
|
||||
* We plan to remove this directive in the next major version of umbraco (8.0). The directive is not recommended to use.
|
||||
* @description This is used for the editor buttons to ensure they are displayed correctly if the horizontal overflow of the editor
|
||||
* exceeds the height of the window
|
||||
* exceeds the height of the window
|
||||
**/
|
||||
|
||||
angular.module("umbraco.directives.html")
|
||||
.directive('detectFold', function ($timeout, $log, windowResizeListener) {
|
||||
return {
|
||||
|
||||
+4
-1
@@ -1,11 +1,14 @@
|
||||
/**
|
||||
/**
|
||||
* @ngdoc directive
|
||||
* @name umbraco.directives.directive:umbItemSorter
|
||||
* @deprecated
|
||||
* We plan to remove this directive in the next major version of umbraco (8.0). The directive is not recommended to use.
|
||||
* @function
|
||||
* @element ANY
|
||||
* @restrict E
|
||||
* @description A re-usable directive for sorting items
|
||||
**/
|
||||
|
||||
function umbItemSorter(angularHelper) {
|
||||
return {
|
||||
scope: {
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
/**
|
||||
* @ngdoc directive
|
||||
* @name umbraco.directives.directive:umbContentName
|
||||
* @deprecated
|
||||
* We plan to remove this directive in the next major version of umbraco (8.0). The directive is not recommended to use.
|
||||
* @restrict E
|
||||
* @function
|
||||
* @description
|
||||
* Used by editors that require naming an entity. Shows a textbox/headline with a required validator within it's own form.
|
||||
**/
|
||||
|
||||
angular.module("umbraco.directives")
|
||||
.directive('umbContentName', function ($timeout, localizationService) {
|
||||
return {
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
/**
|
||||
* @ngdoc directive
|
||||
* @name umbraco.directives.directive:umbHeader
|
||||
* @deprecated
|
||||
* We plan to remove this directive in the next major version of umbraco (8.0). The directive is not recommended to use.
|
||||
* @restrict E
|
||||
* @function
|
||||
* @description
|
||||
* The header on an editor that contains tabs using bootstrap tabs - THIS IS OBSOLETE, use umbTabHeader instead
|
||||
**/
|
||||
|
||||
angular.module("umbraco.directives")
|
||||
.directive('umbHeader', function ($parse, $timeout) {
|
||||
return {
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
/**
|
||||
/**
|
||||
* @ngdoc directive
|
||||
* @name umbraco.directives.directive:login
|
||||
* @name umbraco.directives.directive:umbLogin
|
||||
* @deprecated
|
||||
* We plan to remove this directive in the next major version of umbraco (8.0). The directive is not recommended to use.
|
||||
* @function
|
||||
* @element ANY
|
||||
* @restrict E
|
||||
**/
|
||||
|
||||
function loginDirective() {
|
||||
return {
|
||||
restrict: "E", // restrict to an element
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
/**
|
||||
* @ngdoc directive
|
||||
* @name umbraco.directives.directive:umbOptionsMenu
|
||||
* @deprecated
|
||||
* We plan to remove this directive in the next major version of umbraco (8.0). The directive is not recommended to use.
|
||||
* @function
|
||||
* @element ANY
|
||||
* @restrict E
|
||||
**/
|
||||
|
||||
angular.module("umbraco.directives")
|
||||
.directive('umbOptionsMenu', function ($injector, treeService, navigationService, umbModelMapper, appState) {
|
||||
return {
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
/**
|
||||
* @ngdoc directive
|
||||
* @name umbraco.directives.directive:umbPhotoFolder
|
||||
* @deprecated
|
||||
* We plan to remove this directive in the next major version of umbraco (8.0). The directive is not recommended to use.
|
||||
* @restrict E
|
||||
**/
|
||||
|
||||
angular.module("umbraco.directives.html")
|
||||
.directive('umbPhotoFolder', function($compile, $log, $timeout, $filter, umbPhotoFolderHelper) {
|
||||
|
||||
|
||||
@@ -1,20 +1,24 @@
|
||||
/**
|
||||
* @ngdoc directive
|
||||
* @name umbraco.directives.directive:umbSort
|
||||
* @element div
|
||||
* @function
|
||||
*
|
||||
* @description
|
||||
* Resize div's automatically to fit to the bottom of the screen, as an optional parameter an y-axis offset can be set
|
||||
* So if you only want to scale the div to 70 pixels from the bottom you pass "70"
|
||||
*
|
||||
* @example
|
||||
<example module="umbraco.directives">
|
||||
<file name="index.html">
|
||||
<div umb-sort="70" class="input-block-level"></div>
|
||||
</file>
|
||||
</example>
|
||||
*/
|
||||
* @ngdoc directive
|
||||
* @name umbraco.directives.directive:umbSort
|
||||
* @deprecated
|
||||
* We plan to remove this directive in the next major version of umbraco (8.0). The directive is not recommended to use.
|
||||
*
|
||||
* @element div
|
||||
* @function
|
||||
*
|
||||
* @description
|
||||
* Resize div's automatically to fit to the bottom of the screen, as an optional parameter an y-axis offset can be set
|
||||
* So if you only want to scale the div to 70 pixels from the bottom you pass "70"
|
||||
*
|
||||
* @example
|
||||
* <example module="umbraco.directives">
|
||||
* <file name="index.html">
|
||||
* <div umb-sort="70" class="input-block-level"></div>
|
||||
* </file>
|
||||
* </example>
|
||||
**/
|
||||
|
||||
angular.module("umbraco.directives")
|
||||
.value('umbSortContextInternal',{})
|
||||
.directive('umbSort', function($log,umbSortContextInternal) {
|
||||
@@ -165,4 +169,4 @@ angular.module("umbraco.directives")
|
||||
}
|
||||
};
|
||||
|
||||
});
|
||||
});
|
||||
@@ -1,8 +1,12 @@
|
||||
/**
|
||||
* @ngdoc directive
|
||||
* @name umbraco.directives.directive:umbTabView
|
||||
* @deprecated
|
||||
* We plan to remove this directive in the next major version of umbraco (8.0). The directive is not recommended to use.
|
||||
*
|
||||
* @restrict E
|
||||
**/
|
||||
|
||||
angular.module("umbraco.directives")
|
||||
.directive('umbTabView', function($timeout, $log){
|
||||
return {
|
||||
|
||||
+4
@@ -1,8 +1,12 @@
|
||||
/**
|
||||
* @ngdoc directive
|
||||
* @name umbraco.directives.directive:umbUploadDropzone
|
||||
* @deprecated
|
||||
* We plan to remove this directive in the next major version of umbraco (8.0). The directive is not recommended to use.
|
||||
*
|
||||
* @restrict E
|
||||
**/
|
||||
|
||||
angular.module("umbraco.directives.html")
|
||||
.directive('umbUploadDropzone', function(){
|
||||
return {
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@
|
||||
if(convert){
|
||||
element.html("<i class='icon-section " + convert + "'></i>");
|
||||
}else{
|
||||
element.html("<img src='images/tray/" + icon + "'>");
|
||||
element.html("<img class='icon-section' src='images/tray/" + icon + "'>");
|
||||
}
|
||||
//it's a file, normally legacy so look in the icon tray images
|
||||
}
|
||||
|
||||
+68
@@ -1,3 +1,71 @@
|
||||
/**
|
||||
@ngdoc directive
|
||||
@name umbraco.directives.directive:umbButton
|
||||
@restrict E
|
||||
@scope
|
||||
|
||||
@description
|
||||
Use this directive to render an umbraco button. The directive can be used to generate all types of buttons, set type, style, translation, shortcut and much more.
|
||||
|
||||
<h3>Markup example</h3>
|
||||
<pre>
|
||||
<div ng-controller="My.Controller as vm">
|
||||
|
||||
<umb-button
|
||||
action="vm.clickButton()"
|
||||
type="button"
|
||||
button-style="success"
|
||||
state="vm.buttonState"
|
||||
shortcut="ctrl+c"
|
||||
label="My button"
|
||||
disabled="vm.buttonState === 'busy'">
|
||||
</umb-button>
|
||||
|
||||
</div>
|
||||
</pre>
|
||||
|
||||
<h3>Controller example</h3>
|
||||
<pre>
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
function Controller(myService) {
|
||||
|
||||
var vm = this;
|
||||
vm.buttonState = "init";
|
||||
|
||||
vm.clickButton = clickButton;
|
||||
|
||||
function clickButton() {
|
||||
|
||||
vm.buttonState = "busy";
|
||||
|
||||
myService.clickButton().then(function() {
|
||||
vm.buttonState = "success";
|
||||
}, function() {
|
||||
vm.buttonState = "error";
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
angular.module("umbraco").controller("My.Controller", Controller);
|
||||
|
||||
})();
|
||||
</pre>
|
||||
|
||||
@param {callback} action The button action which should be performed when the button is clicked.
|
||||
@param {string=} href Url/Path to navigato to.
|
||||
@param {string=} type Set the button type ("button" or "submit").
|
||||
@param {string=} buttonStyle Set the style of the button. The directive uses the default bootstrap styles ("primary", "info", "success", "warning", "danger", "inverse", "link").
|
||||
@param {string=} state Set a progress state on the button ("init", "busy", "success", "error").
|
||||
@param {string=} shortcut Set a keyboard shortcut for the button ("ctrl+c").
|
||||
@param {string=} label Set the button label.
|
||||
@param {string=} labelKey Set a localization key to make a multi lingual button ("general_buttonText").
|
||||
@param {string=} icon Set a button icon. Can only be used when buttonStyle is "link".
|
||||
@param {boolean=} disabled Set to <code>true</code> to disable the button.
|
||||
**/
|
||||
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user