Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 25 additions & 5 deletions src/WidgetWorks.Infrastructure/Seeding/DbSeeder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,31 @@ public sealed class DbSeeder(IDbConnectionFactory factory, IPasswordHasher hashe
{
private static readonly (string Sku, string Name, string Description, decimal Price, int OnHand)[] DemoWidgets =
[
("WW-001", "Standard Widget", "The dependable everyday widget.", 9.99m, 250),
("WW-002", "Deluxe Widget", "Premium finish with a reinforced housing.", 24.99m, 120),
("WW-003", "Mega Widget", "Oversized widget for heavy-duty jobs.", 49.99m, 60),
("WW-004", "Mini Widget", "Compact widget for tight spaces.", 4.99m, 500),
("WW-005", "Widget Pro Kit", "Bundle of assorted widgets and accessories.", 79.99m, 40),
("WW-001", "Standard Widget Block", "The dependable everyday widget.", 9.99m, 250),
("WW-002", "Standard Widget Rotary", "Dial-adjustable everyday widget.", 11.49m, 220),
("WW-003", "Standard Widget Valve", "Inline everyday widget with twin ports.", 12.99m, 180),
("WW-004", "Standard Widget Hub", "Four-port everyday widget.", 13.99m, 160),
("WW-005", "Standard Widget Turbine", "Ventilated everyday widget.", 14.99m, 140),
("WW-006", "Deluxe Widget Block", "Premium finish with a reinforced housing.", 24.99m, 120),
("WW-007", "Deluxe Widget Rotary", "Premium dial with a gold-plated pointer.", 27.49m, 110),
("WW-008", "Deluxe Widget Valve", "Premium inline widget, machined ports.", 29.99m, 90),
("WW-009", "Deluxe Widget Hub", "Premium four-port widget, gold contacts.", 32.99m, 80),
("WW-010", "Deluxe Widget Turbine", "Premium ventilated widget, balanced rotor.", 34.99m, 70),
("WW-011", "Mega Widget Block", "Oversized widget for heavy-duty jobs.", 49.99m, 60),
("WW-012", "Mega Widget Rotary", "Oversized dial widget for heavy-duty jobs.", 54.49m, 55),
("WW-013", "Mega Widget Valve", "Oversized inline widget, high-flow ports.", 59.99m, 45),
("WW-014", "Mega Widget Hub", "Oversized four-port widget for busy lines.", 64.99m, 40),
("WW-015", "Mega Widget Turbine", "Oversized ventilated widget, high throughput.", 69.99m, 35),
("WW-016", "Mini Widget Block", "Compact widget for tight spaces.", 4.99m, 500),
("WW-017", "Mini Widget Rotary", "Compact dial widget for tight spaces.", 5.99m, 460),
("WW-018", "Mini Widget Valve", "Compact inline widget, low-flow ports.", 6.49m, 420),
("WW-019", "Mini Widget Hub", "Compact four-port widget for tight spaces.", 7.49m, 380),
("WW-020", "Mini Widget Turbine", "Compact ventilated widget, quiet running.", 8.49m, 340),
("WW-021", "Widget Pro Kit", "Bundle of assorted widgets and accessories.", 79.99m, 40),
("WW-022", "Widget Starter Kit", "Open-tray bundle for a first build.", 39.99m, 90),
("WW-023", "Widget Builder Kit", "Three-drawer cabinet of sorted widgets.", 99.99m, 30),
("WW-024", "Widget Travel Kit", "Soft-sided bundle for work away from the bench.", 49.99m, 60),
("WW-025", "Widget Master Kit", "Two-case bundle covering the full range.", 149.99m, 20),
];

public async Task SeedAsync(SeedOptions options, CancellationToken ct)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,15 @@ public async Task Seeding_stocks_the_demo_catalog_and_repeats_safely()
await Seeder.SeedAsync(Options(Guid.NewGuid().ToString("N")[..8]), CancellationToken.None);

var standard = await widgets.GetBySkuAsync("WW-001", CancellationToken.None);
Assert.Equal("Standard Widget", standard!.Name);
Assert.Equal("Standard Widget Block", standard!.Name);
Assert.Equal(9.99m, standard.Price);

await Seeder.SeedAsync(Options(Guid.NewGuid().ToString("N")[..8]), CancellationToken.None);

// Still one row per SKU after a second run.
Assert.Equal(1, await widgets.CountAsync(new WidgetQuery("Standard Widget", true, 1, 50), CancellationToken.None));
// Still one row per SKU after a second run. The search has to name a whole
// product: each department seeds five widgets, so "Standard Widget" on its own
// now matches all five of them.
Assert.Equal(1, await widgets.CountAsync(new WidgetQuery("Standard Widget Block", true, 1, 50), CancellationToken.None));
}

[Fact]
Expand Down
2 changes: 1 addition & 1 deletion web/public/products/widget.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion web/public/products/ww-001.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion web/public/products/ww-002.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion web/public/products/ww-003.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion web/public/products/ww-004.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion web/public/products/ww-005.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading