Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

LuEfUpdateDataAccessTest.cs 29KB

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