diff --git a/README.md b/README.md index 006fb0da1d246b419b376bd526ec9bb75c4ffd31..38fb1712054d7fc65578c965d778b8ddba47b1e9 100644 --- a/README.md +++ b/README.md @@ -183,6 +183,9 @@ await devkitConnector.AddSensorData(sensorContracts); * **Areas** * `GetAreas()` - Get all areas * `GetArea(id)` - Get area by ID + * `AddArea(areaContract)` - Add an area with specified properties + * `UpdateArea(areaContract)` - Update an existing area with new properties + * `DeleteArea(id)` - Delete an existing area by ID * **Authorization** * `Authenticate(login, password)` - Authenticate with login and password as user/device/sensor * **Beacons** diff --git a/SDK/Connection/V3/Layers.cs b/SDK/Connection/V3/Layers.cs index ff91eb3ef8b8192265311d13e7e3e7bcb006dea2..5fb8842c20f45570559f56bb069f4cf12d03c6f9 100644 --- a/SDK/Connection/V3/Layers.cs +++ b/SDK/Connection/V3/Layers.cs @@ -47,5 +47,25 @@ namespace SDK return response; } + + public async Task<LayerContract> AddLayer(LayerContract layer) + { + string subUrl = Address.UrlCombine(Address.Layers); + var response = await PostRequest<LayerContract>(subUrl, layer); + + return response; + } + + public async Task UpdateLayer(LayerContract layer) + { + string subUrl = Address.UrlCombine(Address.Layers, Convert.ToString(layer.Id)); + await PatchRequest<LayerContract>(subUrl, layer); + } + + public async Task DeleteLayer(int id) + { + string subUrl = Address.UrlCombine(Address.Layers, Convert.ToString(id)); + await DeleteRequest(subUrl); + } } } diff --git a/SDK/SDK.csproj b/SDK/SDK.csproj index 437f3bd426d03beb130160b68ef56d4aaf80936f..3aa8f8a11ecd64ffbad8149e791d470efca3ed20 100644 --- a/SDK/SDK.csproj +++ b/SDK/SDK.csproj @@ -5,7 +5,7 @@ <TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks> <AssemblyVersion>2021.6.28.25</AssemblyVersion> <FileVersion>2021.6.28.25</FileVersion> - <Version>5.2.0</Version> + <Version>5.3.0</Version> <GeneratePackageOnBuild>true</GeneratePackageOnBuild> </PropertyGroup> diff --git a/Test/Test/V3/Layers.cs b/Test/Test/V3/Layers.cs index 7578b27aeede0dcbf537764e19b556a2c9bb8706..da4ded08d7d3326ed3e26f597aca895116ab2105 100644 --- a/Test/Test/V3/Layers.cs +++ b/Test/Test/V3/Layers.cs @@ -21,19 +21,108 @@ namespace Test.V3 }; server.Given(Request.Create().WithPath(PATH_BASE + LAYERS + "/localization").UsingPost()) - .RespondWith( - Response.Create() - .WithStatusCode(200) - .WithBodyAsJson(new LayerContract[] { + .RespondWith(Response.Create().WithStatusCode(200) + .WithBodyAsJson( + new LayerContract[] { new LayerContract(){ Id = 1, } - }) - ); + })); var response = await devkitConnector.GetLocalizationLayers(bodyContent); + Assert.IsInstanceOfType(response, typeof(LayerContract[])); + } + + [TestCategory("Layer")] + [TestMethod] + public async Task GetNoGoLayers_ShouldReturnLayers() + { + server.Given(Request.Create().WithPath(PATH_BASE + LAYERS + "/device/login").UsingGet()) + .RespondWith(Response.Create().WithStatusCode(200) + .WithBodyAsJson(new LayerContract[] + { + new LayerContract() + { + Id = 1, + } + })); + var response = await devkitConnector.GetNoGoLayers("login"); Assert.IsInstanceOfType(response, typeof(LayerContract[])); } + + [TestCategory("Layer")] + [TestMethod] + public async Task GetLayers_ShouldReturnLayers() + { + server.Given(Request.Create().WithPath(PATH_BASE + LAYERS).UsingGet()) + .RespondWith(Response.Create().WithStatusCode(200) + .WithBodyAsJson(new LayerContract[] + { + new LayerContract() + { + Id = 1, + } + })); + + var response = await devkitConnector.GetLayers(); + Assert.IsInstanceOfType(response, typeof(LayerContract[])); + } + + [TestCategory("Layer")] + [TestMethod] + public async Task GetLayer_ShouldReturnLayer() + { + server.Given(Request.Create().WithPath(PATH_BASE + LAYERS + "/1").UsingGet()) + .RespondWith(Response.Create().WithStatusCode(200) + .WithBodyAsJson(new LayerContract() + { + Id = 1, + })); + + var response = await devkitConnector.GetLayer(1); + Assert.IsInstanceOfType(response, typeof(LayerContract)); + } + + public async Task AddLayer_ShouldReturnLayer() + { + var layer = new LayerContract() + { + Id = 1, + }; + + server.Given(Request.Create().WithPath(PATH_BASE + LAYERS).UsingPost()) + .RespondWith(Response.Create().WithStatusCode(200) + .WithBodyAsJson(layer)); + + var response = await devkitConnector.AddLayer(layer); + Assert.IsInstanceOfType(response, typeof(LayerContract)); + } + + [TestCategory("Layer")] + [TestMethod] + public async Task UpdateLayer_ShouldReturnOk() + { + var layer = new LayerContract() + { + Id = 1, + }; + + server.Given(Request.Create().WithPath(PATH_BASE + LAYERS + "/1").UsingPatch()) + .RespondWith(Response.Create().WithStatusCode(200) + .WithBodyAsJson(layer)); + + await devkitConnector.UpdateLayer(layer); + } + + [TestCategory("Layer")] + [TestMethod] + public async Task DeleteLayer_ShouldReturnOk() + { + server.Given(Request.Create().WithPath(PATH_BASE + LAYERS + "/1").UsingDelete()) + .RespondWith(Response.Create().WithStatusCode(200)); + + await devkitConnector.DeleteLayer(1); + } } }