|
@@ -1,7 +1,9 @@
|
1
|
1
|
using System;
|
2
|
2
|
using System.Collections.Generic;
|
|
3
|
+using System.Diagnostics;
|
3
|
4
|
using System.Linq;
|
4
|
5
|
using Luticate2.Utils.Dbo;
|
|
6
|
+using Microsoft.AspNetCore.Mvc.Controllers;
|
5
|
7
|
using Test.Utils.DataAccess;
|
6
|
8
|
using Test.Utils.Dbo.PkBigSerial;
|
7
|
9
|
using Test.Utils.Dbo.PkGuid;
|
|
@@ -115,6 +117,30 @@ namespace Test.Utils.EfCrubDataAccess
|
115
|
117
|
});
|
116
|
118
|
}
|
117
|
119
|
|
|
120
|
+ [Fact]
|
|
121
|
+ public void TestAddMultiple4()
|
|
122
|
+ {
|
|
123
|
+ Tests.TestRealDb(context =>
|
|
124
|
+ {
|
|
125
|
+ var dbos = new List<PkBigSerialAddDbo>
|
|
126
|
+ {
|
|
127
|
+ new PkBigSerialAddDbo
|
|
128
|
+ {
|
|
129
|
+ SomeInt = 42,
|
|
130
|
+ SomeText = "42"
|
|
131
|
+ },
|
|
132
|
+ new PkBigSerialAddDbo
|
|
133
|
+ {
|
|
134
|
+ SomeInt = 21,
|
|
135
|
+ SomeText = "42"
|
|
136
|
+ }
|
|
137
|
+ };
|
|
138
|
+ var service = new LuUtilsPkBigSerialDataAccess(context);
|
|
139
|
+ var res = service.Add(dbos, enumerable => enumerable.Select(dbo => dbo.CreatedAt));
|
|
140
|
+ Assert.Equal(LuStatus.DbError, res.Status);
|
|
141
|
+ });
|
|
142
|
+ }
|
|
143
|
+
|
118
|
144
|
|
119
|
145
|
[Fact]
|
120
|
146
|
public void TestAddSingle1()
|
|
@@ -523,5 +549,188 @@ namespace Test.Utils.EfCrubDataAccess
|
523
|
549
|
Assert.Equal(LuStatus.NotFound, get.Status);
|
524
|
550
|
});
|
525
|
551
|
}
|
|
552
|
+
|
|
553
|
+ [Fact]
|
|
554
|
+ public void TestGetMultiple1()
|
|
555
|
+ {
|
|
556
|
+ Tests.TestRealDb(context =>
|
|
557
|
+ {
|
|
558
|
+ var dbos = new List<PkGuidAddDbo>
|
|
559
|
+ {
|
|
560
|
+ new PkGuidAddDbo
|
|
561
|
+ {
|
|
562
|
+ SomeInt = 42,
|
|
563
|
+ SomeText = "442"
|
|
564
|
+ },
|
|
565
|
+ new PkGuidAddDbo
|
|
566
|
+ {
|
|
567
|
+ SomeInt = 42,
|
|
568
|
+ SomeText = "42"
|
|
569
|
+ },
|
|
570
|
+ new PkGuidAddDbo
|
|
571
|
+ {
|
|
572
|
+ SomeInt = 24,
|
|
573
|
+ SomeText = "24"
|
|
574
|
+ }
|
|
575
|
+ };
|
|
576
|
+ var service = new LuUtilsPkGuidDataAccess(context);
|
|
577
|
+ var res = service.AddGuid(dbos);
|
|
578
|
+ Assert.Equal(LuStatus.Success, res.Status);
|
|
579
|
+
|
|
580
|
+ var get = service.GetMultiple(table => table.OrderBy(guid => guid.some_int),
|
|
581
|
+ guid => guid.some_int == 42, 0, int.MaxValue, set => set.OrderBy(guid => guid.some_text));
|
|
582
|
+
|
|
583
|
+ Assert.Equal(LuStatus.Success, get.Status);
|
|
584
|
+ Assert.Equal(2, get.Data.Count);
|
|
585
|
+ Assert.Equal(2, get.Data.Data.Count);
|
|
586
|
+
|
|
587
|
+ var dbo = get.Data.Data[0];
|
|
588
|
+ Assert.Equal(42, dbo.SomeInt);
|
|
589
|
+ Assert.Equal("42", dbo.SomeText);
|
|
590
|
+
|
|
591
|
+ dbo = get.Data.Data[1];
|
|
592
|
+ Assert.Equal(42, dbo.SomeInt);
|
|
593
|
+ Assert.Equal("442", dbo.SomeText);
|
|
594
|
+ });
|
|
595
|
+ }
|
|
596
|
+
|
|
597
|
+ [Fact]
|
|
598
|
+ public void TestGetMultiple2()
|
|
599
|
+ {
|
|
600
|
+ Tests.TestRealDb(context =>
|
|
601
|
+ {
|
|
602
|
+ var dbos = new List<PkGuidAddDbo>
|
|
603
|
+ {
|
|
604
|
+ new PkGuidAddDbo
|
|
605
|
+ {
|
|
606
|
+ SomeInt = 42,
|
|
607
|
+ SomeText = "442"
|
|
608
|
+ },
|
|
609
|
+ new PkGuidAddDbo
|
|
610
|
+ {
|
|
611
|
+ SomeInt = 42,
|
|
612
|
+ SomeText = "42"
|
|
613
|
+ },
|
|
614
|
+ new PkGuidAddDbo
|
|
615
|
+ {
|
|
616
|
+ SomeInt = 24,
|
|
617
|
+ SomeText = "24"
|
|
618
|
+ }
|
|
619
|
+ };
|
|
620
|
+ var service = new LuUtilsPkGuidDataAccess(context);
|
|
621
|
+ var res = service.AddGuid(dbos);
|
|
622
|
+ Assert.Equal(LuStatus.Success, res.Status);
|
|
623
|
+
|
|
624
|
+ var get = service.GetMultiple(guid => guid.some_int, guid => guid.some_int == 42, 0, int.MaxValue,
|
|
625
|
+ guid => guid.some_text);
|
|
626
|
+
|
|
627
|
+ Assert.Equal(LuStatus.Success, get.Status);
|
|
628
|
+ Assert.Equal(2, get.Data.Count);
|
|
629
|
+ Assert.Equal(2, get.Data.Data.Count);
|
|
630
|
+
|
|
631
|
+ var dbo = get.Data.Data[0];
|
|
632
|
+ Assert.Equal(42, dbo.SomeInt);
|
|
633
|
+ Assert.Equal("42", dbo.SomeText);
|
|
634
|
+
|
|
635
|
+ dbo = get.Data.Data[1];
|
|
636
|
+ Assert.Equal(42, dbo.SomeInt);
|
|
637
|
+ Assert.Equal("442", dbo.SomeText);
|
|
638
|
+ });
|
|
639
|
+ }
|
|
640
|
+
|
|
641
|
+ [Fact]
|
|
642
|
+ public void TestGetMultiple3()
|
|
643
|
+ {
|
|
644
|
+ Tests.TestRealDb(context =>
|
|
645
|
+ {
|
|
646
|
+ var dbos = new List<PkGuidAddDbo>
|
|
647
|
+ {
|
|
648
|
+ new PkGuidAddDbo
|
|
649
|
+ {
|
|
650
|
+ SomeInt = 42,
|
|
651
|
+ SomeText = "442"
|
|
652
|
+ },
|
|
653
|
+ new PkGuidAddDbo
|
|
654
|
+ {
|
|
655
|
+ SomeInt = 42,
|
|
656
|
+ SomeText = "42"
|
|
657
|
+ },
|
|
658
|
+ new PkGuidAddDbo
|
|
659
|
+ {
|
|
660
|
+ SomeInt = 24,
|
|
661
|
+ SomeText = "24"
|
|
662
|
+ }
|
|
663
|
+ };
|
|
664
|
+ var service = new LuUtilsPkGuidDataAccess(context);
|
|
665
|
+ var res = service.AddGuid(dbos);
|
|
666
|
+ Assert.Equal(LuStatus.Success, res.Status);
|
|
667
|
+
|
|
668
|
+ var get = service.GetMultiple(table => table.OrderBy(guid => guid.some_int), 0, int.MaxValue,
|
|
669
|
+ set => set.OrderBy(guid => guid.some_text));
|
|
670
|
+
|
|
671
|
+ Assert.Equal(LuStatus.Success, get.Status);
|
|
672
|
+ Assert.Equal(3, get.Data.Count);
|
|
673
|
+ Assert.Equal(3, get.Data.Data.Count);
|
|
674
|
+
|
|
675
|
+ var dbo = get.Data.Data[0];
|
|
676
|
+ Assert.Equal(24, dbo.SomeInt);
|
|
677
|
+ Assert.Equal("24", dbo.SomeText);
|
|
678
|
+
|
|
679
|
+ dbo = get.Data.Data[1];
|
|
680
|
+ Assert.Equal(42, dbo.SomeInt);
|
|
681
|
+ Assert.Equal("42", dbo.SomeText);
|
|
682
|
+
|
|
683
|
+ dbo = get.Data.Data[2];
|
|
684
|
+ Assert.Equal(42, dbo.SomeInt);
|
|
685
|
+ Assert.Equal("442", dbo.SomeText);
|
|
686
|
+ });
|
|
687
|
+ }
|
|
688
|
+
|
|
689
|
+ [Fact]
|
|
690
|
+ public void TestGetMultiple4()
|
|
691
|
+ {
|
|
692
|
+ Tests.TestRealDb(context =>
|
|
693
|
+ {
|
|
694
|
+ var dbos = new List<PkGuidAddDbo>
|
|
695
|
+ {
|
|
696
|
+ new PkGuidAddDbo
|
|
697
|
+ {
|
|
698
|
+ SomeInt = 42,
|
|
699
|
+ SomeText = "442"
|
|
700
|
+ },
|
|
701
|
+ new PkGuidAddDbo
|
|
702
|
+ {
|
|
703
|
+ SomeInt = 42,
|
|
704
|
+ SomeText = "42"
|
|
705
|
+ },
|
|
706
|
+ new PkGuidAddDbo
|
|
707
|
+ {
|
|
708
|
+ SomeInt = 24,
|
|
709
|
+ SomeText = "24"
|
|
710
|
+ }
|
|
711
|
+ };
|
|
712
|
+ var service = new LuUtilsPkGuidDataAccess(context);
|
|
713
|
+ var res = service.AddGuid(dbos);
|
|
714
|
+ Assert.Equal(LuStatus.Success, res.Status);
|
|
715
|
+
|
|
716
|
+ var get = service.GetMultiple(guid => guid.some_int, 0, int.MaxValue, guid => guid.some_text);
|
|
717
|
+
|
|
718
|
+ Assert.Equal(LuStatus.Success, get.Status);
|
|
719
|
+ Assert.Equal(3, get.Data.Count);
|
|
720
|
+ Assert.Equal(3, get.Data.Data.Count);
|
|
721
|
+
|
|
722
|
+ var dbo = get.Data.Data[0];
|
|
723
|
+ Assert.Equal(24, dbo.SomeInt);
|
|
724
|
+ Assert.Equal("24", dbo.SomeText);
|
|
725
|
+
|
|
726
|
+ dbo = get.Data.Data[1];
|
|
727
|
+ Assert.Equal(42, dbo.SomeInt);
|
|
728
|
+ Assert.Equal("42", dbo.SomeText);
|
|
729
|
+
|
|
730
|
+ dbo = get.Data.Data[2];
|
|
731
|
+ Assert.Equal(42, dbo.SomeInt);
|
|
732
|
+ Assert.Equal("442", dbo.SomeText);
|
|
733
|
+ });
|
|
734
|
+ }
|
526
|
735
|
}
|
527
|
736
|
}
|