Skip to content
Snippets Groups Projects
Commit 28298014 authored by Daniel Andrášik's avatar Daniel Andrášik
Browse files

Add log service

parent 8d8fb1a8
No related branches found
No related tags found
No related merge requests found
using SDK.Contracts.Communication;
using SDK.Exceptions;
using SDK.Models;
using System.Threading.Tasks;
namespace SDK
{
public partial class DevkitConnectorV3
{
public async Task<LogContract> AddLog(LogContract logContract)
{
string subUrl = Address.UrlCombine(Address.LogAdd);
return await PostRequest<LogContract>(subUrl, logContract);
}
}
}
using SDK.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
namespace SDK.Contracts.Communication
{
[DataContract]
public class LogContract
{
[DataMember(Order = 1)]
public int Id { get; set; }
[DataMember(Order = 2)]
public int AccountId { get; set; }
[DataMember(Order = 3)]
public string Message { get; set; }
[DataMember(Order = 4)]
public string Level { get; set; }
[DataMember(Order = 5)]
public long Timestamp { get; set; }
[DataMember(Order = 6)]
public int BranchId { get; set; }
[DataMember(Order = 8)]
public string Login { get; set; }
}
}
......@@ -48,6 +48,8 @@ namespace SDK.Models
public const string LocalizationAddData = "localization/";
public const string LocalizationAddDataBatch = "localization/batch/";
public const string LogAdd = "logs";
public const string Sectors = "sectors/";
public const string Sensors = "sensors/";
......
......@@ -5,7 +5,7 @@
<TargetFramework>net5.0</TargetFramework>
<AssemblyVersion>2021.6.28.25</AssemblyVersion>
<FileVersion>2021.6.28.25</FileVersion>
<Version>4.4.0</Version>
<Version>4.5.0</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
</PropertyGroup>
......
......@@ -26,6 +26,7 @@ namespace Test.V3
const string CONFIGURATION = "configuration";
const string DEVICES = "devices";
const string LAYERS = "layers";
const string LOG = "logs";
const string SECTORS = "sectors";
static WireMockServer server;
......@@ -232,7 +233,7 @@ namespace Test.V3
Login = "login"
};
server.Given(Request.Create().WithPath(PATH_BASE + LAYERS + "/localization").UsingPost())
server.Given(Request.Create().WithPath(PATH_BASE + LOG + "/localization").UsingPost())
.RespondWith(
Response.Create()
.WithStatusCode(200)
......@@ -248,6 +249,30 @@ namespace Test.V3
Assert.IsInstanceOfType(response, typeof(LayerContract[]));
}
[TestCategory("Log")]
[TestMethod]
public async Task PostLog_ShouldReturnLogContract()
{
var bodyContent = new LogContract()
{
Login = "login",
AccountId = 1,
Level = "Info",
Message = "message"
};
server.Given(Request.Create().WithPath(PATH_BASE + LOG).UsingPost())
.RespondWith(
Response.Create()
.WithStatusCode(200)
.WithBodyAsJson(bodyContent)
);
var response = await devkitConnector.AddLog(bodyContent);
Assert.IsInstanceOfType(response, typeof(LogContract));
}
[TestCategory("Sector")]
[TestMethod]
public async Task GetSector_GetDeviceByLogin_ShouldReturn200()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment