Produced by Araxis Merge on 9/9/2019 5:42:10 PM Eastern Daylight Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.
# | Location | File | Last Modified |
---|---|---|---|
1 | Webvram-v4.zip\20190725-webvram-source.zip\Sources\WebVRAM.VistA.Service.Tests\Service | SyncServiceTests.cs | Tue Jul 23 23:11:38 2019 UTC |
2 | Webvram-v4.zip\20190725-webvram-source.zip\Sources\WebVRAM.VistA.Service.Tests\Service | SyncServiceTests.cs | Fri Sep 6 20:59:19 2019 UTC |
Description | Between Files 1 and 2 |
|
---|---|---|
Text Blocks | Lines | |
Unchanged | 4 | 480 |
Changed | 3 | 8 |
Inserted | 0 | 0 |
Removed | 0 | 0 |
Whitespace | |
---|---|
Character case | Differences in character case are significant |
Line endings | Differences in line endings (CR and LF characters) are ignored |
CR/LF characters | Not shown in the comparison detail |
No regular expressions were active.
1 | using Syst em; | |
2 | using Syst em.Collect ions.Gener ic; | |
3 | using Micr osoft.Visu alStudio.T estTools.U nitTesting ; | |
4 | using Micr osoft.Exte nsions.Log ging; | |
5 | using WebV RAM.Vista. Service; | |
6 | using Micr osoft.Exte nsions.Con figuration ; | |
7 | using Micr osoft.AspN etCore.Htt p; | |
8 | using Syst em.Securit y.Claims; | |
9 | using Vist a.RPC; | |
10 | using WebV RAM.Web.ng .Common; | |
11 | using Vist a.RPC.Proc edures; | |
12 | using Vist a.RPC.Proc edures.DDR ; | |
13 | using Vist a.RPC.Proc edures.XUS ; | |
14 | using Vist a.RPC.Proc edures.XWB ; | |
15 | using WebV RAM.Vista. Data.Tests .Common; | |
16 | using WebV RAM.Vista. Services; | |
17 | using WebV RAM.Web.ng .Models; | |
18 | ||
19 | namespace WebVRAM.Vi sta.Servic e.Tests.Se rvice | |
20 | { | |
21 | /// <s ummary> | |
22 | /// Su mmary desc ription fo r UnitTest 1 | |
23 | /// </ summary> | |
24 | [TestC lass] | |
25 | public class Syn cServiceTe sts : IHtt pContextAc cessor, IR pcClientFa ctory, IRp cSocketFac tory, IRpc Socket | |
26 | { | |
27 | De faultHttpC ontext htt pContext; | |
28 | ||
29 | // TestRpcCli ent testRp cClient; | |
30 | Rp cClient te stRpcClien t2; | |
31 | bo ol _rpcSoc ketConnect ed = false ; | |
32 | st ring _loca lIpAddress ; | |
33 | st ring _loca lHostName; | |
34 | Li st<List<ob ject>> rpc SocketCall s = new Li st<List<ob ject>>(); | |
35 | Li st<string> rpcSocket ParamStrin gs = new L ist<string >(); | |
36 | ||
37 | pu blic SyncS erviceTest s() | |
38 | { | |
39 | } | |
40 | ||
41 | pr ivate Test Context te stContextI nstance; | |
42 | ||
43 | // / <summary > | |
44 | // /Gets or s ets the te st context which pro vides | |
45 | // /informati on about a nd functio nality for the curre nt test ru n. | |
46 | // /</summary > | |
47 | pu blic TestC ontext Tes tContext | |
48 | { | |
49 | get => t estContext Instance; | |
50 | set => t estContext Instance = value; | |
51 | } | |
52 | ||
53 | // IHttpCont extAccesso r property implement ation | |
54 | pu blic HttpC ontext Htt pContext | |
55 | { | |
56 | get => h ttpContext ; | |
57 | set => t hrow new N otImplemen tedExcepti on(); | |
58 | } | |
59 | ||
60 | // IRpcSocke t interfac e implemen tation | |
61 | pu blic bool Connected | |
62 | { | |
63 | get => _ rpcSocketC onnected; | |
64 | set => _ rpcSocketC onnected = value; | |
65 | } | |
66 | ||
67 | pu blic strin g LocalIpA ddress | |
68 | { | |
69 | get | |
70 | { | |
71 | stri ng returnV alue = ""; | |
72 | if ( Connected) | |
73 | { | |
74 | returnValu e = _local IpAddress; | |
75 | } | |
76 | ||
77 | rpcS ocketCalls .Add(new L ist<object >() {"Loca lIpAddress ", returnV alue}); | |
78 | retu rn returnV alue; | |
79 | } | |
80 | } | |
81 | ||
82 | pu blic strin g LocalHos tName | |
83 | { | |
84 | get | |
85 | { | |
86 | rpcS ocketCalls .Add(new L ist<object >() {"Loca lHostName" , _localHo stName}); | |
87 | retu rn _localH ostName; | |
88 | } | |
89 | } | |
90 | ||
91 | #r egion Addi tional tes t attribut es | |
92 | ||
93 | // | |
94 | // You can u se the fol lowing add itional at tributes a s you writ e your tes ts: | |
95 | // | |
96 | // Use Class Initialize to run co de before running th e first te st in the class | |
97 | // [ClassIni tialize()] | |
98 | // public st atic void MyClassIni tialize(Te stContext testContex t) { } | |
99 | // | |
100 | // Use Class Cleanup to run code after all tests in a class hav e run | |
101 | // [ClassCle anup()] | |
102 | // public st atic void MyClassCle anup() { } | |
103 | // | |
104 | // Use TestI nitialize to run cod e before r unning eac h test | |
105 | // [TestInit ialize()] | |
106 | // public vo id MyTestI nitialize( ) { } | |
107 | // | |
108 | // Use TestC leanup to run code a fter each test has r un | |
109 | // [TestClea nup()] | |
110 | // public vo id MyTestC leanup() { } | |
111 | // | |
112 | ||
113 | #e ndregion | |
114 | ||
115 | [T estInitial ize()] | |
116 | pu blic void MyTestInit ialize() | |
117 | { | |
118 | httpCont ext = new DefaultHtt pContext() ; | |
119 | httpCont ext.User = GetTestUs er(); | |
120 | _rpcSock etConnecte d = false; | |
121 | _localIp Address = "127.127.1 27.127"; | |
122 | _localHost Name = " URL "; | |
123 | } | |
124 | ||
125 | pr otected vi rtual Clai msPrincipa l GetTestU ser() | |
126 | { | |
127 | ClaimsPr incipal cl aimsPrinci pal = new ClaimsPrin cipal(); | |
128 | claimsPr incipal.Ad dIdentity( getUserId( )); | |
129 | return c laimsPrinc ipal; | |
130 | } | |
131 | ||
132 | pr otected vi rtual Clai msIdentity getUserId () | |
133 | { | |
134 | var clai ms = new L ist<Claim> | |
135 | { | |
136 | new Claim(Clai mTypes.Nam e, "MyUser "), | |
137 | new Claim(Clai mTypes.Nam eIdentifie r, "MyUser ID"), | |
138 | new Claim(Clai mTypes.Rol e, "MyRole "), | |
139 | new Claim(JwtP rivateClai ms.AccessC ode, "stuf f1"), | |
140 | new Claim(JwtP rivateClai ms.VerifyC ode, "stuf f2") | |
141 | }; | |
142 | ClaimsId entity id = new Clai msIdentity (claims, " CustomApiK eyAuth"); | |
143 | return i d; | |
144 | } | |
145 | ||
146 | [T estMethod] | |
147 | pu blic void GetVistaSi tes_happyP ath() | |
148 | { | |
149 | ILogger< SyncServic e> logger = TestLogg er.Create< SyncServic e>(); | |
150 | SyncServ ice servic e = new Sy ncService( logger, Ge tVistaConf ig(), GetT estUser(), null); // TODO Mock object | |
151 | //servic e.RpcClien tFactory = this; // this shoul dn't be ne eded | |
152 | ||
153 | Dictiona ry<string, Models.Vi staSite> s ites = ser vice.GetVi staSites() ; | |
154 | Assert.A reEqual(12 , rpcSocke tCalls.Cou nt); | |
155 | Assert.A reEqual("C all", rpcS ocketCalls [8][0]); | |
156 | DdrGets ddrGets = (DdrGets) rpcSocketC alls[8][1] ; | |
157 | Assert.A reEqual("D DR GETS EN TRY DATA", ddrGets.R pcName); | |
158 | Assert.A reEqual("C all", rpcS ocketCalls [9][0]); | |
159 | DdrListe r ddrListe r = (DdrLi ster) rpcS ocketCalls [9][1]; | |
160 | Assert.A reEqual("D DR LISTER" , ddrListe r.RpcName) ; | |
161 | Assert.I sTrue(rpcS ocketParam Strings[6] | |
162 | .Con tains("if $extract($ piece(^(0) ,U,4))'=\" @\",$data( ^R1(100100 .0343,\"AU \",DUZ,+Y) )")); | |
163 | } | |
164 | ||
165 | pr otected vi rtual ICon figuration Section ge tTestConfi gSection() | |
166 | { | |
167 | FlexConf igurationS ection roo t = new Fl exConfigur ationSecti on(); | |
168 | FlexConf igurationS ection vis taConfig = new FlexC onfigurati onSection( ); | |
169 | vistaConfi g["Hostnam e"] = " URL "; | |
170 | vistaConfi g["RpcPort "] = " PORT "; | |
171 | vistaCon fig["VramM enuOption" ] = "VRAM IS HERE BA BY"; | |
172 | root.Add Section("V ista", vis taConfig); | |
173 | return r oot; | |
174 | } | |
175 | ||
176 | pr otected vi rtual Vist aConfig Ge tVistaConf ig() | |
177 | { | |
178 | var vistaC onfig = ne w VistaCon fig(" URL ", PORT , | |
179 | "VRA M IS HERE BABY".ToSe cureString (), "UNKNO WN".ToSecu reString() ); | |
180 | ||
181 | return v istaConfig ; | |
182 | } | |
183 | ||
184 | // IRpcClien tFactory m ethods | |
185 | pu blic IRpcC lient Crea te(string hostname, int port, bool preve ntRpcTimeo ut = true) | |
186 | { | |
187 | var logg er = RpcLo gging.Crea teLogger<R pcClient>( ); | |
188 | testRpcC lient2 = n ew RpcClie nt(logger, hostname, port, pre ventRpcTim eout); | |
189 | testRpcC lient2.Rpc SocketFact ory = this ; | |
190 | return t his.testRp cClient2; | |
191 | } | |
192 | ||
193 | // IRpcSocke tFactory m ethods | |
194 | pu blic IRpcS ocket Crea te() | |
195 | { | |
196 | return t his; | |
197 | } | |
198 | ||
199 | // IRpcSocke t interfac e implemen tation | |
200 | pu blic void Connect(st ring host, int port) | |
201 | { | |
202 | rpcSocke tCalls.Add (new List< object>() {"Connect" , host + " :" + port} ); | |
203 | Connecte d = true; | |
204 | } | |
205 | ||
206 | pu blic void Call(IRemo teProcedur e rpc) | |
207 | { | |
208 | rpcSocke tCalls.Add (new List< object>() {"Call", r pc}); | |
209 | if (!Con nected) | |
210 | { | |
211 | thro w new Exce ption("not connected "); | |
212 | } | |
213 | ||
214 | rpcSocke tParamStri ngs.Add(rp c.ToProced ure()); | |
215 | if (rpc is AvCode) | |
216 | { | |
217 | rpc. SetRespons e("123\r\n 0\r\n\r\n" ); | |
218 | } | |
219 | else if (rpc is Co nnect) | |
220 | { | |
221 | rpc. SetRespons e("accept" ); | |
222 | } | |
223 | else if (rpc is Cr eateContex t) | |
224 | { | |
225 | rpc. SetRespons e("1"); | |
226 | } | |
227 | else | |
228 | { | |
229 | rpc. SetRespons e(""); | |
230 | } | |
231 | } | |
232 | ||
233 | pu blic void Disconnect () | |
234 | { | |
235 | rpcSocke tCalls.Add (new List< object>() {"Disconne ct", ""}); | |
236 | Connecte d = false; | |
237 | } | |
238 | ||
239 | pu blic void Dispose() | |
240 | { | |
241 | ||
242 | } | |
243 | } | |
244 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.