Skip to content

Commit 9c7927a

Browse files
chore(internal): add copy constructor tests
1 parent d8f27e8 commit 9c7927a

File tree

530 files changed

+41238
-1977
lines changed

Some content is hidden

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

530 files changed

+41238
-1977
lines changed

src/Orb.Tests/Models/AddressTest.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,22 @@ public void Validation_Works()
103103

104104
model.Validate();
105105
}
106+
107+
[Fact]
108+
public void CopyConstructor_Works()
109+
{
110+
var model = new Address
111+
{
112+
City = "city",
113+
Country = "country",
114+
Line1 = "line1",
115+
Line2 = "line2",
116+
PostalCode = "postal_code",
117+
State = "state",
118+
};
119+
120+
Address copied = new(model);
121+
122+
Assert.Equal(model, copied);
123+
}
106124
}

src/Orb.Tests/Models/AdjustmentIntervalTest.cs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,42 @@ public void Validation_Works()
231231

232232
model.Validate();
233233
}
234+
235+
[Fact]
236+
public void CopyConstructor_Works()
237+
{
238+
var model = new AdjustmentInterval
239+
{
240+
ID = "id",
241+
Adjustment = new PlanPhaseUsageDiscountAdjustment()
242+
{
243+
ID = "id",
244+
AdjustmentType = PlanPhaseUsageDiscountAdjustmentAdjustmentType.UsageDiscount,
245+
AppliesToPriceIds = ["string"],
246+
Filters =
247+
[
248+
new()
249+
{
250+
Field = PlanPhaseUsageDiscountAdjustmentFilterField.PriceID,
251+
Operator = PlanPhaseUsageDiscountAdjustmentFilterOperator.Includes,
252+
Values = ["string"],
253+
},
254+
],
255+
IsInvoiceLevel = true,
256+
PlanPhaseOrder = 0,
257+
Reason = "reason",
258+
ReplacesAdjustmentID = "replaces_adjustment_id",
259+
UsageDiscount = 0,
260+
},
261+
AppliesToPriceIntervalIds = ["string"],
262+
EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"),
263+
StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"),
264+
};
265+
266+
AdjustmentInterval copied = new(model);
267+
268+
Assert.Equal(model, copied);
269+
}
234270
}
235271

236272
public class AdjustmentTest : TestBase

src/Orb.Tests/Models/AggregatedCostTest.cs

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -844,4 +844,144 @@ public void Validation_Works()
844844

845845
model.Validate();
846846
}
847+
848+
[Fact]
849+
public void CopyConstructor_Works()
850+
{
851+
var model = new AggregatedCost
852+
{
853+
PerPriceCosts =
854+
[
855+
new()
856+
{
857+
Price = new Unit()
858+
{
859+
ID = "id",
860+
BillableMetric = new("id"),
861+
BillingCycleConfiguration = new()
862+
{
863+
Duration = 0,
864+
DurationUnit = DurationUnit.Day,
865+
},
866+
BillingMode = BillingMode.InAdvance,
867+
Cadence = UnitCadence.OneTime,
868+
CompositePriceFilters =
869+
[
870+
new()
871+
{
872+
Field = CompositePriceFilterField.PriceID,
873+
Operator = CompositePriceFilterOperator.Includes,
874+
Values = ["string"],
875+
},
876+
],
877+
ConversionRate = 0,
878+
ConversionRateConfig = new SharedUnitConversionRateConfig()
879+
{
880+
ConversionRateType =
881+
SharedUnitConversionRateConfigConversionRateType.Unit,
882+
UnitConfig = new("unit_amount"),
883+
},
884+
CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"),
885+
CreditAllocation = new()
886+
{
887+
AllowsRollover = true,
888+
Currency = "currency",
889+
CustomExpiration = new()
890+
{
891+
Duration = 0,
892+
DurationUnit = CustomExpirationDurationUnit.Day,
893+
},
894+
Filters =
895+
[
896+
new()
897+
{
898+
Field = Field.PriceID,
899+
Operator = Operator.Includes,
900+
Values = ["string"],
901+
},
902+
],
903+
},
904+
Currency = "currency",
905+
Discount = new PercentageDiscount()
906+
{
907+
DiscountType = PercentageDiscountDiscountType.Percentage,
908+
PercentageDiscountValue = 0.15,
909+
AppliesToPriceIds = ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"],
910+
Filters =
911+
[
912+
new()
913+
{
914+
Field = PercentageDiscountFilterField.PriceID,
915+
Operator = PercentageDiscountFilterOperator.Includes,
916+
Values = ["string"],
917+
},
918+
],
919+
Reason = "reason",
920+
},
921+
ExternalPriceID = "external_price_id",
922+
FixedPriceQuantity = 0,
923+
InvoicingCycleConfiguration = new()
924+
{
925+
Duration = 0,
926+
DurationUnit = DurationUnit.Day,
927+
},
928+
Item = new() { ID = "id", Name = "name" },
929+
Maximum = new()
930+
{
931+
AppliesToPriceIds = ["string"],
932+
Filters =
933+
[
934+
new()
935+
{
936+
Field = MaximumFilterField.PriceID,
937+
Operator = MaximumFilterOperator.Includes,
938+
Values = ["string"],
939+
},
940+
],
941+
MaximumAmount = "maximum_amount",
942+
},
943+
MaximumAmount = "maximum_amount",
944+
Metadata = new Dictionary<string, string>() { { "foo", "string" } },
945+
Minimum = new()
946+
{
947+
AppliesToPriceIds = ["string"],
948+
Filters =
949+
[
950+
new()
951+
{
952+
Field = MinimumFilterField.PriceID,
953+
Operator = MinimumFilterOperator.Includes,
954+
Values = ["string"],
955+
},
956+
],
957+
MinimumAmount = "minimum_amount",
958+
},
959+
MinimumAmount = "minimum_amount",
960+
Name = "name",
961+
PlanPhaseOrder = 0,
962+
PriceType = UnitPriceType.UsagePrice,
963+
ReplacesPriceID = "replaces_price_id",
964+
UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true },
965+
DimensionalPriceConfiguration = new()
966+
{
967+
DimensionValues = ["string"],
968+
DimensionalPriceGroupID = "dimensional_price_group_id",
969+
},
970+
},
971+
PriceID = "price_id",
972+
Subtotal = "subtotal",
973+
Total = "total",
974+
Quantity = 0,
975+
},
976+
],
977+
Subtotal = "subtotal",
978+
TimeframeEnd = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"),
979+
TimeframeStart = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"),
980+
Total = "total",
981+
};
982+
983+
AggregatedCost copied = new(model);
984+
985+
Assert.Equal(model, copied);
986+
}
847987
}

src/Orb.Tests/Models/Alerts/AlertListPageResponseTest.cs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,4 +225,40 @@ public void Validation_Works()
225225

226226
model.Validate();
227227
}
228+
229+
[Fact]
230+
public void CopyConstructor_Works()
231+
{
232+
var model = new AlertListPageResponse
233+
{
234+
Data =
235+
[
236+
new()
237+
{
238+
ID = "XuxCbt7x9L82yyeF",
239+
CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"),
240+
Currency = "currency",
241+
Customer = new() { ID = "id", ExternalCustomerID = "external_customer_id" },
242+
Enabled = true,
243+
Metric = new("id"),
244+
Plan = new()
245+
{
246+
ID = "m2t5akQeh2obwxeU",
247+
ExternalPlanID = "m2t5akQeh2obwxeU",
248+
Name = "Example plan",
249+
PlanVersion = "plan_version",
250+
},
251+
Subscription = new("VDGsT23osdLb84KD"),
252+
Thresholds = [new(0)],
253+
Type = AlertType.CreditBalanceDepleted,
254+
BalanceAlertStatus = [new() { InAlert = true, ThresholdValue = 0 }],
255+
},
256+
],
257+
PaginationMetadata = new() { HasMore = true, NextCursor = "next_cursor" },
258+
};
259+
260+
AlertListPageResponse copied = new(model);
261+
262+
Assert.Equal(model, copied);
263+
}
228264
}

src/Orb.Tests/Models/Alerts/AlertTest.cs

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,35 @@ public void OptionalNullablePropertiesSetToNullValidation_Works()
324324

325325
model.Validate();
326326
}
327+
328+
[Fact]
329+
public void CopyConstructor_Works()
330+
{
331+
var model = new Alert
332+
{
333+
ID = "XuxCbt7x9L82yyeF",
334+
CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"),
335+
Currency = "currency",
336+
Customer = new() { ID = "id", ExternalCustomerID = "external_customer_id" },
337+
Enabled = true,
338+
Metric = new("id"),
339+
Plan = new()
340+
{
341+
ID = "m2t5akQeh2obwxeU",
342+
ExternalPlanID = "m2t5akQeh2obwxeU",
343+
Name = "Example plan",
344+
PlanVersion = "plan_version",
345+
},
346+
Subscription = new("VDGsT23osdLb84KD"),
347+
Thresholds = [new(0)],
348+
Type = AlertType.CreditBalanceDepleted,
349+
BalanceAlertStatus = [new() { InAlert = true, ThresholdValue = 0 }],
350+
};
351+
352+
Alert copied = new(model);
353+
354+
Assert.Equal(model, copied);
355+
}
327356
}
328357

329358
public class MetricTest : TestBase
@@ -370,6 +399,16 @@ public void Validation_Works()
370399

371400
model.Validate();
372401
}
402+
403+
[Fact]
404+
public void CopyConstructor_Works()
405+
{
406+
var model = new Metric { ID = "id" };
407+
408+
Metric copied = new(model);
409+
410+
Assert.Equal(model, copied);
411+
}
373412
}
374413

375414
public class PlanTest : TestBase
@@ -452,6 +491,22 @@ public void Validation_Works()
452491

453492
model.Validate();
454493
}
494+
495+
[Fact]
496+
public void CopyConstructor_Works()
497+
{
498+
var model = new Plan
499+
{
500+
ID = "m2t5akQeh2obwxeU",
501+
ExternalPlanID = "m2t5akQeh2obwxeU",
502+
Name = "Example plan",
503+
PlanVersion = "plan_version",
504+
};
505+
506+
Plan copied = new(model);
507+
508+
Assert.Equal(model, copied);
509+
}
455510
}
456511

457512
public class AlertTypeTest : TestBase
@@ -572,4 +627,14 @@ public void Validation_Works()
572627

573628
model.Validate();
574629
}
630+
631+
[Fact]
632+
public void CopyConstructor_Works()
633+
{
634+
var model = new BalanceAlertStatus { InAlert = true, ThresholdValue = 0 };
635+
636+
BalanceAlertStatus copied = new(model);
637+
638+
Assert.Equal(model, copied);
639+
}
575640
}

src/Orb.Tests/Models/Alerts/ThresholdTest.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,14 @@ public void Validation_Works()
5151

5252
model.Validate();
5353
}
54+
55+
[Fact]
56+
public void CopyConstructor_Works()
57+
{
58+
var model = new Threshold { Value = 0 };
59+
60+
Threshold copied = new(model);
61+
62+
Assert.Equal(model, copied);
63+
}
5464
}

0 commit comments

Comments
 (0)