stateset-dotnet 0.7.13

C#/.NET bindings for StateSet Embedded Commerce
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
using Xunit;
using StateSet.Embedded;

namespace StateSet.Tests;

public class StateSetTests : IDisposable
{
    private readonly StateSetCommerce _commerce;

    public StateSetTests()
    {
        _commerce = new StateSetCommerce(":memory:");
    }

    public void Dispose()
    {
        _commerce.Dispose();
    }

    #region API Availability Tests

    [Fact]
    public void AllAPIsAvailable()
    {
        Assert.NotNull(_commerce.Customers);
        Assert.NotNull(_commerce.Products);
        Assert.NotNull(_commerce.Orders);
        Assert.NotNull(_commerce.Inventory);
        Assert.NotNull(_commerce.Carts);
        Assert.NotNull(_commerce.Returns);
        Assert.NotNull(_commerce.Payments);
        Assert.NotNull(_commerce.Analytics);
        Assert.NotNull(_commerce.Shipments);
        Assert.NotNull(_commerce.Warranties);
        Assert.NotNull(_commerce.Suppliers);
        Assert.NotNull(_commerce.PurchaseOrders);
        Assert.NotNull(_commerce.Invoices);
        Assert.NotNull(_commerce.Bom);
        Assert.NotNull(_commerce.WorkOrders);
        Assert.NotNull(_commerce.Currency);
        Assert.NotNull(_commerce.Subscriptions);
        Assert.NotNull(_commerce.Promotions);
        Assert.NotNull(_commerce.Tax);
        Assert.NotNull(_commerce.Quality);
        Assert.NotNull(_commerce.Lots);
        Assert.NotNull(_commerce.Serials);
        Assert.NotNull(_commerce.Warehouse);
        Assert.NotNull(_commerce.Receiving);
        Assert.NotNull(_commerce.Fulfillment);
        Assert.NotNull(_commerce.AccountsPayable);
        Assert.NotNull(_commerce.AccountsReceivable);
        Assert.NotNull(_commerce.CostAccounting);
        Assert.NotNull(_commerce.Credit);
        Assert.NotNull(_commerce.Backorders);
        Assert.NotNull(_commerce.GeneralLedger);
    }

    #endregion

    #region Customer Tests

    [Fact]
    public void CreateCustomer()
    {
        var customer = _commerce.Customers.Create(
            email: "test@example.com",
            firstName: "Test",
            lastName: "User"
        );

        Assert.NotEmpty(customer.Id);
        Assert.Equal("test@example.com", customer.Email);
        Assert.Equal("Test", customer.FirstName);
        Assert.Equal("User", customer.LastName);
    }

    [Fact]
    public void GetCustomer()
    {
        var created = _commerce.Customers.Create(
            email: "get@example.com",
            firstName: "Get",
            lastName: "Test"
        );

        var retrieved = _commerce.Customers.Get(created.Id);
        Assert.NotNull(retrieved);
        Assert.Equal(created.Id, retrieved.Id);
        Assert.Equal("get@example.com", retrieved.Email);
    }

    [Fact]
    public void ListCustomers()
    {
        _commerce.Customers.Create(
            email: "list1@example.com",
            firstName: "List",
            lastName: "One"
        );
        _commerce.Customers.Create(
            email: "list2@example.com",
            firstName: "List",
            lastName: "Two"
        );

        var customers = _commerce.Customers.List();
        Assert.True(customers.Count >= 2);
    }

    [Fact]
    public void DeleteCustomer()
    {
        var customer = _commerce.Customers.Create(
            email: "delete@example.com",
            firstName: "Delete",
            lastName: "Me"
        );

        var deleted = _commerce.Customers.Delete(customer.Id);
        Assert.True(deleted);

        var retrieved = _commerce.Customers.Get(customer.Id);
        Assert.Null(retrieved);
    }

    [Fact]
    public void CustomerCount()
    {
        _commerce.Customers.Create(
            email: "count1@example.com",
            firstName: "Count",
            lastName: "One"
        );
        _commerce.Customers.Create(
            email: "count2@example.com",
            firstName: "Count",
            lastName: "Two"
        );

        var count = _commerce.Customers.Count();
        Assert.True(count >= 2);
    }

    #endregion

    #region Product Tests

    [Fact]
    public void CreateProduct()
    {
        var product = _commerce.Products.Create(
            name: "Test Product",
            sku: "TEST-001",
            price: 29.99m,
            description: "A test product"
        );

        Assert.NotEmpty(product.Id);
        Assert.Equal("Test Product", product.Name);
    }

    [Fact]
    public void ListProducts()
    {
        _commerce.Products.Create(
            name: "Product A",
            sku: "PROD-A",
            price: 10.00m
        );
        _commerce.Products.Create(
            name: "Product B",
            sku: "PROD-B",
            price: 20.00m
        );

        var products = _commerce.Products.List();
        Assert.True(products.Count >= 2);
    }

    #endregion

    #region Inventory Tests

    [Fact]
    public void CreateInventoryItem()
    {
        var item = _commerce.Inventory.CreateItem(
            sku: "INV-001",
            name: "Inventory Item",
            initialQuantity: 100
        );

        Assert.Equal("INV-001", item.Sku);
    }

    [Fact]
    public void AdjustInventory()
    {
        _commerce.Inventory.CreateItem(
            sku: "ADJ-001",
            name: "Adjust Test",
            initialQuantity: 50
        );

        var adjusted = _commerce.Inventory.Adjust(
            sku: "ADJ-001",
            quantityDelta: 10,
            reason: "Received shipment"
        );
        Assert.True(adjusted);

        var level = _commerce.Inventory.GetLevel("ADJ-001");
        Assert.NotNull(level);
    }

    #endregion

    #region Order Tests

    [Fact]
    public void CreateOrder()
    {
        var customer = _commerce.Customers.Create(
            email: "order@example.com",
            firstName: "Order",
            lastName: "Test"
        );

        var order = _commerce.Orders.Create(
            customerId: customer.Id,
            items: new[]
            {
                new OrderItem { Sku = "TEST-SKU", Name = "Test Item", Quantity = 2, UnitPrice = 19.99 }
            },
            currency: "USD"
        );

        Assert.NotEmpty(order.Id);
        Assert.Equal(customer.Id, order.CustomerId);
    }

    [Fact]
    public void OrderLifecycle()
    {
        var customer = _commerce.Customers.Create(
            email: "lifecycle@example.com",
            firstName: "Lifecycle",
            lastName: "Test"
        );

        var order = _commerce.Orders.Create(
            customerId: customer.Id,
            items: new[]
            {
                new OrderItem { Sku = "LIFE-001", Name = "Lifecycle Item", Quantity = 1, UnitPrice = 49.99 }
            }
        );

        // Ship order
        var shipped = _commerce.Orders.Ship(order.Id);
        Assert.Equal("shipped", shipped.Status);
    }

    [Fact]
    public void CancelOrder()
    {
        var customer = _commerce.Customers.Create(
            email: "cancel@example.com",
            firstName: "Cancel",
            lastName: "Test"
        );

        var order = _commerce.Orders.Create(
            customerId: customer.Id,
            items: new[]
            {
                new OrderItem { Sku = "CANCEL-001", Name = "Cancel Item", Quantity = 1, UnitPrice = 25.00 }
            }
        );

        var cancelled = _commerce.Orders.Cancel(order.Id);
        Assert.Equal("cancelled", cancelled.Status);
    }

    #endregion

    #region Cart Tests

    [Fact]
    public void CreateCart()
    {
        var cart = _commerce.Carts.Create(currency: "USD");

        Assert.NotEmpty(cart.Id);
        Assert.Equal("USD", cart.Currency);
    }

    [Fact]
    public void AddItemToCart()
    {
        var cart = _commerce.Carts.Create();

        var updated = _commerce.Carts.AddItem(
            cartId: cart.Id,
            sku: "CART-SKU",
            name: "Cart Item",
            quantity: 2,
            unitPrice: 15.99m
        );

        Assert.NotNull(updated);
    }

    #endregion

    #region Analytics Tests

    [Fact]
    public void SalesSummary()
    {
        var summary = _commerce.Analytics.SalesSummary();
        Assert.NotNull(summary);
    }

    [Fact]
    public void TopProducts()
    {
        var products = _commerce.Analytics.TopProducts();
        Assert.NotNull(products);
    }

    [Fact]
    public void TopCustomers()
    {
        var customers = _commerce.Analytics.TopCustomers();
        Assert.NotNull(customers);
    }

    #endregion

    #region Supplier Tests

    [Fact]
    public void CreateSupplier()
    {
        var supplier = _commerce.Suppliers.Create(
            name: "Test Supplier",
            email: "supplier@example.com"
        );

        Assert.NotEmpty(supplier.Id);
        Assert.Equal("Test Supplier", supplier.Name);
    }

    [Fact]
    public void ListSuppliers()
    {
        _commerce.Suppliers.Create(
            name: "Supplier A",
            email: "suppliera@example.com"
        );

        var suppliers = _commerce.Suppliers.List();
        Assert.True(suppliers.Count >= 1);
    }

    #endregion

    #region Invoice Tests

    [Fact]
    public void CreateInvoice()
    {
        var customer = _commerce.Customers.Create(
            email: "invoice@example.com",
            firstName: "Invoice",
            lastName: "Test"
        );

        var invoice = _commerce.Invoices.Create(
            customerId: customer.Id,
            items: new[]
            {
                new InvoiceItem { Description = "Service", Quantity = 1, UnitPrice = 100.00 }
            }
        );

        Assert.NotEmpty(invoice.Id);
    }

    [Fact]
    public void ListInvoices()
    {
        var invoices = _commerce.Invoices.List();
        Assert.NotNull(invoices);
    }

    #endregion

    #region Subscription Tests

    [Fact]
    public void CreateSubscriptionPlan()
    {
        var plan = _commerce.Subscriptions.CreatePlan(
            code: "BASIC",
            name: "Basic Plan",
            interval: "month",
            intervalCount: 1,
            price: 9.99m,
            currency: "USD"
        );

        Assert.NotEmpty(plan.Id);
        Assert.Equal("BASIC", plan.Code);
    }

    [Fact]
    public void ListSubscriptionPlans()
    {
        _commerce.Subscriptions.CreatePlan(
            code: "LIST-PLAN",
            name: "List Plan",
            interval: "month",
            intervalCount: 1,
            price: 19.99m
        );

        var plans = _commerce.Subscriptions.ListPlans();
        Assert.True(plans.Count >= 1);
    }

    [Fact]
    public void SubscribeCustomer()
    {
        var customer = _commerce.Customers.Create(
            email: "subscribe@example.com",
            firstName: "Subscribe",
            lastName: "Test"
        );

        var plan = _commerce.Subscriptions.CreatePlan(
            code: "SUB-PLAN",
            name: "Subscribe Plan",
            interval: "month",
            intervalCount: 1,
            price: 29.99m
        );

        var subscription = _commerce.Subscriptions.Subscribe(
            customerId: customer.Id,
            planId: plan.Id
        );

        Assert.NotEmpty(subscription.Id);
        Assert.Equal(customer.Id, subscription.CustomerId);
    }

    #endregion

    #region Promotion Tests

    [Fact]
    public void CreatePromotion()
    {
        var promo = _commerce.Promotions.Create(
            code: "TEST20",
            name: "Test Discount",
            discountType: "percentage",
            discountValue: 20.0m
        );

        Assert.NotEmpty(promo.Id);
        Assert.Equal("TEST20", promo.Code);
    }

    [Fact]
    public void GetActivePromotions()
    {
        var promo = _commerce.Promotions.Create(
            code: "ACTIVE10",
            name: "Active Promo",
            discountType: "percentage",
            discountValue: 10.0m
        );
        _commerce.Promotions.Activate(promo.Id);

        var active = _commerce.Promotions.GetActive();
        Assert.True(active.Count >= 1);
    }

    [Fact]
    public void CreateCoupon()
    {
        var promo = _commerce.Promotions.Create(
            code: "COUPON-PROMO",
            name: "Coupon Promotion",
            discountType: "percentage",
            discountValue: 15.0m
        );

        var coupon = _commerce.Promotions.CreateCoupon(
            promotionId: promo.Id,
            code: "SAVE15NOW",
            maxUses: 100
        );

        Assert.NotEmpty(coupon.Id);
        Assert.Equal("SAVE15NOW", coupon.Code);
    }

    #endregion

    #region Tax Tests

    [Fact]
    public void GetTaxSettings()
    {
        var settings = _commerce.Tax.GetSettings();
        Assert.NotNull(settings);
    }

    [Fact]
    public void CreateTaxRate()
    {
        var rate = _commerce.Tax.CreateRate(
            country: "US",
            rate: 8.25m
        );

        Assert.NotEmpty(rate.Id);
        Assert.Equal("US", rate.Country);
    }

    #endregion

    #region Warehouse Tests

    [Fact]
    public void CreateWarehouse()
    {
        var warehouse = _commerce.Warehouse.CreateWarehouse(
            code: "WH-TEST",
            name: "Test Warehouse",
            warehouseType: "distribution"
        );

        Assert.Equal("WH-TEST", warehouse.Code);
        Assert.Equal("Test Warehouse", warehouse.Name);
    }

    [Fact]
    public void ListWarehouses()
    {
        _commerce.Warehouse.CreateWarehouse(
            code: "WH-LIST",
            name: "List Warehouse"
        );

        var warehouses = _commerce.Warehouse.ListWarehouses();
        Assert.True(warehouses.Count >= 1);
    }

    [Fact]
    public void CreateZone()
    {
        var warehouse = _commerce.Warehouse.CreateWarehouse(
            code: "WH-ZONE",
            name: "Zone Warehouse"
        );

        var zone = _commerce.Warehouse.CreateZone(
            warehouseId: warehouse.Id,
            code: "ZONE-A",
            name: "Zone A",
            zoneType: "storage"
        );

        Assert.NotEmpty(zone.Id);
        Assert.Equal("ZONE-A", zone.Code);
    }

    #endregion

    #region Quality Tests

    [Fact]
    public void CreateInspection()
    {
        var inspection = _commerce.Quality.CreateInspection(
            inspectionType: "incoming",
            referenceType: "purchase_order",
            referenceId: "test-po-id"
        );

        Assert.NotEmpty(inspection.Id);
    }

    [Fact]
    public void ListInspections()
    {
        var inspections = _commerce.Quality.ListInspections();
        Assert.NotNull(inspections);
    }

    #endregion

    #region Lots Tests

    [Fact]
    public void CreateLot()
    {
        _commerce.Inventory.CreateItem(
            sku: "LOT-SKU",
            name: "Lot Item",
            initialQuantity: 0
        );

        var lot = _commerce.Lots.CreateLot(
            lotNumber: "LOT-001",
            sku: "LOT-SKU",
            quantity: 100
        );

        Assert.NotEmpty(lot.Id);
        Assert.Equal("LOT-001", lot.LotNumber);
    }

    [Fact]
    public void ListLots()
    {
        var lots = _commerce.Lots.ListLots();
        Assert.NotNull(lots);
    }

    #endregion

    #region Serials Tests

    [Fact]
    public void RegisterSerial()
    {
        _commerce.Inventory.CreateItem(
            sku: "SERIAL-SKU",
            name: "Serial Item",
            initialQuantity: 0
        );

        var serial = _commerce.Serials.RegisterSerial(
            serialNumber: "SN-001",
            sku: "SERIAL-SKU"
        );

        Assert.NotEmpty(serial.Id);
        Assert.Equal("SN-001", serial.SerialNumber);
    }

    [Fact]
    public void ListSerials()
    {
        var serials = _commerce.Serials.ListSerials();
        Assert.NotNull(serials);
    }

    #endregion

    #region General Ledger Tests

    [Fact]
    public void CreateGlAccount()
    {
        var account = _commerce.GeneralLedger.CreateAccount(
            accountNumber: "1000",
            name: "Cash",
            accountType: "asset"
        );

        Assert.NotEmpty(account.Id);
        Assert.Equal("1000", account.AccountNumber);
        Assert.Equal("Cash", account.Name);
    }

    [Fact]
    public void ListGlAccounts()
    {
        _commerce.GeneralLedger.CreateAccount(
            accountNumber: "2000",
            name: "Accounts Payable",
            accountType: "liability"
        );

        var accounts = _commerce.GeneralLedger.ListAccounts();
        Assert.True(accounts.Count >= 1);
    }

    [Fact]
    public void InitializeChartOfAccounts()
    {
        var accounts = _commerce.GeneralLedger.InitializeChartOfAccounts();
        Assert.NotNull(accounts);
        Assert.True(accounts.Count > 0);
    }

    #endregion

    #region Accounts Payable Tests

    [Fact]
    public void ListBills()
    {
        var bills = _commerce.AccountsPayable.ListBills();
        Assert.NotNull(bills);
    }

    [Fact]
    public void GetApAgingSummary()
    {
        var summary = _commerce.AccountsPayable.GetAgingSummary();
        Assert.NotNull(summary);
    }

    #endregion

    #region Accounts Receivable Tests

    [Fact]
    public void ListReceivables()
    {
        var receivables = _commerce.AccountsReceivable.ListReceivables();
        Assert.NotNull(receivables);
    }

    [Fact]
    public void GetArAgingSummary()
    {
        var summary = _commerce.AccountsReceivable.GetAgingSummary();
        Assert.NotNull(summary);
    }

    #endregion

    #region Credit Tests

    [Fact]
    public void GetCreditLimit()
    {
        var customer = _commerce.Customers.Create(
            email: "credit@example.com",
            firstName: "Credit",
            lastName: "Test"
        );

        var limit = _commerce.Credit.GetCreditLimit(customer.Id);
        Assert.NotNull(limit);
    }

    [Fact]
    public void SetCreditLimit()
    {
        var customer = _commerce.Customers.Create(
            email: "setcredit@example.com",
            firstName: "Set",
            lastName: "Credit"
        );

        var limit = _commerce.Credit.SetCreditLimit(
            customerId: customer.Id,
            limit: 10000.00m,
            currency: "USD"
        );

        Assert.NotNull(limit);
    }

    #endregion

    #region Backorders Tests

    [Fact]
    public void ListBackorders()
    {
        var backorders = _commerce.Backorders.ListBackorders();
        Assert.NotNull(backorders);
    }

    [Fact]
    public void GetBackorderSummary()
    {
        var summary = _commerce.Backorders.GetSummary();
        Assert.NotNull(summary);
    }

    #endregion

    #region Fulfillment Tests

    [Fact]
    public void ListWaves()
    {
        var waves = _commerce.Fulfillment.ListWaves();
        Assert.NotNull(waves);
    }

    [Fact]
    public void ListPickLists()
    {
        var pickLists = _commerce.Fulfillment.ListPickLists();
        Assert.NotNull(pickLists);
    }

    #endregion

    #region Receiving Tests

    [Fact]
    public void ListReceipts()
    {
        var receipts = _commerce.Receiving.ListReceipts();
        Assert.NotNull(receipts);
    }

    #endregion

    #region Cost Accounting Tests

    [Fact]
    public void ListCostEntries()
    {
        var entries = _commerce.CostAccounting.ListCostEntries();
        Assert.NotNull(entries);
    }

    #endregion

    #region BOM Tests

    [Fact]
    public void CreateBom()
    {
        var product = _commerce.Products.Create(
            name: "BOM Product",
            sku: "BOM-PROD",
            price: 99.99m
        );

        var bom = _commerce.Bom.Create(
            productId: product.Id,
            name: "Test BOM",
            version: "1.0"
        );

        Assert.NotEmpty(bom.Id);
        Assert.Equal("Test BOM", bom.Name);
    }

    [Fact]
    public void ListBoms()
    {
        var boms = _commerce.Bom.List();
        Assert.NotNull(boms);
    }

    #endregion

    #region Work Orders Tests

    [Fact]
    public void CreateWorkOrder()
    {
        var product = _commerce.Products.Create(
            name: "WO Product",
            sku: "WO-PROD",
            price: 49.99m
        );

        var workOrder = _commerce.WorkOrders.Create(
            productId: product.Id,
            quantity: 10
        );

        Assert.NotEmpty(workOrder.Id);
    }

    [Fact]
    public void ListWorkOrders()
    {
        var workOrders = _commerce.WorkOrders.List();
        Assert.NotNull(workOrders);
    }

    #endregion

    #region Purchase Orders Tests

    [Fact]
    public void CreatePurchaseOrder()
    {
        var supplier = _commerce.Suppliers.Create(
            name: "PO Supplier",
            email: "posupplier@example.com"
        );

        var po = _commerce.PurchaseOrders.Create(
            supplierId: supplier.Id,
            items: new[]
            {
                new PurchaseOrderItem { Sku = "PO-SKU", Name = "PO Item", Quantity = 10, UnitCost = 5.00 }
            }
        );

        Assert.NotEmpty(po.Id);
    }

    [Fact]
    public void ListPurchaseOrders()
    {
        var pos = _commerce.PurchaseOrders.List();
        Assert.NotNull(pos);
    }

    #endregion

    #region Shipments Tests

    [Fact]
    public void CreateShipment()
    {
        var customer = _commerce.Customers.Create(
            email: "shipment@example.com",
            firstName: "Shipment",
            lastName: "Test"
        );

        var order = _commerce.Orders.Create(
            customerId: customer.Id,
            items: new[]
            {
                new OrderItem { Sku = "SHIP-SKU", Name = "Ship Item", Quantity = 1, UnitPrice = 30.00 }
            }
        );

        var shipment = _commerce.Shipments.Create(
            orderId: order.Id,
            recipientName: "Test Recipient",
            shippingAddress: "123 Test St",
            carrier: "ups"
        );

        Assert.NotEmpty(shipment.Id);

        var shipped = _commerce.Shipments.Ship(shipment.Id, "1Z999AA10123456784");
        Assert.Equal("shipped", shipped.Status);

        var delivered = _commerce.Shipments.Deliver(shipment.Id);
        Assert.Equal("delivered", delivered.Status);

        var order2 = _commerce.Orders.Create(
            customerId: customer.Id,
            items: new[]
            {
                new OrderItem { Sku = "SHIP-SKU-2", Name = "Ship Item 2", Quantity = 1, UnitPrice = 12.00 }
            }
        );

        var toCancel = _commerce.Shipments.Create(
            orderId: order2.Id,
            recipientName: "Test Recipient",
            shippingAddress: "456 Market St",
            carrier: "ups"
        );

        var cancelled = _commerce.Shipments.Cancel(toCancel.Id);
        Assert.Equal("cancelled", cancelled.Status);
    }

    [Fact]
    public void ListShipments()
    {
        var shipments = _commerce.Shipments.List();
        Assert.NotNull(shipments);
    }

    #endregion

    #region Warranties Tests

    [Fact]
    public void CreateWarranty()
    {
        var customer = _commerce.Customers.Create(
            email: "warranty@example.com",
            firstName: "Warranty",
            lastName: "Test"
        );

        var warranty = _commerce.Warranties.Create(
            customerId: customer.Id,
            warrantyType: "standard",
            durationMonths: 12
        );

        Assert.NotEmpty(warranty.Id);
    }

    [Fact]
    public void ListWarranties()
    {
        var warranties = _commerce.Warranties.List();
        Assert.NotNull(warranties);
    }

    #endregion

    #region Returns Tests

    [Fact]
    public void CreateReturn()
    {
        var customer = _commerce.Customers.Create(
            email: "return@example.com",
            firstName: "Return",
            lastName: "Test"
        );

        var order = _commerce.Orders.Create(
            customerId: customer.Id,
            items: new[]
            {
                new OrderItem { Sku = "RET-SKU", Name = "Return Item", Quantity = 1, UnitPrice = 50.00 }
            }
        );

        var returnRequest = _commerce.Returns.Create(
            orderId: order.Id,
            reason: "defective"
        );

        Assert.NotEmpty(returnRequest.Id);
    }

    [Fact]
    public void ListReturns()
    {
        var returns = _commerce.Returns.List();
        Assert.NotNull(returns);
    }

    #endregion

    #region Payments Tests

    [Fact]
    public void CreatePayment()
    {
        var customer = _commerce.Customers.Create(
            email: "payment@example.com",
            firstName: "Payment",
            lastName: "Test"
        );

        var order = _commerce.Orders.Create(
            customerId: customer.Id,
            items: new[]
            {
                new OrderItem { Sku = "PAY-SKU", Name = "Payment Item", Quantity = 1, UnitPrice = 100.00 }
            }
        );

        var payment = _commerce.Payments.Create(
            orderId: order.Id,
            amount: 100.00m,
            method: "credit_card"
        );

        Assert.NotEmpty(payment.Id);
    }

    [Fact]
    public void ListPayments()
    {
        var payments = _commerce.Payments.List();
        Assert.NotNull(payments);
    }

    #endregion
}