-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBrightnessSensorConfigTests.cs
49 lines (46 loc) · 2.4 KB
/
BrightnessSensorConfigTests.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
using Microsoft.Extensions.Logging;
using NanoleafAPI;
using NanoleafAPI.API;
using System.Net;
namespace NanoleafAPI_Tests
{
public class BrightnessSensorConfigTests
{
private static ILogger? __logger = null;
const string IP = "192.168.10.152";
const string PORT = "16021";
const string AUTH_TOKEN = "7lOFIqsyqmO8c8H2bYco74z4fK2DmXqK";
[SetUp]
public void Setup()
{
Tools.LoggerFactory = new TestLoggerFactory();
__logger = Tools.LoggerFactory.CreateLogger(nameof(BrightnessSensorConfigTests));
Communication.RegisterIPAddress(IPAddress.Any);
}
[Test]
public async Task TestGetBrightnessSensorConfig()
{
var responseGet = await Communication.GetBrightnessSensorConfig(IP, PORT, AUTH_TOKEN);
Assert.That(responseGet.Success, Is.True);
}
[Test]
public async Task TestSetBrightnessSensorConfig()
{
var responseGet = await Communication.GetBrightnessSensorConfig(IP, PORT, AUTH_TOKEN);
Assert.That(responseGet.Success, Is.True);
Assert.That(responseGet.ResponseValue.BrightnessSensorConfig.HasValue, Is.True);
BrightnessSensorConfig backup = responseGet.ResponseValue.BrightnessSensorConfig.Value;
var responseSet = await Communication.SetBrightnessSensorConfig(IP, PORT, AUTH_TOKEN, new BrightnessSensorConfig(true, EBrightnessMode.Atmospheric, 95, 5));
Assert.That(responseSet.Success, Is.True);
responseGet = await Communication.GetBrightnessSensorConfig(IP, PORT, AUTH_TOKEN);
Assert.That(responseGet.ResponseValue.BrightnessSensorConfig.HasValue, Is.True);
var resValue = responseGet.ResponseValue.BrightnessSensorConfig.Value;
Assert.That(resValue.Enabled, Is.True);
Assert.That(resValue.BrightnessSensorMode, Is.EqualTo(EBrightnessMode.Atmospheric));
Assert.That(resValue.UserMaxBrightness, Is.EqualTo(95));
Assert.That(resValue.UserMinBrightness, Is.EqualTo(5));
responseSet = await Communication.SetBrightnessSensorConfig(IP, PORT, AUTH_TOKEN, new BrightnessSensorConfig(backup.Enabled, backup.BrightnessSensorMode, backup.UserMaxBrightness, backup.UserMinBrightness));
Assert.That(responseSet.Success, Is.True);
}
}
}