diff --git a/backend/api.test/Mocks/EchoServiceMock.cs b/backend/api.test/Mocks/EchoServiceMock.cs index 391d73404..480707196 100644 --- a/backend/api.test/Mocks/EchoServiceMock.cs +++ b/backend/api.test/Mocks/EchoServiceMock.cs @@ -3,6 +3,7 @@ using System.Threading; using System.Threading.Tasks; using Api.Controllers.Models; +using Api.Database.Models; using Api.Services; namespace Api.Test.Mocks { @@ -21,16 +22,6 @@ public class MockEchoService : IEchoService } ]; - public EchoMission MockEchoMission = - new() - { - Id = 1, - Name = "test", - InstallationCode = "testInstallation", - URL = new Uri("https://www.I-am-echo-stid-tag-url.com"), - Tags = new List() - }; - public CondensedEchoMissionDefinition MockMissionDefinition = new() { @@ -47,7 +38,25 @@ public async Task> GetAvailableMissions(st public async Task GetMissionById(int missionId) { await Task.Run(() => Thread.Sleep(1)); - return MockEchoMission; + + var mockEchoMission = new EchoMission + { + Id = missionId, + Name = "test", + InstallationCode = "testInstallation", + URL = new Uri("https://testurl.com"), + Tags = new List{new() { + Id = 1, + TagId = "testTag", + Pose = new Pose(), + Inspections = new List{new() { + InspectionType = InspectionType.Image, + InspectionPoint = new Position{X=1, Y=1, Z=1} + }} + }} + }; + + return mockEchoMission; } public async Task> GetEchoPlantInfos() diff --git a/backend/api.test/Mocks/StidServiceMock.cs b/backend/api.test/Mocks/StidServiceMock.cs index 4086900bd..b28fd1aef 100644 --- a/backend/api.test/Mocks/StidServiceMock.cs +++ b/backend/api.test/Mocks/StidServiceMock.cs @@ -1,9 +1,14 @@ -using System.Threading.Tasks; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Api.Database.Context; using Api.Database.Models; +using Microsoft.EntityFrameworkCore; namespace Api.Services { - public class MockStidService : IStidService + public class MockStidService(FlotillaDbContext context) : IStidService { public const string ServiceName = "StidApi"; @@ -16,5 +21,62 @@ public async Task GetTagPosition(string tag, string installationCode) z: 0 ); } + + public virtual async Task GetTagArea(string tag, string installationCode) + { + await Task.CompletedTask; + string testAreaName = "StidServiceMockArea"; + + var area = context.Areas.Include(a => a.SafePositions) + .Include(a => a.Deck).Include(d => d.Plant) + .Include(i => i.Installation).Include(d => d.DefaultLocalizationPose) + .Where(area => area.Name.Contains(testAreaName)).ToList().FirstOrDefault(); + if (area != null) { return area; } + + var testInstallation = new Installation + { + Id = Guid.NewGuid().ToString(), + Name = "StidServiceMockInstallation", + InstallationCode = "TTT" + }; + + var testPlant = new Plant + { + Id = Guid.NewGuid().ToString(), + Installation = testInstallation, + Name = "StidServiceMockPlant", + PlantCode = "TTT" + }; + + var testDeck = new Deck + { + Id = Guid.NewGuid().ToString(), + Plant = testPlant, + Installation = testPlant.Installation, + DefaultLocalizationPose = new DefaultLocalizationPose(), + Name = "StidServiceMockDeck" + }; + + var testArea = new Area + { + Id = Guid.NewGuid().ToString(), + Deck = testDeck, + Plant = testDeck.Plant, + Installation = testDeck.Plant.Installation, + Name = testAreaName, + MapMetadata = new MapMetadata(), + DefaultLocalizationPose = new DefaultLocalizationPose(), + SafePositions = new List() + }; + + context.Add(testInstallation); + context.Add(testPlant); + context.Add(testDeck); + context.Add(testArea); + + await context.SaveChangesAsync(); + + return testArea; + } } } diff --git a/backend/api.test/api.test.csproj b/backend/api.test/api.test.csproj index 70546a708..1d256fba4 100644 --- a/backend/api.test/api.test.csproj +++ b/backend/api.test/api.test.csproj @@ -12,7 +12,7 @@ - + all