|
| 1 | +using System; |
| 2 | +using System.IO; |
| 3 | +using GeneXus.Application; |
| 4 | +using GeneXus.Configuration; |
| 5 | +using GeneXus.Data; |
| 6 | +using GeneXus.Data.NTier; |
| 7 | +using GeneXus.Data.NTier.ADO; |
| 8 | +using GeneXus.Procedure; |
| 9 | +using UnitTesting; |
| 10 | +using Xunit; |
| 11 | + |
| 12 | +namespace DotNetCoreUnitTest.Domain |
| 13 | +{ |
| 14 | + public class ProcedureInitializationTest : FileSystemTest |
| 15 | + { |
| 16 | + [Fact] |
| 17 | + public void PublicTempStorageNotCreated() |
| 18 | + { |
| 19 | + bool isKey = Config.GetValueOf("CS_BLOB_PATH", out string blobPath); |
| 20 | + Assert.True(isKey); |
| 21 | + string path = Path.Combine(BaseDir, blobPath); |
| 22 | + aprocedure1 aprocedure1 = new aprocedure1(); |
| 23 | + aprocedure1.execute(); |
| 24 | + Assert.False(Directory.Exists(path), $"The directory {blobPath} should only be created when necessary."); |
| 25 | + |
| 26 | + isKey = Config.GetValueOf("TMPMEDIA_DIR", out string tempMediaDir); |
| 27 | + Assert.True(isKey); |
| 28 | + path = Path.Combine(BaseDir, tempMediaDir); |
| 29 | + Assert.False(Directory.Exists(path), $"The directory {tempMediaDir} should only be created when necessary."); |
| 30 | + } |
| 31 | + } |
| 32 | + public class aprocedure1 : GXProcedure |
| 33 | + { |
| 34 | + |
| 35 | + public int executeCmdLine(string[] args) |
| 36 | + { |
| 37 | + return ExecuteCmdLine(args); ; |
| 38 | + } |
| 39 | + |
| 40 | + protected override int ExecuteCmdLine(string[] args) |
| 41 | + { |
| 42 | + execute(); |
| 43 | + return GX.GXRuntime.ExitCode; |
| 44 | + } |
| 45 | + |
| 46 | + public aprocedure1() |
| 47 | + { |
| 48 | + context = new GxContext(); |
| 49 | + DataStoreUtil.LoadDataStores(context); |
| 50 | + IsMain = true; |
| 51 | + context.SetDefaultTheme("CmdLine", true); |
| 52 | + } |
| 53 | + |
| 54 | + public aprocedure1(IGxContext context) |
| 55 | + { |
| 56 | + this.context = context; |
| 57 | + IsMain = false; |
| 58 | + } |
| 59 | + |
| 60 | + public void execute() |
| 61 | + { |
| 62 | + initialize(); |
| 63 | + try |
| 64 | + { |
| 65 | + ExecutePrivate(); |
| 66 | + } |
| 67 | + catch (ReturnInErrorHandlerException) |
| 68 | + { |
| 69 | + this.cleanup(); |
| 70 | + return; |
| 71 | + } |
| 72 | + } |
| 73 | + |
| 74 | + public void executeSubmit() |
| 75 | + { |
| 76 | + SubmitImpl(); |
| 77 | + } |
| 78 | + |
| 79 | + protected override void ExecutePrivate() |
| 80 | + { |
| 81 | + /* GeneXus formulas */ |
| 82 | + /* Output device settings */ |
| 83 | + pr_default.close(0); |
| 84 | + this.cleanup(); |
| 85 | + } |
| 86 | + |
| 87 | + public override void cleanup() |
| 88 | + { |
| 89 | + CloseCursors(); |
| 90 | + if (IsMain) |
| 91 | + { |
| 92 | + context.CloseConnections(); |
| 93 | + } |
| 94 | + ExitApp(); |
| 95 | + } |
| 96 | + |
| 97 | + public override void initialize() |
| 98 | + { |
| 99 | + P000D2_A1GXM01_CtlName = new string[] { "" }; |
| 100 | + pr_default = new DataStoreProvider(context, new aprocedure1__default(), |
| 101 | + new Object[][] { |
| 102 | + new Object[] { |
| 103 | + P000D2_A1GXM01_CtlName |
| 104 | + } |
| 105 | + } |
| 106 | + ); |
| 107 | + /* GeneXus formulas. */ |
| 108 | + } |
| 109 | + |
| 110 | + private IDataStoreProvider pr_default; |
| 111 | + private string[] P000D2_A1GXM01_CtlName; |
| 112 | + } |
| 113 | + |
| 114 | + public class aprocedure1__default : DataStoreHelperBase, IDataStoreHelper |
| 115 | + { |
| 116 | + public ICursor[] getCursors() |
| 117 | + { |
| 118 | + cursorDefinitions(); |
| 119 | + return new Cursor[] { |
| 120 | + new ForEachCursor(def[0]) |
| 121 | + }; |
| 122 | + } |
| 123 | + |
| 124 | + private static CursorDef[] def; |
| 125 | + private void cursorDefinitions() |
| 126 | + { |
| 127 | + if (def == null) |
| 128 | + { |
| 129 | + Object[] prmP000D2; |
| 130 | + prmP000D2 = new Object[] { |
| 131 | + }; |
| 132 | + def = new CursorDef[] { |
| 133 | + new CursorDef("P000D2", "SELECT TOP 1 [GXM01_CtlName] FROM [GXM01] WHERE [GXM01_CtlName] = 'FCA010_DL_Name' ORDER BY [GXM01_CtlName] ",false, GxErrorMask.GX_NOMASK | GxErrorMask.GX_MASKLOOPLOCK, false, this,prmP000D2,1, GxCacheFrequency.OFF ,false,true ) |
| 134 | + }; |
| 135 | + } |
| 136 | + } |
| 137 | + |
| 138 | + public void getResults(int cursor, |
| 139 | + IFieldGetter rslt, |
| 140 | + Object[] buf) |
| 141 | + { |
| 142 | + switch (cursor) |
| 143 | + { |
| 144 | + case 0: |
| 145 | + ((string[])buf[0])[0] = rslt.getVarchar(1); |
| 146 | + return; |
| 147 | + } |
| 148 | + } |
| 149 | + |
| 150 | + } |
| 151 | + |
| 152 | +} |
0 commit comments