@@ -55,7 +55,7 @@ public interface IPersonTable : IRelation<Person>
55
55
public Task VerifyCannotUsePrimaryKeyTogetherWithInKeyValue ( )
56
56
{
57
57
// language=cs
58
- return VerifySourceGenerator ( @ "
58
+ return VerifySourceGenerator ( "" "
59
59
using BTDB.ODBLayer;
60
60
61
61
namespace TestNamespace;
@@ -69,6 +69,125 @@ public class Person
69
69
public interface IPersonTable : IRelation<Person>
70
70
{
71
71
}
72
- " ) ;
72
+
73
+ """ ) ;
74
+ }
75
+
76
+ [ Fact ]
77
+ public Task VerifyThatSecondaryKeyCannotBeNamedId ( )
78
+ {
79
+ // language=cs
80
+ return VerifySourceGenerator ( """
81
+ using BTDB.ODBLayer;
82
+
83
+ namespace TestNamespace;
84
+
85
+ public class Person
86
+ {
87
+ [PrimaryKey(1)] public int Id { get; set; }
88
+ [SecondaryKey("Id")] public string Name { get; set; } = null!;
89
+ }
90
+
91
+ public interface IPersonTable : IRelation<Person>
92
+ {
93
+ }
94
+
95
+ """ ) ;
96
+ }
97
+
98
+ [ Fact ]
99
+ public Task VerifyThatInKeyValueCannotBeAlsoSecondaryKey ( )
100
+ {
101
+ // language=cs
102
+ return VerifySourceGenerator ( """
103
+ using BTDB.ODBLayer;
104
+
105
+ namespace TestNamespace;
106
+
107
+ public class Person
108
+ {
109
+ [PrimaryKey(1)]
110
+ public int Id { get; set; }
111
+ [SecondaryKey("Name")]
112
+ [InKeyValue(2)]
113
+ public string Name { get; set; } = null!;
114
+ }
115
+
116
+ public interface IPersonTable : IRelation<Person>
117
+ {
118
+ }
119
+
120
+ """ ) ;
121
+ }
122
+
123
+ [ Fact ]
124
+ public Task VerifyThatInKeyValueCannotBeBeforePrimaryKey ( )
125
+ {
126
+ // language=cs
127
+ return VerifySourceGenerator ( """
128
+ using BTDB.ODBLayer;
129
+
130
+ namespace TestNamespace;
131
+
132
+ public class Person
133
+ {
134
+ [InKeyValue(1)]
135
+ public int InKeyValue { get; set; }
136
+ [PrimaryKey(2)]
137
+ public int PrimaryKey { get; set; }
138
+ }
139
+ public interface IPersonTable : IRelation<Person>
140
+ {
141
+ }
142
+
143
+ """ ) ;
144
+ }
145
+
146
+ [ Fact ]
147
+ public Task VerifyThatTwoPrimaryKeysCannotHaveSameOrder ( )
148
+ {
149
+ // language=cs
150
+ return VerifySourceGenerator ( """
151
+ using BTDB.ODBLayer;
152
+
153
+ namespace TestNamespace;
154
+
155
+ public class Person
156
+ {
157
+ [PrimaryKey(1)]
158
+ public int P1 { get; set; }
159
+ [PrimaryKey(1)]
160
+ public int P1Also { get; set; }
161
+ }
162
+ public interface IPersonTable : IRelation<Person>
163
+ {
164
+ }
165
+
166
+ """ ) ;
167
+ }
168
+
169
+ [ Fact ]
170
+ public Task VerifyThatTwoSecondaryKeysCannotHaveSameOrder ( )
171
+ {
172
+ // language=cs
173
+ return VerifySourceGenerator ( """
174
+ using BTDB.ODBLayer;
175
+
176
+ namespace TestNamespace;
177
+
178
+ public class Person
179
+ {
180
+ [PrimaryKey(1)]
181
+ public int P1 { get; set; }
182
+ [SecondaryKey("SK", Order = 1)]
183
+ public int S1 { get; set; }
184
+ [SecondaryKey("SK", Order = 1)]
185
+ public int S1Also { get; set; }
186
+ }
187
+ public interface IPersonTable : IRelation<Person>
188
+ {
189
+ }
190
+
191
+ """ ) ;
73
192
}
74
193
}
0 commit comments