-
Notifications
You must be signed in to change notification settings - Fork 0
/
apilog.test.cs
61 lines (48 loc) · 1.68 KB
/
apilog.test.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
using Microsoft.Extensions.Configuration;
using NUnit.Framework;
using System;
using System.Collections.Generic;
namespace LeafTests
{
public class ApiLogtest
{
IConfiguration _config;
[SetUp]
public void Setup()
{
var builder = new ConfigurationBuilder()
.SetBasePath(@"C:\Projects\LeafTests")
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);
_config = builder.Build();
Tools.InitDatabase(_config);
}
[Test]
public void NewLog()
{
Leaf.Models.ApiLog apilog = new Leaf.Models.ApiLog(_config);
apilog.Id = "testhash";
apilog.Method = "POST";
apilog.Headers = Newtonsoft.Json.JsonConvert.SerializeObject("Headers");
apilog.Scheme = "scheme";
apilog.Host = "HOST";
apilog.Path = "/url/get";
apilog.QueryString = Newtonsoft.Json.JsonConvert.SerializeObject("querystring");
apilog.RemoteIPAdress = "Remote ip address";
apilog.Response = Newtonsoft.Json.JsonConvert.SerializeObject("preresponse");
Assert.IsNotNull(apilog.Create());
}
[Test]
public void GetLogById()
{
Leaf.Models.ApiLog apilog = new Leaf.Models.ApiLog("da8b4d2db8738078c9a1cd7882eb76dd", _config);
Assert.IsNotNull(apilog);
}
[Test]
public void SaveLog()
{
Leaf.Models.ApiLog apilog = new Leaf.Models.ApiLog("da8b4d2db8738078c9a1cd7882eb76dd", _config);
apilog.Response = "200 OK";
Assert.IsNotNull(apilog.Save());
}
}
}