Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

LuEfUpdateDataAccessTest.cs 28KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using Luticate2.Utils.Dbo.Result;
  5. using TestUtils.DataAccess;
  6. using TestUtils.Dbo.PkBigSerial;
  7. using TestUtils.Dbo.PkGuid;
  8. using Xunit;
  9. namespace TestUtils.EfCrudDataAccess
  10. {
  11. public class LuEfUpdateDataAccessTest
  12. {
  13. [Fact]
  14. public void TestEditMultiple1()
  15. {
  16. Tests.TestRealDb<LuUtilsPkGuidDataAccess>(service =>
  17. {
  18. var dbos = new List<PkGuidAddDbo>
  19. {
  20. new PkGuidAddDbo
  21. {
  22. SomeInt = 42,
  23. SomeText = "442"
  24. },
  25. new PkGuidAddDbo
  26. {
  27. SomeInt = 42,
  28. SomeText = "42"
  29. },
  30. new PkGuidAddDbo
  31. {
  32. SomeInt = 24,
  33. SomeText = "24"
  34. }
  35. };
  36. var res = service.AddId(dbos);
  37. Assert.Equal(LuStatus.Success, res.Status);
  38. var edit = service.Edit(guid => guid.some_int == 42, guid => guid.some_int = -1, enumerable => enumerable);
  39. Assert.Equal(LuStatus.Success, edit.Status);
  40. var elements = edit.Data.ToList();
  41. Assert.Equal(2, elements.Count);
  42. var e = elements[0];
  43. Assert.Equal(-1, e.SomeInt);
  44. Assert.Equal("442", e.SomeText);
  45. e = elements[1];
  46. Assert.Equal(-1, e.SomeInt);
  47. Assert.Equal("42", e.SomeText);
  48. });
  49. }
  50. [Fact]
  51. public void TestEditMultiple2()
  52. {
  53. Tests.TestRealDb<LuUtilsPkGuidDataAccess>(service =>
  54. {
  55. var dbos = new List<PkGuidAddDbo>
  56. {
  57. new PkGuidAddDbo
  58. {
  59. SomeInt = 42,
  60. SomeText = "442"
  61. },
  62. new PkGuidAddDbo
  63. {
  64. SomeInt = 42,
  65. SomeText = "42"
  66. },
  67. new PkGuidAddDbo
  68. {
  69. SomeInt = 24,
  70. SomeText = "24"
  71. }
  72. };
  73. var res = service.AddId(dbos);
  74. Assert.Equal(LuStatus.Success, res.Status);
  75. var edit = service.Edit(guid => guid.some_int == 42, guid => guid.some_int = -1, enumerable => enumerable.Select(guidDbo => guidDbo.SomeText));
  76. Assert.Equal(LuStatus.Success, edit.Status);
  77. var elements = edit.Data.ToList();
  78. Assert.Equal(2, elements.Count);
  79. var e = elements[0];
  80. Assert.Equal("442", e);
  81. e = elements[1];
  82. Assert.Equal("42", e);
  83. });
  84. }
  85. [Fact]
  86. public void TestEditMultiple3()
  87. {
  88. Tests.TestRealDb<LuUtilsPkGuidDataAccess>(service =>
  89. {
  90. var dbos = new List<PkGuidAddDbo>
  91. {
  92. new PkGuidAddDbo
  93. {
  94. SomeInt = 42,
  95. SomeText = "442"
  96. },
  97. new PkGuidAddDbo
  98. {
  99. SomeInt = 42,
  100. SomeText = "42"
  101. },
  102. new PkGuidAddDbo
  103. {
  104. SomeInt = 24,
  105. SomeText = "24"
  106. }
  107. };
  108. var res = service.AddId(dbos);
  109. Assert.Equal(LuStatus.Success, res.Status);
  110. var edit = service.EditId(guid => guid.some_int == 42, guid => guid.some_int = -1);
  111. Assert.Equal(LuStatus.Success, edit.Status);
  112. var elements = edit.Data.ToList();
  113. Assert.Equal(2, elements.Count);
  114. var e = elements[0];
  115. Assert.NotEqual(new Guid().ToString(), e);
  116. e = elements[1];
  117. Assert.NotEqual(new Guid().ToString(), e);
  118. });
  119. }
  120. [Fact]
  121. public void TestEditMultiple4()
  122. {
  123. Tests.TestRealDb<LuUtilsPkBigSerialDataAccess>(service =>
  124. {
  125. var dbos = new List<PkBigSerialAddDbo>
  126. {
  127. new PkBigSerialAddDbo
  128. {
  129. SomeInt = 42,
  130. SomeText = "442"
  131. },
  132. new PkBigSerialAddDbo
  133. {
  134. SomeInt = 42,
  135. SomeText = "42"
  136. },
  137. new PkBigSerialAddDbo
  138. {
  139. SomeInt = 24,
  140. SomeText = "24"
  141. }
  142. };
  143. var res = service.AddId(dbos);
  144. Assert.Equal(LuStatus.Success, res.Status);
  145. var edit = service.EditId(guid => guid.some_int == 42, guid => guid.some_int = -1);
  146. Assert.Equal(LuStatus.Success, edit.Status);
  147. var elements = edit.Data.ToList();
  148. Assert.Equal(2, elements.Count);
  149. var e = elements[0];
  150. Assert.NotEqual(0, e);
  151. e = elements[1];
  152. Assert.NotEqual(0, e);
  153. });
  154. }
  155. [Fact]
  156. public void TestEditMultiple5()
  157. {
  158. Tests.TestRealDb<LuUtilsPkGuidDataAccess>(service =>
  159. {
  160. var dbos = new List<PkGuidAddDbo>
  161. {
  162. new PkGuidAddDbo
  163. {
  164. SomeInt = 42,
  165. SomeText = "442"
  166. },
  167. new PkGuidAddDbo
  168. {
  169. SomeInt = 42,
  170. SomeText = "42"
  171. },
  172. new PkGuidAddDbo
  173. {
  174. SomeInt = 24,
  175. SomeText = "24"
  176. }
  177. };
  178. var res = service.AddId(dbos);
  179. Assert.Equal(LuStatus.Success, res.Status);
  180. var edit = service.EditDbo(guid => guid.some_int == 42, guid => guid.some_int = -1);
  181. Assert.Equal(LuStatus.Success, edit.Status);
  182. var elements = edit.Data.ToList();
  183. Assert.Equal(2, elements.Count);
  184. var e = elements[0];
  185. Assert.Equal(-1, e.SomeInt);
  186. Assert.Equal("442", e.SomeText);
  187. e = elements[1];
  188. Assert.Equal(-1, e.SomeInt);
  189. Assert.Equal("42", e.SomeText);
  190. });
  191. }
  192. [Fact]
  193. public void TestEditSingle1()
  194. {
  195. Tests.TestRealDb<LuUtilsPkBigSerialDataAccess>(service =>
  196. {
  197. var dbos = new List<PkBigSerialAddDbo>
  198. {
  199. new PkBigSerialAddDbo
  200. {
  201. SomeInt = 42,
  202. SomeText = "442"
  203. },
  204. new PkBigSerialAddDbo
  205. {
  206. SomeInt = 42,
  207. SomeText = "42"
  208. },
  209. new PkBigSerialAddDbo
  210. {
  211. SomeInt = 24,
  212. SomeText = "24"
  213. }
  214. };
  215. var res = service.AddId(dbos);
  216. Assert.Equal(LuStatus.Success, res.Status);
  217. var ids = res.Data.ToList();
  218. var edit = service.EditSingleById(ids[0], guid => guid.some_int = -1, d => d);
  219. Assert.Equal(LuStatus.Success, edit.Status);
  220. Assert.Equal(-1, edit.Data.SomeInt);
  221. Assert.Equal("442", edit.Data.SomeText);
  222. var get = service.GetMultiple(guid => guid.some_text);
  223. Assert.Equal(LuStatus.Success, get.Status);
  224. Assert.Equal(3, get.Data.Count);
  225. Assert.Equal(3, get.Data.Data.Count);
  226. var dbo = get.Data.Data[0];
  227. Assert.Equal(24, dbo.SomeInt);
  228. Assert.Equal("24", dbo.SomeText);
  229. dbo = get.Data.Data[1];
  230. Assert.Equal(42, dbo.SomeInt);
  231. Assert.Equal("42", dbo.SomeText);
  232. dbo = get.Data.Data[2];
  233. Assert.Equal(-1, dbo.SomeInt);
  234. Assert.Equal("442", dbo.SomeText);
  235. });
  236. }
  237. [Fact]
  238. public void TestEditSingle2()
  239. {
  240. Tests.TestRealDb<LuUtilsPkBigSerialDataAccess>(service =>
  241. {
  242. var dbos = new List<PkBigSerialAddDbo>
  243. {
  244. new PkBigSerialAddDbo
  245. {
  246. SomeInt = 42,
  247. SomeText = "442"
  248. },
  249. new PkBigSerialAddDbo
  250. {
  251. SomeInt = 42,
  252. SomeText = "42"
  253. },
  254. new PkBigSerialAddDbo
  255. {
  256. SomeInt = 24,
  257. SomeText = "24"
  258. }
  259. };
  260. var res = service.AddId(dbos);
  261. Assert.Equal(LuStatus.Success, res.Status);
  262. var ids = res.Data.ToList();
  263. var edit = service.EditSingleByIdId(ids[0], guid => guid.some_int = -1);
  264. Assert.Equal(LuStatus.Success, edit.Status);
  265. var get = service.GetMultiple(guid => guid.some_text);
  266. Assert.Equal(LuStatus.Success, get.Status);
  267. Assert.Equal(3, get.Data.Count);
  268. Assert.Equal(3, get.Data.Data.Count);
  269. var dbo = get.Data.Data[0];
  270. Assert.Equal(24, dbo.SomeInt);
  271. Assert.Equal("24", dbo.SomeText);
  272. dbo = get.Data.Data[1];
  273. Assert.Equal(42, dbo.SomeInt);
  274. Assert.Equal("42", dbo.SomeText);
  275. dbo = get.Data.Data[2];
  276. Assert.Equal(-1, dbo.SomeInt);
  277. Assert.Equal("442", dbo.SomeText);
  278. });
  279. }
  280. [Fact]
  281. public void TestEditSingle3()
  282. {
  283. Tests.TestRealDb<LuUtilsPkBigSerialDataAccess>(service =>
  284. {
  285. var dbos = new List<PkBigSerialAddDbo>
  286. {
  287. new PkBigSerialAddDbo
  288. {
  289. SomeInt = 42,
  290. SomeText = "442"
  291. },
  292. new PkBigSerialAddDbo
  293. {
  294. SomeInt = 42,
  295. SomeText = "42"
  296. },
  297. new PkBigSerialAddDbo
  298. {
  299. SomeInt = 24,
  300. SomeText = "24"
  301. }
  302. };
  303. var res = service.AddId(dbos);
  304. Assert.Equal(LuStatus.Success, res.Status);
  305. var ids = res.Data.ToList();
  306. var edit = service.EditSingleByIdDbo(ids[0], guid => guid.some_int = -1);
  307. Assert.Equal(LuStatus.Success, edit.Status);
  308. Assert.Equal(-1, edit.Data.SomeInt);
  309. Assert.Equal("442", edit.Data.SomeText);
  310. var get = service.GetMultiple(guid => guid.some_text);
  311. Assert.Equal(LuStatus.Success, get.Status);
  312. Assert.Equal(3, get.Data.Count);
  313. Assert.Equal(3, get.Data.Data.Count);
  314. var dbo = get.Data.Data[0];
  315. Assert.Equal(24, dbo.SomeInt);
  316. Assert.Equal("24", dbo.SomeText);
  317. dbo = get.Data.Data[1];
  318. Assert.Equal(42, dbo.SomeInt);
  319. Assert.Equal("42", dbo.SomeText);
  320. dbo = get.Data.Data[2];
  321. Assert.Equal(-1, dbo.SomeInt);
  322. Assert.Equal("442", dbo.SomeText);
  323. });
  324. }
  325. [Fact]
  326. public void TestEditSingle4()
  327. {
  328. Tests.TestRealDb<LuUtilsPkGuidDataAccess>(service =>
  329. {
  330. var dbos = new List<PkGuidAddDbo>
  331. {
  332. new PkGuidAddDbo
  333. {
  334. SomeInt = 42,
  335. SomeText = "442"
  336. },
  337. new PkGuidAddDbo
  338. {
  339. SomeInt = 42,
  340. SomeText = "42"
  341. },
  342. new PkGuidAddDbo
  343. {
  344. SomeInt = 24,
  345. SomeText = "24"
  346. }
  347. };
  348. var res = service.AddId(dbos);
  349. Assert.Equal(LuStatus.Success, res.Status);
  350. var ids = res.Data.ToList();
  351. var edit = service.EditSingleById(ids[0], guid => guid.some_int = -1, d => d);
  352. Assert.Equal(LuStatus.Success, edit.Status);
  353. Assert.Equal(-1, edit.Data.SomeInt);
  354. Assert.Equal("442", edit.Data.SomeText);
  355. var get = service.GetMultiple(guid => guid.some_text);
  356. Assert.Equal(LuStatus.Success, get.Status);
  357. Assert.Equal(3, get.Data.Count);
  358. Assert.Equal(3, get.Data.Data.Count);
  359. var dbo = get.Data.Data[0];
  360. Assert.Equal(24, dbo.SomeInt);
  361. Assert.Equal("24", dbo.SomeText);
  362. dbo = get.Data.Data[1];
  363. Assert.Equal(42, dbo.SomeInt);
  364. Assert.Equal("42", dbo.SomeText);
  365. dbo = get.Data.Data[2];
  366. Assert.Equal(-1, dbo.SomeInt);
  367. Assert.Equal("442", dbo.SomeText);
  368. });
  369. }
  370. [Fact]
  371. public void TestEditSingle5()
  372. {
  373. Tests.TestRealDb<LuUtilsPkGuidDataAccess>(service =>
  374. {
  375. var dbos = new List<PkGuidAddDbo>
  376. {
  377. new PkGuidAddDbo
  378. {
  379. SomeInt = 42,
  380. SomeText = "442"
  381. },
  382. new PkGuidAddDbo
  383. {
  384. SomeInt = 42,
  385. SomeText = "42"
  386. },
  387. new PkGuidAddDbo
  388. {
  389. SomeInt = 24,
  390. SomeText = "24"
  391. }
  392. };
  393. var res = service.AddId(dbos);
  394. Assert.Equal(LuStatus.Success, res.Status);
  395. var ids = res.Data.ToList();
  396. var edit = service.EditSingleByIdId(ids[0], guid => guid.some_int = -1);
  397. Assert.Equal(LuStatus.Success, edit.Status);
  398. var get = service.GetMultiple(guid => guid.some_text);
  399. Assert.Equal(LuStatus.Success, get.Status);
  400. Assert.Equal(3, get.Data.Count);
  401. Assert.Equal(3, get.Data.Data.Count);
  402. var dbo = get.Data.Data[0];
  403. Assert.Equal(24, dbo.SomeInt);
  404. Assert.Equal("24", dbo.SomeText);
  405. dbo = get.Data.Data[1];
  406. Assert.Equal(42, dbo.SomeInt);
  407. Assert.Equal("42", dbo.SomeText);
  408. dbo = get.Data.Data[2];
  409. Assert.Equal(-1, dbo.SomeInt);
  410. Assert.Equal("442", dbo.SomeText);
  411. });
  412. }
  413. [Fact]
  414. public void TestEditSingle6()
  415. {
  416. Tests.TestRealDb<LuUtilsPkGuidDataAccess>(service =>
  417. {
  418. var dbos = new List<PkGuidAddDbo>
  419. {
  420. new PkGuidAddDbo
  421. {
  422. SomeInt = 42,
  423. SomeText = "442"
  424. },
  425. new PkGuidAddDbo
  426. {
  427. SomeInt = 42,
  428. SomeText = "42"
  429. },
  430. new PkGuidAddDbo
  431. {
  432. SomeInt = 24,
  433. SomeText = "24"
  434. }
  435. };
  436. var res = service.AddId(dbos);
  437. Assert.Equal(LuStatus.Success, res.Status);
  438. var ids = res.Data.ToList();
  439. var edit = service.EditSingleByIdDbo(ids[0], guid => guid.some_int = -1);
  440. Assert.Equal(LuStatus.Success, edit.Status);
  441. Assert.Equal(-1, edit.Data.SomeInt);
  442. Assert.Equal("442", edit.Data.SomeText);
  443. var get = service.GetMultiple(guid => guid.some_text);
  444. Assert.Equal(LuStatus.Success, get.Status);
  445. Assert.Equal(3, get.Data.Count);
  446. Assert.Equal(3, get.Data.Data.Count);
  447. var dbo = get.Data.Data[0];
  448. Assert.Equal(24, dbo.SomeInt);
  449. Assert.Equal("24", dbo.SomeText);
  450. dbo = get.Data.Data[1];
  451. Assert.Equal(42, dbo.SomeInt);
  452. Assert.Equal("42", dbo.SomeText);
  453. dbo = get.Data.Data[2];
  454. Assert.Equal(-1, dbo.SomeInt);
  455. Assert.Equal("442", dbo.SomeText);
  456. });
  457. }
  458. [Fact]
  459. public void TestEditSingle7()
  460. {
  461. Tests.TestRealDb<LuUtilsPkBigSerialDataAccess>(service =>
  462. {
  463. var dbos = new List<PkBigSerialAddDbo>
  464. {
  465. new PkBigSerialAddDbo
  466. {
  467. SomeInt = 42,
  468. SomeText = "442"
  469. },
  470. new PkBigSerialAddDbo
  471. {
  472. SomeInt = 42,
  473. SomeText = "42"
  474. },
  475. new PkBigSerialAddDbo
  476. {
  477. SomeInt = 24,
  478. SomeText = "24"
  479. }
  480. };
  481. var res = service.AddId(dbos);
  482. Assert.Equal(LuStatus.Success, res.Status);
  483. var ids = res.Data.ToList();
  484. dbos[0].SomeInt = -1;
  485. var edit = service.EditSingleById(ids[0], dbos[0], d => d);
  486. Assert.Equal(LuStatus.Success, edit.Status);
  487. Assert.Equal(-1, edit.Data.SomeInt);
  488. Assert.Equal("442", edit.Data.SomeText);
  489. var get = service.GetMultiple(guid => guid.some_text);
  490. Assert.Equal(LuStatus.Success, get.Status);
  491. Assert.Equal(3, get.Data.Count);
  492. Assert.Equal(3, get.Data.Data.Count);
  493. var dbo = get.Data.Data[0];
  494. Assert.Equal(24, dbo.SomeInt);
  495. Assert.Equal("24", dbo.SomeText);
  496. dbo = get.Data.Data[1];
  497. Assert.Equal(42, dbo.SomeInt);
  498. Assert.Equal("42", dbo.SomeText);
  499. dbo = get.Data.Data[2];
  500. Assert.Equal(-1, dbo.SomeInt);
  501. Assert.Equal("442", dbo.SomeText);
  502. });
  503. }
  504. [Fact]
  505. public void TestEditSingle8()
  506. {
  507. Tests.TestRealDb<LuUtilsPkBigSerialDataAccess>(service =>
  508. {
  509. var dbos = new List<PkBigSerialAddDbo>
  510. {
  511. new PkBigSerialAddDbo
  512. {
  513. SomeInt = 42,
  514. SomeText = "442"
  515. },
  516. new PkBigSerialAddDbo
  517. {
  518. SomeInt = 42,
  519. SomeText = "42"
  520. },
  521. new PkBigSerialAddDbo
  522. {
  523. SomeInt = 24,
  524. SomeText = "24"
  525. }
  526. };
  527. var res = service.AddId(dbos);
  528. Assert.Equal(LuStatus.Success, res.Status);
  529. var ids = res.Data.ToList();
  530. dbos[0].SomeInt = -1;
  531. var edit = service.EditSingleByIdId(ids[0], dbos[0]);
  532. Assert.Equal(LuStatus.Success, edit.Status);
  533. var get = service.GetMultiple(guid => guid.some_text);
  534. Assert.Equal(LuStatus.Success, get.Status);
  535. Assert.Equal(3, get.Data.Count);
  536. Assert.Equal(3, get.Data.Data.Count);
  537. var dbo = get.Data.Data[0];
  538. Assert.Equal(24, dbo.SomeInt);
  539. Assert.Equal("24", dbo.SomeText);
  540. dbo = get.Data.Data[1];
  541. Assert.Equal(42, dbo.SomeInt);
  542. Assert.Equal("42", dbo.SomeText);
  543. dbo = get.Data.Data[2];
  544. Assert.Equal(-1, dbo.SomeInt);
  545. Assert.Equal("442", dbo.SomeText);
  546. });
  547. }
  548. [Fact]
  549. public void TestEditSingle9()
  550. {
  551. Tests.TestRealDb<LuUtilsPkBigSerialDataAccess>(service =>
  552. {
  553. var dbos = new List<PkBigSerialAddDbo>
  554. {
  555. new PkBigSerialAddDbo
  556. {
  557. SomeInt = 42,
  558. SomeText = "442"
  559. },
  560. new PkBigSerialAddDbo
  561. {
  562. SomeInt = 42,
  563. SomeText = "42"
  564. },
  565. new PkBigSerialAddDbo
  566. {
  567. SomeInt = 24,
  568. SomeText = "24"
  569. }
  570. };
  571. var res = service.AddId(dbos);
  572. Assert.Equal(LuStatus.Success, res.Status);
  573. var ids = res.Data.ToList();
  574. dbos[0].SomeInt = -1;
  575. var edit = service.EditSingleByIdDbo(ids[0], dbos[0]);
  576. Assert.Equal(LuStatus.Success, edit.Status);
  577. Assert.Equal(-1, edit.Data.SomeInt);
  578. Assert.Equal("442", edit.Data.SomeText);
  579. var get = service.GetMultiple(guid => guid.some_text);
  580. Assert.Equal(LuStatus.Success, get.Status);
  581. Assert.Equal(3, get.Data.Count);
  582. Assert.Equal(3, get.Data.Data.Count);
  583. var dbo = get.Data.Data[0];
  584. Assert.Equal(24, dbo.SomeInt);
  585. Assert.Equal("24", dbo.SomeText);
  586. dbo = get.Data.Data[1];
  587. Assert.Equal(42, dbo.SomeInt);
  588. Assert.Equal("42", dbo.SomeText);
  589. dbo = get.Data.Data[2];
  590. Assert.Equal(-1, dbo.SomeInt);
  591. Assert.Equal("442", dbo.SomeText);
  592. });
  593. }
  594. [Fact]
  595. public void TestEditSingle10()
  596. {
  597. Tests.TestRealDb<LuUtilsPkGuidDataAccess>(service =>
  598. {
  599. var dbos = new List<PkGuidAddDbo>
  600. {
  601. new PkGuidAddDbo
  602. {
  603. SomeInt = 42,
  604. SomeText = "442"
  605. },
  606. new PkGuidAddDbo
  607. {
  608. SomeInt = 42,
  609. SomeText = "42"
  610. },
  611. new PkGuidAddDbo
  612. {
  613. SomeInt = 24,
  614. SomeText = "24"
  615. }
  616. };
  617. var res = service.AddId(dbos);
  618. Assert.Equal(LuStatus.Success, res.Status);
  619. var ids = res.Data.ToList();
  620. dbos[0].SomeInt = -1;
  621. var edit = service.EditSingleById(ids[0], dbos[0], d => d);
  622. Assert.Equal(LuStatus.Success, edit.Status);
  623. Assert.Equal(-1, edit.Data.SomeInt);
  624. Assert.Equal("442", edit.Data.SomeText);
  625. var get = service.GetMultiple(guid => guid.some_text);
  626. Assert.Equal(LuStatus.Success, get.Status);
  627. Assert.Equal(3, get.Data.Count);
  628. Assert.Equal(3, get.Data.Data.Count);
  629. var dbo = get.Data.Data[0];
  630. Assert.Equal(24, dbo.SomeInt);
  631. Assert.Equal("24", dbo.SomeText);
  632. dbo = get.Data.Data[1];
  633. Assert.Equal(42, dbo.SomeInt);
  634. Assert.Equal("42", dbo.SomeText);
  635. dbo = get.Data.Data[2];
  636. Assert.Equal(-1, dbo.SomeInt);
  637. Assert.Equal("442", dbo.SomeText);
  638. });
  639. }
  640. [Fact]
  641. public void TestEditSingle11()
  642. {
  643. Tests.TestRealDb<LuUtilsPkGuidDataAccess>(service =>
  644. {
  645. var dbos = new List<PkGuidAddDbo>
  646. {
  647. new PkGuidAddDbo
  648. {
  649. SomeInt = 42,
  650. SomeText = "442"
  651. },
  652. new PkGuidAddDbo
  653. {
  654. SomeInt = 42,
  655. SomeText = "42"
  656. },
  657. new PkGuidAddDbo
  658. {
  659. SomeInt = 24,
  660. SomeText = "24"
  661. }
  662. };
  663. var res = service.AddId(dbos);
  664. Assert.Equal(LuStatus.Success, res.Status);
  665. var ids = res.Data.ToList();
  666. dbos[0].SomeInt = -1;
  667. var edit = service.EditSingleByIdId(ids[0], dbos[0]);
  668. Assert.Equal(LuStatus.Success, edit.Status);
  669. var get = service.GetMultiple(guid => guid.some_text);
  670. Assert.Equal(LuStatus.Success, get.Status);
  671. Assert.Equal(3, get.Data.Count);
  672. Assert.Equal(3, get.Data.Data.Count);
  673. var dbo = get.Data.Data[0];
  674. Assert.Equal(24, dbo.SomeInt);
  675. Assert.Equal("24", dbo.SomeText);
  676. dbo = get.Data.Data[1];
  677. Assert.Equal(42, dbo.SomeInt);
  678. Assert.Equal("42", dbo.SomeText);
  679. dbo = get.Data.Data[2];
  680. Assert.Equal(-1, dbo.SomeInt);
  681. Assert.Equal("442", dbo.SomeText);
  682. });
  683. }
  684. [Fact]
  685. public void TestEditSingle12()
  686. {
  687. Tests.TestRealDb<LuUtilsPkGuidDataAccess>(service =>
  688. {
  689. var dbos = new List<PkGuidAddDbo>
  690. {
  691. new PkGuidAddDbo
  692. {
  693. SomeInt = 42,
  694. SomeText = "442"
  695. },
  696. new PkGuidAddDbo
  697. {
  698. SomeInt = 42,
  699. SomeText = "42"
  700. },
  701. new PkGuidAddDbo
  702. {
  703. SomeInt = 24,
  704. SomeText = "24"
  705. }
  706. };
  707. var res = service.AddId(dbos);
  708. Assert.Equal(LuStatus.Success, res.Status);
  709. var ids = res.Data.ToList();
  710. dbos[0].SomeInt = -1;
  711. var edit = service.EditSingleByIdDbo(ids[0], dbos[0]);
  712. Assert.Equal(LuStatus.Success, edit.Status);
  713. Assert.Equal(-1, edit.Data.SomeInt);
  714. Assert.Equal("442", edit.Data.SomeText);
  715. var get = service.GetMultiple(guid => guid.some_text);
  716. Assert.Equal(LuStatus.Success, get.Status);
  717. Assert.Equal(3, get.Data.Count);
  718. Assert.Equal(3, get.Data.Data.Count);
  719. var dbo = get.Data.Data[0];
  720. Assert.Equal(24, dbo.SomeInt);
  721. Assert.Equal("24", dbo.SomeText);
  722. dbo = get.Data.Data[1];
  723. Assert.Equal(42, dbo.SomeInt);
  724. Assert.Equal("42", dbo.SomeText);
  725. dbo = get.Data.Data[2];
  726. Assert.Equal(-1, dbo.SomeInt);
  727. Assert.Equal("442", dbo.SomeText);
  728. });
  729. }
  730. }
  731. }