Skip to content

Commit

Permalink
Fix Unit Tests
Browse files Browse the repository at this point in the history
#46 non-breaking
  • Loading branch information
tthiery committed Aug 1, 2020
1 parent 3a4f709 commit a7a0028
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions test/SharpBrick.PoweredUp.Test/Devices/VoltageTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,16 @@ await mock.WriteUpstreamAsync(new PortInputFormatSingleMessage()
{
var serviceProvider = new ServiceCollection()
.AddLogging()
.AddSingleton<PoweredUpBluetoothAdapterMock>()
.AddSingleton<IPoweredUpBluetoothAdapter, PoweredUpBluetoothAdapterMock>()
.AddSingleton<BluetoothKernel>()
.AddSingleton<IPoweredUpProtocol, PoweredUpProtocol>()
.AddSingleton<IDeviceFactory, DeviceFactory>() // for protocol knowledge init

.BuildServiceProvider();

var poweredUpBluetoothAdapterMock = serviceProvider.GetService<PoweredUpBluetoothAdapterMock>();
var poweredUpBluetoothAdapterMock = serviceProvider.GetService<IPoweredUpBluetoothAdapter>() as PoweredUpBluetoothAdapterMock;

var kernel = ActivatorUtilities.CreateInstance<BluetoothKernel>(serviceProvider, (IPoweredUpBluetoothAdapter)poweredUpBluetoothAdapterMock, (ulong)0);
var protocol = ActivatorUtilities.CreateInstance<PoweredUpProtocol>(serviceProvider, kernel);
var protocol = serviceProvider.GetService<IPoweredUpProtocol>();

protocol.ConnectAsync().Wait();

Expand Down

0 comments on commit a7a0028

Please sign in to comment.