Add ActiveDevice + DeviceRegistry + HubEnvelopes + IDeviceClient/Channel implementations
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
using System.Net.WebSockets;
|
||||
using backend.DeviceHub;
|
||||
using FluentAssertions;
|
||||
using Xunit;
|
||||
|
||||
namespace backend.tests;
|
||||
|
||||
public class DeviceRegistryTests
|
||||
{
|
||||
[Fact]
|
||||
public void Register_unregister_round_trip()
|
||||
{
|
||||
var reg = new DeviceRegistry();
|
||||
var id = Guid.NewGuid();
|
||||
var dev = new ActiveDevice(id, new ClientWebSocket());
|
||||
reg.TryRegister(dev).Should().BeTrue();
|
||||
reg.TryRegister(dev).Should().BeFalse();
|
||||
reg.IsOnline(id).Should().BeTrue();
|
||||
reg.OnlineCount.Should().Be(1);
|
||||
|
||||
reg.Unregister(id).Should().BeTrue();
|
||||
reg.IsOnline(id).Should().BeFalse();
|
||||
reg.OnlineCount.Should().Be(0);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user