using RobotNet10.FleetManager.Data; using RobotNet10.FleetManager.Shared.Enums; namespace RobotNet10.RobotManager.Test.Helpers; /// /// Helper methods for creating test data /// public static class TestHelpers { /// /// Creates a test RobotModel entity /// public static RobotModel CreateTestRobotModel( Guid? id = null, string? modelName = null, double length = 1.0, double width = 0.5, int imageWidth = 800, int imageHeight = 600, double navigationPointX = 0.0, double navigationPointY = 0.0, NavigationType navigationType = NavigationType.Differential) { return new RobotModel { Id = id ?? Guid.NewGuid(), ModelName = modelName ?? "TestModel", Length = length, Width = width, ImageWidth = imageWidth, ImageHeight = imageHeight, NavigationPointX = navigationPointX, NavigationPointY = navigationPointY, NavigationType = navigationType, CreatedDate = DateTime.UtcNow }; } /// /// Creates a test Robot entity /// public static Robot CreateTestRobot( Guid? id = null, string? robotId = null, string? name = null, Guid? modelId = null, Guid? mapId = null) { return new Robot { Id = id ?? Guid.NewGuid(), RobotId = robotId ?? "ROBOT-001", Name = name ?? "Test Robot", ModelId = modelId ?? Guid.NewGuid(), MapId = mapId, CreatedDate = DateTime.UtcNow }; } /// /// Seeds test data into the database context /// public static void SeedTestData(ApplicationDbContext context) { var model1 = CreateTestRobotModel( id: Guid.Parse("11111111-1111-1111-1111-111111111111"), modelName: "AMR-T800", length: 1.2, width: 0.8); var model2 = CreateTestRobotModel( id: Guid.Parse("22222222-2222-2222-2222-222222222222"), modelName: "AMR-F500", length: 1.0, width: 0.6, navigationType: NavigationType.Forklift); context.RobotModels.AddRange(model1, model2); var robot1 = CreateTestRobot( id: Guid.Parse("33333333-3333-3333-3333-333333333333"), robotId: "ROBOT-001", name: "Robot 1", modelId: model1.Id); var robot2 = CreateTestRobot( id: Guid.Parse("44444444-4444-4444-4444-444444444444"), robotId: "ROBOT-002", name: "Robot 2", modelId: model1.Id); var robot3 = CreateTestRobot( id: Guid.Parse("55555555-5555-5555-5555-555555555555"), robotId: "ROBOT-003", name: "Robot 3", modelId: model2.Id); context.Robots.AddRange(robot1, robot2, robot3); context.SaveChanges(); } }