Skip to content

Commit 4169656

Browse files
chore(internal): add union tests
1 parent e3ba15d commit 4169656

File tree

113 files changed

+95278
-13860
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

113 files changed

+95278
-13860
lines changed

src/Orb.Tests/Models/AdjustmentIntervalTest.cs

Lines changed: 302 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,3 +225,305 @@ public void Validation_Works()
225225
model.Validate();
226226
}
227227
}
228+
229+
public class AdjustmentTest : TestBase
230+
{
231+
[Fact]
232+
public void plan_phase_usage_discountValidation_Works()
233+
{
234+
Adjustment value = new(
235+
new()
236+
{
237+
ID = "id",
238+
AdjustmentType = PlanPhaseUsageDiscountAdjustmentAdjustmentType.UsageDiscount,
239+
AppliesToPriceIDs = ["string"],
240+
Filters =
241+
[
242+
new()
243+
{
244+
Field = PlanPhaseUsageDiscountAdjustmentFilterField.PriceID,
245+
Operator = PlanPhaseUsageDiscountAdjustmentFilterOperator.Includes,
246+
Values = ["string"],
247+
},
248+
],
249+
IsInvoiceLevel = true,
250+
PlanPhaseOrder = 0,
251+
Reason = "reason",
252+
ReplacesAdjustmentID = "replaces_adjustment_id",
253+
UsageDiscount = 0,
254+
}
255+
);
256+
value.Validate();
257+
}
258+
259+
[Fact]
260+
public void plan_phase_amount_discountValidation_Works()
261+
{
262+
Adjustment value = new(
263+
new()
264+
{
265+
ID = "id",
266+
AdjustmentType = PlanPhaseAmountDiscountAdjustmentAdjustmentType.AmountDiscount,
267+
AmountDiscount = "amount_discount",
268+
AppliesToPriceIDs = ["string"],
269+
Filters =
270+
[
271+
new()
272+
{
273+
Field = PlanPhaseAmountDiscountAdjustmentFilterField.PriceID,
274+
Operator = PlanPhaseAmountDiscountAdjustmentFilterOperator.Includes,
275+
Values = ["string"],
276+
},
277+
],
278+
IsInvoiceLevel = true,
279+
PlanPhaseOrder = 0,
280+
Reason = "reason",
281+
ReplacesAdjustmentID = "replaces_adjustment_id",
282+
}
283+
);
284+
value.Validate();
285+
}
286+
287+
[Fact]
288+
public void plan_phase_percentage_discountValidation_Works()
289+
{
290+
Adjustment value = new(
291+
new()
292+
{
293+
ID = "id",
294+
AdjustmentType =
295+
PlanPhasePercentageDiscountAdjustmentAdjustmentType.PercentageDiscount,
296+
AppliesToPriceIDs = ["string"],
297+
Filters =
298+
[
299+
new()
300+
{
301+
Field = PlanPhasePercentageDiscountAdjustmentFilterField.PriceID,
302+
Operator = PlanPhasePercentageDiscountAdjustmentFilterOperator.Includes,
303+
Values = ["string"],
304+
},
305+
],
306+
IsInvoiceLevel = true,
307+
PercentageDiscount = 0,
308+
PlanPhaseOrder = 0,
309+
Reason = "reason",
310+
ReplacesAdjustmentID = "replaces_adjustment_id",
311+
}
312+
);
313+
value.Validate();
314+
}
315+
316+
[Fact]
317+
public void plan_phase_minimumValidation_Works()
318+
{
319+
Adjustment value = new(
320+
new()
321+
{
322+
ID = "id",
323+
AdjustmentType = PlanPhaseMinimumAdjustmentAdjustmentType.Minimum,
324+
AppliesToPriceIDs = ["string"],
325+
Filters =
326+
[
327+
new()
328+
{
329+
Field = PlanPhaseMinimumAdjustmentFilterField.PriceID,
330+
Operator = PlanPhaseMinimumAdjustmentFilterOperator.Includes,
331+
Values = ["string"],
332+
},
333+
],
334+
IsInvoiceLevel = true,
335+
ItemID = "item_id",
336+
MinimumAmount = "minimum_amount",
337+
PlanPhaseOrder = 0,
338+
Reason = "reason",
339+
ReplacesAdjustmentID = "replaces_adjustment_id",
340+
}
341+
);
342+
value.Validate();
343+
}
344+
345+
[Fact]
346+
public void plan_phase_maximumValidation_Works()
347+
{
348+
Adjustment value = new(
349+
new()
350+
{
351+
ID = "id",
352+
AdjustmentType = PlanPhaseMaximumAdjustmentAdjustmentType.Maximum,
353+
AppliesToPriceIDs = ["string"],
354+
Filters =
355+
[
356+
new()
357+
{
358+
Field = PlanPhaseMaximumAdjustmentFilterField.PriceID,
359+
Operator = PlanPhaseMaximumAdjustmentFilterOperator.Includes,
360+
Values = ["string"],
361+
},
362+
],
363+
IsInvoiceLevel = true,
364+
MaximumAmount = "maximum_amount",
365+
PlanPhaseOrder = 0,
366+
Reason = "reason",
367+
ReplacesAdjustmentID = "replaces_adjustment_id",
368+
}
369+
);
370+
value.Validate();
371+
}
372+
373+
[Fact]
374+
public void plan_phase_usage_discountSerializationRoundtrip_Works()
375+
{
376+
Adjustment value = new(
377+
new()
378+
{
379+
ID = "id",
380+
AdjustmentType = PlanPhaseUsageDiscountAdjustmentAdjustmentType.UsageDiscount,
381+
AppliesToPriceIDs = ["string"],
382+
Filters =
383+
[
384+
new()
385+
{
386+
Field = PlanPhaseUsageDiscountAdjustmentFilterField.PriceID,
387+
Operator = PlanPhaseUsageDiscountAdjustmentFilterOperator.Includes,
388+
Values = ["string"],
389+
},
390+
],
391+
IsInvoiceLevel = true,
392+
PlanPhaseOrder = 0,
393+
Reason = "reason",
394+
ReplacesAdjustmentID = "replaces_adjustment_id",
395+
UsageDiscount = 0,
396+
}
397+
);
398+
string json = JsonSerializer.Serialize(value);
399+
var deserialized = JsonSerializer.Deserialize<Adjustment>(json);
400+
401+
Assert.Equal(value, deserialized);
402+
}
403+
404+
[Fact]
405+
public void plan_phase_amount_discountSerializationRoundtrip_Works()
406+
{
407+
Adjustment value = new(
408+
new()
409+
{
410+
ID = "id",
411+
AdjustmentType = PlanPhaseAmountDiscountAdjustmentAdjustmentType.AmountDiscount,
412+
AmountDiscount = "amount_discount",
413+
AppliesToPriceIDs = ["string"],
414+
Filters =
415+
[
416+
new()
417+
{
418+
Field = PlanPhaseAmountDiscountAdjustmentFilterField.PriceID,
419+
Operator = PlanPhaseAmountDiscountAdjustmentFilterOperator.Includes,
420+
Values = ["string"],
421+
},
422+
],
423+
IsInvoiceLevel = true,
424+
PlanPhaseOrder = 0,
425+
Reason = "reason",
426+
ReplacesAdjustmentID = "replaces_adjustment_id",
427+
}
428+
);
429+
string json = JsonSerializer.Serialize(value);
430+
var deserialized = JsonSerializer.Deserialize<Adjustment>(json);
431+
432+
Assert.Equal(value, deserialized);
433+
}
434+
435+
[Fact]
436+
public void plan_phase_percentage_discountSerializationRoundtrip_Works()
437+
{
438+
Adjustment value = new(
439+
new()
440+
{
441+
ID = "id",
442+
AdjustmentType =
443+
PlanPhasePercentageDiscountAdjustmentAdjustmentType.PercentageDiscount,
444+
AppliesToPriceIDs = ["string"],
445+
Filters =
446+
[
447+
new()
448+
{
449+
Field = PlanPhasePercentageDiscountAdjustmentFilterField.PriceID,
450+
Operator = PlanPhasePercentageDiscountAdjustmentFilterOperator.Includes,
451+
Values = ["string"],
452+
},
453+
],
454+
IsInvoiceLevel = true,
455+
PercentageDiscount = 0,
456+
PlanPhaseOrder = 0,
457+
Reason = "reason",
458+
ReplacesAdjustmentID = "replaces_adjustment_id",
459+
}
460+
);
461+
string json = JsonSerializer.Serialize(value);
462+
var deserialized = JsonSerializer.Deserialize<Adjustment>(json);
463+
464+
Assert.Equal(value, deserialized);
465+
}
466+
467+
[Fact]
468+
public void plan_phase_minimumSerializationRoundtrip_Works()
469+
{
470+
Adjustment value = new(
471+
new()
472+
{
473+
ID = "id",
474+
AdjustmentType = PlanPhaseMinimumAdjustmentAdjustmentType.Minimum,
475+
AppliesToPriceIDs = ["string"],
476+
Filters =
477+
[
478+
new()
479+
{
480+
Field = PlanPhaseMinimumAdjustmentFilterField.PriceID,
481+
Operator = PlanPhaseMinimumAdjustmentFilterOperator.Includes,
482+
Values = ["string"],
483+
},
484+
],
485+
IsInvoiceLevel = true,
486+
ItemID = "item_id",
487+
MinimumAmount = "minimum_amount",
488+
PlanPhaseOrder = 0,
489+
Reason = "reason",
490+
ReplacesAdjustmentID = "replaces_adjustment_id",
491+
}
492+
);
493+
string json = JsonSerializer.Serialize(value);
494+
var deserialized = JsonSerializer.Deserialize<Adjustment>(json);
495+
496+
Assert.Equal(value, deserialized);
497+
}
498+
499+
[Fact]
500+
public void plan_phase_maximumSerializationRoundtrip_Works()
501+
{
502+
Adjustment value = new(
503+
new()
504+
{
505+
ID = "id",
506+
AdjustmentType = PlanPhaseMaximumAdjustmentAdjustmentType.Maximum,
507+
AppliesToPriceIDs = ["string"],
508+
Filters =
509+
[
510+
new()
511+
{
512+
Field = PlanPhaseMaximumAdjustmentFilterField.PriceID,
513+
Operator = PlanPhaseMaximumAdjustmentFilterOperator.Includes,
514+
Values = ["string"],
515+
},
516+
],
517+
IsInvoiceLevel = true,
518+
MaximumAmount = "maximum_amount",
519+
PlanPhaseOrder = 0,
520+
Reason = "reason",
521+
ReplacesAdjustmentID = "replaces_adjustment_id",
522+
}
523+
);
524+
string json = JsonSerializer.Serialize(value);
525+
var deserialized = JsonSerializer.Deserialize<Adjustment>(json);
526+
527+
Assert.Equal(value, deserialized);
528+
}
529+
}

0 commit comments

Comments
 (0)