Explorar el Código

tests; fixed editById overloads

tags/v0.1.0
Robin Thoni hace 8 años
padre
commit
64104e7441

+ 1
- 34
Luticate2.Utils/DataAccess/LuEfCrudDataAccess.cs Ver fichero

@@ -220,12 +220,6 @@ namespace Luticate2.Utils.DataAccess
220 220
                 list => returnFunc(list.FirstOrDefault()));
221 221
         }
222 222
 
223
-        public LuResult<string> EditSingleByIdGuid(long id, Action<TModel> update)
224
-        {
225
-            var func = GetIdFunc<string>();
226
-            return EditSingleById(id, update, func);
227
-        }
228
-
229 223
         public LuResult<long> EditSingleByIdId(long id, Action<TModel> update)
230 224
         {
231 225
             var func = GetIdFunc<long>();
@@ -249,11 +243,6 @@ namespace Luticate2.Utils.DataAccess
249 243
             return EditSingleById(id, update, GetIdFunc<string>());
250 244
         }
251 245
 
252
-        public LuResult<long> EditSingleByIdId(string id, Action<TModel> update)
253
-        {
254
-            return EditSingleById(id, update, GetIdFunc<long>());
255
-        }
256
-
257 246
         public LuResult<TDboRead> EditSingleByIdDbo(string id, Action<TModel> update)
258 247
         {
259 248
             return EditSingleById(id, update, read => read);
@@ -266,11 +255,6 @@ namespace Luticate2.Utils.DataAccess
266 255
                 model => EditModelFromTUpdate(update, model), list => returnFunc(list.FirstOrDefault()));
267 256
         }
268 257
 
269
-        public LuResult<string> EditSingleByIdGuid(long id, TDboUpdate update)
270
-        {
271
-            return EditSingleById(id, update, GetIdFunc<string>());
272
-        }
273
-
274 258
         public LuResult<long> EditSingleByIdId(long id, TDboUpdate update)
275 259
         {
276 260
             return EditSingleById(id, update, GetIdFunc<long>());
@@ -284,7 +268,7 @@ namespace Luticate2.Utils.DataAccess
284 268
 
285 269
         public LuResult<T> EditSingleById<T>(string id, TDboUpdate update, Func<TDboRead, T> returnFunc)
286 270
         {
287
-            return Edit(GetExpression(new KeyValuePair<string, object>("id", id)),
271
+            return Edit(GetExpression(new KeyValuePair<string, object>("id", new Guid(id))),
288 272
                 model => EditModelFromTUpdate(update, model), list => returnFunc(list.FirstOrDefault()));
289 273
         }
290 274
 
@@ -293,11 +277,6 @@ namespace Luticate2.Utils.DataAccess
293 277
             return EditSingleById(id, update, GetIdFunc<string>());
294 278
         }
295 279
 
296
-        public LuResult<long> EditSingleByIdId(string id, TDboUpdate update)
297
-        {
298
-            return EditSingleById(id, update, GetIdFunc<long>());
299
-        }
300
-
301 280
         public LuResult<TDboRead> EditSingleByIdDbo(string id, TDboUpdate update)
302 281
         {
303 282
             return EditSingleById(id, update, read => read);
@@ -349,12 +328,6 @@ namespace Luticate2.Utils.DataAccess
349 328
             return DeleteSingleById(id, func);
350 329
         }
351 330
 
352
-        public LuResult<long> DeleteSingleByIdId(string id)
353
-        {
354
-            var func = GetIdFunc<long>();
355
-            return DeleteSingleById(id, func);
356
-        }
357
-
358 331
         public LuResult<TDboRead> DeleteSingleByIdDbo(string id)
359 332
         {
360 333
             return DeleteSingleById(id, read => read);
@@ -367,12 +340,6 @@ namespace Luticate2.Utils.DataAccess
367 340
                 reads => returnFunc(reads.First()));
368 341
         }
369 342
 
370
-        public LuResult<string> DeleteSingleByGuid(long id)
371
-        {
372
-            var func = GetIdFunc<string>();
373
-            return DeleteSingleById(id, func);
374
-        }
375
-
376 343
         public LuResult<long> DeleteSingleByIdId(long id)
377 344
         {
378 345
             var func = GetIdFunc<long>();

+ 640
- 0
Test/Utils/EfCrubDataAccess/LuEfUpdateDataAccessTest.cs Ver fichero

@@ -219,5 +219,645 @@ namespace Test.Utils.EfCrubDataAccess
219 219
                 Assert.Equal("42", e.SomeText);
220 220
             });
221 221
         }
222
+
223
+        [Fact]
224
+        public void TestEditSingle1()
225
+        {
226
+            Tests.TestRealDb(context =>
227
+            {
228
+                var dbos = new List<PkBigSerialAddDbo>
229
+                {
230
+                    new PkBigSerialAddDbo
231
+                    {
232
+                        SomeInt = 42,
233
+                        SomeText = "442"
234
+                    },
235
+                    new PkBigSerialAddDbo
236
+                    {
237
+                        SomeInt = 42,
238
+                        SomeText = "42"
239
+                    },
240
+                    new PkBigSerialAddDbo
241
+                    {
242
+                        SomeInt = 24,
243
+                        SomeText = "24"
244
+                    }
245
+                };
246
+                var service = new LuUtilsPkBigSerialDataAccess(context);
247
+                var res = service.AddId(dbos);
248
+                Assert.Equal(LuStatus.Success, res.Status);
249
+                var ids = res.Data.ToList();
250
+
251
+                var edit = service.EditSingleById(ids[0], guid => guid.some_int = -1, d => d);
252
+                Assert.Equal(LuStatus.Success, edit.Status);
253
+                Assert.Equal(-1, edit.Data.SomeInt);
254
+                Assert.Equal("442", edit.Data.SomeText);
255
+
256
+                var get = service.GetMultiple(guid => guid.some_text);
257
+
258
+                Assert.Equal(LuStatus.Success, get.Status);
259
+                Assert.Equal(3, get.Data.Count);
260
+                Assert.Equal(3, get.Data.Data.Count);
261
+
262
+                var dbo = get.Data.Data[0];
263
+                Assert.Equal(24, dbo.SomeInt);
264
+                Assert.Equal("24", dbo.SomeText);
265
+
266
+                dbo = get.Data.Data[1];
267
+                Assert.Equal(42, dbo.SomeInt);
268
+                Assert.Equal("42", dbo.SomeText);
269
+
270
+                dbo = get.Data.Data[2];
271
+                Assert.Equal(-1, dbo.SomeInt);
272
+                Assert.Equal("442", dbo.SomeText);
273
+            });
274
+        }
275
+
276
+        [Fact]
277
+        public void TestEditSingle2()
278
+        {
279
+            Tests.TestRealDb(context =>
280
+            {
281
+                var dbos = new List<PkBigSerialAddDbo>
282
+                {
283
+                    new PkBigSerialAddDbo
284
+                    {
285
+                        SomeInt = 42,
286
+                        SomeText = "442"
287
+                    },
288
+                    new PkBigSerialAddDbo
289
+                    {
290
+                        SomeInt = 42,
291
+                        SomeText = "42"
292
+                    },
293
+                    new PkBigSerialAddDbo
294
+                    {
295
+                        SomeInt = 24,
296
+                        SomeText = "24"
297
+                    }
298
+                };
299
+                var service = new LuUtilsPkBigSerialDataAccess(context);
300
+                var res = service.AddId(dbos);
301
+                Assert.Equal(LuStatus.Success, res.Status);
302
+                var ids = res.Data.ToList();
303
+
304
+                var edit = service.EditSingleByIdId(ids[0], guid => guid.some_int = -1);
305
+                Assert.Equal(LuStatus.Success, edit.Status);
306
+
307
+                var get = service.GetMultiple(guid => guid.some_text);
308
+
309
+                Assert.Equal(LuStatus.Success, get.Status);
310
+                Assert.Equal(3, get.Data.Count);
311
+                Assert.Equal(3, get.Data.Data.Count);
312
+
313
+                var dbo = get.Data.Data[0];
314
+                Assert.Equal(24, dbo.SomeInt);
315
+                Assert.Equal("24", dbo.SomeText);
316
+
317
+                dbo = get.Data.Data[1];
318
+                Assert.Equal(42, dbo.SomeInt);
319
+                Assert.Equal("42", dbo.SomeText);
320
+
321
+                dbo = get.Data.Data[2];
322
+                Assert.Equal(-1, dbo.SomeInt);
323
+                Assert.Equal("442", dbo.SomeText);
324
+            });
325
+        }
326
+
327
+        [Fact]
328
+        public void TestEditSingle3()
329
+        {
330
+            Tests.TestRealDb(context =>
331
+            {
332
+                var dbos = new List<PkBigSerialAddDbo>
333
+                {
334
+                    new PkBigSerialAddDbo
335
+                    {
336
+                        SomeInt = 42,
337
+                        SomeText = "442"
338
+                    },
339
+                    new PkBigSerialAddDbo
340
+                    {
341
+                        SomeInt = 42,
342
+                        SomeText = "42"
343
+                    },
344
+                    new PkBigSerialAddDbo
345
+                    {
346
+                        SomeInt = 24,
347
+                        SomeText = "24"
348
+                    }
349
+                };
350
+                var service = new LuUtilsPkBigSerialDataAccess(context);
351
+                var res = service.AddId(dbos);
352
+                Assert.Equal(LuStatus.Success, res.Status);
353
+                var ids = res.Data.ToList();
354
+
355
+                var edit = service.EditSingleByIdDbo(ids[0], guid => guid.some_int = -1);
356
+                Assert.Equal(LuStatus.Success, edit.Status);
357
+                Assert.Equal(-1, edit.Data.SomeInt);
358
+                Assert.Equal("442", edit.Data.SomeText);
359
+
360
+                var get = service.GetMultiple(guid => guid.some_text);
361
+
362
+                Assert.Equal(LuStatus.Success, get.Status);
363
+                Assert.Equal(3, get.Data.Count);
364
+                Assert.Equal(3, get.Data.Data.Count);
365
+
366
+                var dbo = get.Data.Data[0];
367
+                Assert.Equal(24, dbo.SomeInt);
368
+                Assert.Equal("24", dbo.SomeText);
369
+
370
+                dbo = get.Data.Data[1];
371
+                Assert.Equal(42, dbo.SomeInt);
372
+                Assert.Equal("42", dbo.SomeText);
373
+
374
+                dbo = get.Data.Data[2];
375
+                Assert.Equal(-1, dbo.SomeInt);
376
+                Assert.Equal("442", dbo.SomeText);
377
+            });
378
+        }
379
+
380
+        [Fact]
381
+        public void TestEditSingle4()
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
+
408
+                var edit = service.EditSingleById(ids[0], guid => guid.some_int = -1, d => d);
409
+                Assert.Equal(LuStatus.Success, edit.Status);
410
+                Assert.Equal(-1, edit.Data.SomeInt);
411
+                Assert.Equal("442", edit.Data.SomeText);
412
+
413
+                var get = service.GetMultiple(guid => guid.some_text);
414
+
415
+                Assert.Equal(LuStatus.Success, get.Status);
416
+                Assert.Equal(3, get.Data.Count);
417
+                Assert.Equal(3, get.Data.Data.Count);
418
+
419
+                var dbo = get.Data.Data[0];
420
+                Assert.Equal(24, dbo.SomeInt);
421
+                Assert.Equal("24", dbo.SomeText);
422
+
423
+                dbo = get.Data.Data[1];
424
+                Assert.Equal(42, dbo.SomeInt);
425
+                Assert.Equal("42", dbo.SomeText);
426
+
427
+                dbo = get.Data.Data[2];
428
+                Assert.Equal(-1, dbo.SomeInt);
429
+                Assert.Equal("442", dbo.SomeText);
430
+            });
431
+        }
432
+
433
+        [Fact]
434
+        public void TestEditSingle5()
435
+        {
436
+            Tests.TestRealDb(context =>
437
+            {
438
+                var dbos = new List<PkGuidAddDbo>
439
+                {
440
+                    new PkGuidAddDbo
441
+                    {
442
+                        SomeInt = 42,
443
+                        SomeText = "442"
444
+                    },
445
+                    new PkGuidAddDbo
446
+                    {
447
+                        SomeInt = 42,
448
+                        SomeText = "42"
449
+                    },
450
+                    new PkGuidAddDbo
451
+                    {
452
+                        SomeInt = 24,
453
+                        SomeText = "24"
454
+                    }
455
+                };
456
+                var service = new LuUtilsPkGuidDataAccess(context);
457
+                var res = service.AddGuid(dbos);
458
+                Assert.Equal(LuStatus.Success, res.Status);
459
+                var ids = res.Data.ToList();
460
+
461
+                var edit = service.EditSingleByIdGuid(ids[0], guid => guid.some_int = -1);
462
+                Assert.Equal(LuStatus.Success, edit.Status);
463
+
464
+                var get = service.GetMultiple(guid => guid.some_text);
465
+
466
+                Assert.Equal(LuStatus.Success, get.Status);
467
+                Assert.Equal(3, get.Data.Count);
468
+                Assert.Equal(3, get.Data.Data.Count);
469
+
470
+                var dbo = get.Data.Data[0];
471
+                Assert.Equal(24, dbo.SomeInt);
472
+                Assert.Equal("24", dbo.SomeText);
473
+
474
+                dbo = get.Data.Data[1];
475
+                Assert.Equal(42, dbo.SomeInt);
476
+                Assert.Equal("42", dbo.SomeText);
477
+
478
+                dbo = get.Data.Data[2];
479
+                Assert.Equal(-1, dbo.SomeInt);
480
+                Assert.Equal("442", dbo.SomeText);
481
+            });
482
+        }
483
+
484
+        [Fact]
485
+        public void TestEditSingle6()
486
+        {
487
+            Tests.TestRealDb(context =>
488
+            {
489
+                var dbos = new List<PkGuidAddDbo>
490
+                {
491
+                    new PkGuidAddDbo
492
+                    {
493
+                        SomeInt = 42,
494
+                        SomeText = "442"
495
+                    },
496
+                    new PkGuidAddDbo
497
+                    {
498
+                        SomeInt = 42,
499
+                        SomeText = "42"
500
+                    },
501
+                    new PkGuidAddDbo
502
+                    {
503
+                        SomeInt = 24,
504
+                        SomeText = "24"
505
+                    }
506
+                };
507
+                var service = new LuUtilsPkGuidDataAccess(context);
508
+                var res = service.AddGuid(dbos);
509
+                Assert.Equal(LuStatus.Success, res.Status);
510
+                var ids = res.Data.ToList();
511
+
512
+                var edit = service.EditSingleByIdDbo(ids[0], guid => guid.some_int = -1);
513
+                Assert.Equal(LuStatus.Success, edit.Status);
514
+                Assert.Equal(-1, edit.Data.SomeInt);
515
+                Assert.Equal("442", edit.Data.SomeText);
516
+
517
+                var get = service.GetMultiple(guid => guid.some_text);
518
+
519
+                Assert.Equal(LuStatus.Success, get.Status);
520
+                Assert.Equal(3, get.Data.Count);
521
+                Assert.Equal(3, get.Data.Data.Count);
522
+
523
+                var dbo = get.Data.Data[0];
524
+                Assert.Equal(24, dbo.SomeInt);
525
+                Assert.Equal("24", dbo.SomeText);
526
+
527
+                dbo = get.Data.Data[1];
528
+                Assert.Equal(42, dbo.SomeInt);
529
+                Assert.Equal("42", dbo.SomeText);
530
+
531
+                dbo = get.Data.Data[2];
532
+                Assert.Equal(-1, dbo.SomeInt);
533
+                Assert.Equal("442", dbo.SomeText);
534
+            });
535
+        }
536
+
537
+        [Fact]
538
+        public void TestEditSingle7()
539
+        {
540
+            Tests.TestRealDb(context =>
541
+            {
542
+                var dbos = new List<PkBigSerialAddDbo>
543
+                {
544
+                    new PkBigSerialAddDbo
545
+                    {
546
+                        SomeInt = 42,
547
+                        SomeText = "442"
548
+                    },
549
+                    new PkBigSerialAddDbo
550
+                    {
551
+                        SomeInt = 42,
552
+                        SomeText = "42"
553
+                    },
554
+                    new PkBigSerialAddDbo
555
+                    {
556
+                        SomeInt = 24,
557
+                        SomeText = "24"
558
+                    }
559
+                };
560
+                var service = new LuUtilsPkBigSerialDataAccess(context);
561
+                var res = service.AddId(dbos);
562
+                Assert.Equal(LuStatus.Success, res.Status);
563
+                var ids = res.Data.ToList();
564
+
565
+                dbos[0].SomeInt = -1;
566
+
567
+                var edit = service.EditSingleById(ids[0], dbos[0], d => d);
568
+                Assert.Equal(LuStatus.Success, edit.Status);
569
+                Assert.Equal(-1, edit.Data.SomeInt);
570
+                Assert.Equal("442", edit.Data.SomeText);
571
+
572
+                var get = service.GetMultiple(guid => guid.some_text);
573
+
574
+                Assert.Equal(LuStatus.Success, get.Status);
575
+                Assert.Equal(3, get.Data.Count);
576
+                Assert.Equal(3, get.Data.Data.Count);
577
+
578
+                var dbo = get.Data.Data[0];
579
+                Assert.Equal(24, dbo.SomeInt);
580
+                Assert.Equal("24", dbo.SomeText);
581
+
582
+                dbo = get.Data.Data[1];
583
+                Assert.Equal(42, dbo.SomeInt);
584
+                Assert.Equal("42", dbo.SomeText);
585
+
586
+                dbo = get.Data.Data[2];
587
+                Assert.Equal(-1, dbo.SomeInt);
588
+                Assert.Equal("442", dbo.SomeText);
589
+            });
590
+        }
591
+
592
+        [Fact]
593
+        public void TestEditSingle8()
594
+        {
595
+            Tests.TestRealDb(context =>
596
+            {
597
+                var dbos = new List<PkBigSerialAddDbo>
598
+                {
599
+                    new PkBigSerialAddDbo
600
+                    {
601
+                        SomeInt = 42,
602
+                        SomeText = "442"
603
+                    },
604
+                    new PkBigSerialAddDbo
605
+                    {
606
+                        SomeInt = 42,
607
+                        SomeText = "42"
608
+                    },
609
+                    new PkBigSerialAddDbo
610
+                    {
611
+                        SomeInt = 24,
612
+                        SomeText = "24"
613
+                    }
614
+                };
615
+                var service = new LuUtilsPkBigSerialDataAccess(context);
616
+                var res = service.AddId(dbos);
617
+                Assert.Equal(LuStatus.Success, res.Status);
618
+                var ids = res.Data.ToList();
619
+
620
+                dbos[0].SomeInt = -1;
621
+
622
+                var edit = service.EditSingleByIdId(ids[0], dbos[0]);
623
+                Assert.Equal(LuStatus.Success, edit.Status);
624
+
625
+                var get = service.GetMultiple(guid => guid.some_text);
626
+
627
+                Assert.Equal(LuStatus.Success, get.Status);
628
+                Assert.Equal(3, get.Data.Count);
629
+                Assert.Equal(3, get.Data.Data.Count);
630
+
631
+                var dbo = get.Data.Data[0];
632
+                Assert.Equal(24, dbo.SomeInt);
633
+                Assert.Equal("24", dbo.SomeText);
634
+
635
+                dbo = get.Data.Data[1];
636
+                Assert.Equal(42, dbo.SomeInt);
637
+                Assert.Equal("42", dbo.SomeText);
638
+
639
+                dbo = get.Data.Data[2];
640
+                Assert.Equal(-1, dbo.SomeInt);
641
+                Assert.Equal("442", dbo.SomeText);
642
+            });
643
+        }
644
+
645
+        [Fact]
646
+        public void TestEditSingle9()
647
+        {
648
+            Tests.TestRealDb(context =>
649
+            {
650
+                var dbos = new List<PkBigSerialAddDbo>
651
+                {
652
+                    new PkBigSerialAddDbo
653
+                    {
654
+                        SomeInt = 42,
655
+                        SomeText = "442"
656
+                    },
657
+                    new PkBigSerialAddDbo
658
+                    {
659
+                        SomeInt = 42,
660
+                        SomeText = "42"
661
+                    },
662
+                    new PkBigSerialAddDbo
663
+                    {
664
+                        SomeInt = 24,
665
+                        SomeText = "24"
666
+                    }
667
+                };
668
+                var service = new LuUtilsPkBigSerialDataAccess(context);
669
+                var res = service.AddId(dbos);
670
+                Assert.Equal(LuStatus.Success, res.Status);
671
+                var ids = res.Data.ToList();
672
+
673
+                dbos[0].SomeInt = -1;
674
+
675
+                var edit = service.EditSingleByIdDbo(ids[0], dbos[0]);
676
+                Assert.Equal(LuStatus.Success, edit.Status);
677
+                Assert.Equal(-1, edit.Data.SomeInt);
678
+                Assert.Equal("442", edit.Data.SomeText);
679
+
680
+                var get = service.GetMultiple(guid => guid.some_text);
681
+
682
+                Assert.Equal(LuStatus.Success, get.Status);
683
+                Assert.Equal(3, get.Data.Count);
684
+                Assert.Equal(3, get.Data.Data.Count);
685
+
686
+                var dbo = get.Data.Data[0];
687
+                Assert.Equal(24, dbo.SomeInt);
688
+                Assert.Equal("24", dbo.SomeText);
689
+
690
+                dbo = get.Data.Data[1];
691
+                Assert.Equal(42, dbo.SomeInt);
692
+                Assert.Equal("42", dbo.SomeText);
693
+
694
+                dbo = get.Data.Data[2];
695
+                Assert.Equal(-1, dbo.SomeInt);
696
+                Assert.Equal("442", dbo.SomeText);
697
+            });
698
+        }
699
+
700
+        [Fact]
701
+        public void TestEditSingle10()
702
+        {
703
+            Tests.TestRealDb(context =>
704
+            {
705
+                var dbos = new List<PkGuidAddDbo>
706
+                {
707
+                    new PkGuidAddDbo
708
+                    {
709
+                        SomeInt = 42,
710
+                        SomeText = "442"
711
+                    },
712
+                    new PkGuidAddDbo
713
+                    {
714
+                        SomeInt = 42,
715
+                        SomeText = "42"
716
+                    },
717
+                    new PkGuidAddDbo
718
+                    {
719
+                        SomeInt = 24,
720
+                        SomeText = "24"
721
+                    }
722
+                };
723
+                var service = new LuUtilsPkGuidDataAccess(context);
724
+                var res = service.AddGuid(dbos);
725
+                Assert.Equal(LuStatus.Success, res.Status);
726
+                var ids = res.Data.ToList();
727
+
728
+                dbos[0].SomeInt = -1;
729
+
730
+                var edit = service.EditSingleById(ids[0], dbos[0], d => d);
731
+                Assert.Equal(LuStatus.Success, edit.Status);
732
+                Assert.Equal(-1, edit.Data.SomeInt);
733
+                Assert.Equal("442", edit.Data.SomeText);
734
+
735
+                var get = service.GetMultiple(guid => guid.some_text);
736
+
737
+                Assert.Equal(LuStatus.Success, get.Status);
738
+                Assert.Equal(3, get.Data.Count);
739
+                Assert.Equal(3, get.Data.Data.Count);
740
+
741
+                var dbo = get.Data.Data[0];
742
+                Assert.Equal(24, dbo.SomeInt);
743
+                Assert.Equal("24", dbo.SomeText);
744
+
745
+                dbo = get.Data.Data[1];
746
+                Assert.Equal(42, dbo.SomeInt);
747
+                Assert.Equal("42", dbo.SomeText);
748
+
749
+                dbo = get.Data.Data[2];
750
+                Assert.Equal(-1, dbo.SomeInt);
751
+                Assert.Equal("442", dbo.SomeText);
752
+            });
753
+        }
754
+
755
+        [Fact]
756
+        public void TestEditSingle11()
757
+        {
758
+            Tests.TestRealDb(context =>
759
+            {
760
+                var dbos = new List<PkGuidAddDbo>
761
+                {
762
+                    new PkGuidAddDbo
763
+                    {
764
+                        SomeInt = 42,
765
+                        SomeText = "442"
766
+                    },
767
+                    new PkGuidAddDbo
768
+                    {
769
+                        SomeInt = 42,
770
+                        SomeText = "42"
771
+                    },
772
+                    new PkGuidAddDbo
773
+                    {
774
+                        SomeInt = 24,
775
+                        SomeText = "24"
776
+                    }
777
+                };
778
+                var service = new LuUtilsPkGuidDataAccess(context);
779
+                var res = service.AddGuid(dbos);
780
+                Assert.Equal(LuStatus.Success, res.Status);
781
+                var ids = res.Data.ToList();
782
+
783
+                dbos[0].SomeInt = -1;
784
+
785
+                var edit = service.EditSingleByIdGuid(ids[0], dbos[0]);
786
+                Assert.Equal(LuStatus.Success, edit.Status);
787
+
788
+                var get = service.GetMultiple(guid => guid.some_text);
789
+
790
+                Assert.Equal(LuStatus.Success, get.Status);
791
+                Assert.Equal(3, get.Data.Count);
792
+                Assert.Equal(3, get.Data.Data.Count);
793
+
794
+                var dbo = get.Data.Data[0];
795
+                Assert.Equal(24, dbo.SomeInt);
796
+                Assert.Equal("24", dbo.SomeText);
797
+
798
+                dbo = get.Data.Data[1];
799
+                Assert.Equal(42, dbo.SomeInt);
800
+                Assert.Equal("42", dbo.SomeText);
801
+
802
+                dbo = get.Data.Data[2];
803
+                Assert.Equal(-1, dbo.SomeInt);
804
+                Assert.Equal("442", dbo.SomeText);
805
+            });
806
+        }
807
+
808
+        [Fact]
809
+        public void TestEditSingle12()
810
+        {
811
+            Tests.TestRealDb(context =>
812
+            {
813
+                var dbos = new List<PkGuidAddDbo>
814
+                {
815
+                    new PkGuidAddDbo
816
+                    {
817
+                        SomeInt = 42,
818
+                        SomeText = "442"
819
+                    },
820
+                    new PkGuidAddDbo
821
+                    {
822
+                        SomeInt = 42,
823
+                        SomeText = "42"
824
+                    },
825
+                    new PkGuidAddDbo
826
+                    {
827
+                        SomeInt = 24,
828
+                        SomeText = "24"
829
+                    }
830
+                };
831
+                var service = new LuUtilsPkGuidDataAccess(context);
832
+                var res = service.AddGuid(dbos);
833
+                Assert.Equal(LuStatus.Success, res.Status);
834
+                var ids = res.Data.ToList();
835
+
836
+                dbos[0].SomeInt = -1;
837
+
838
+                var edit = service.EditSingleByIdDbo(ids[0], dbos[0]);
839
+                Assert.Equal(LuStatus.Success, edit.Status);
840
+                Assert.Equal(-1, edit.Data.SomeInt);
841
+                Assert.Equal("442", edit.Data.SomeText);
842
+
843
+                var get = service.GetMultiple(guid => guid.some_text);
844
+
845
+                Assert.Equal(LuStatus.Success, get.Status);
846
+                Assert.Equal(3, get.Data.Count);
847
+                Assert.Equal(3, get.Data.Data.Count);
848
+
849
+                var dbo = get.Data.Data[0];
850
+                Assert.Equal(24, dbo.SomeInt);
851
+                Assert.Equal("24", dbo.SomeText);
852
+
853
+                dbo = get.Data.Data[1];
854
+                Assert.Equal(42, dbo.SomeInt);
855
+                Assert.Equal("42", dbo.SomeText);
856
+
857
+                dbo = get.Data.Data[2];
858
+                Assert.Equal(-1, dbo.SomeInt);
859
+                Assert.Equal("442", dbo.SomeText);
860
+            });
861
+        }
222 862
     }
223 863
 }

Loading…
Cancelar
Guardar