public void AddNewDevicesToCollection( [Frozen] Mock <ISystemImagingDevices <ScannerSettings> > systemDevices, [Frozen, CollectionSize(4)] IEnumerable <ScannerSettings> scannerSettings, ScannerSettings newScannerSettings) { systemDevices .Setup(mock => mock.GetDeviceSettings()) .Returns(scannerSettings); var sut = new ScanningDevices(null, systemDevices.Object); var initalDevices = sut.Devices; // Add an extra scanner to the collection scannerSettings = scannerSettings.Append(newScannerSettings); var scannerProperties = new List <IDictionary <string, object> >(); foreach (var deviceID in sut.Devices.Select(d => d.DeviceID).Append(newScannerSettings.Id)) { scannerProperties.Add(new Dictionary <string, object>() { { "Unique Device ID", deviceID } }); } systemDevices .Setup(mock => mock.GetDeviceProperties()) .Returns(scannerProperties); systemDevices .Setup(mock => mock.GetDeviceSettings()) .Returns(scannerSettings); sut.RefreshDevices(); sut.Devices .Should().HaveCount(5) .And.Contain(initalDevices); sut.Devices .Any(d => d.DeviceID == newScannerSettings.Id) .Should().BeTrue(); }
public void DisconnectSingleDeviceIfNotFound( [Frozen] Mock <ISystemImagingDevices <ScannerSettings> > systemDevices, [Frozen] IEnumerable <ScannerSettings> scannerSettings) { systemDevices .Setup(mock => mock.GetDeviceSettings()) .Returns(scannerSettings); var sut = new ScanningDevices(null, systemDevices.Object); var initalDevices = sut.Devices; // Add the existing DeviceIds except one so the device will appear disconnected var scannerProperties = new List <IDictionary <string, object> >(); foreach (var deviceID in sut.Devices.Skip(1).Select(d => d.DeviceID)) { scannerProperties.Add(new Dictionary <string, object>() { { "Unique Device ID", deviceID } }); } systemDevices .Setup(mock => mock.GetDeviceProperties()) .Returns(scannerProperties); sut.RefreshDevices(); sut.Devices .Should().HaveCount(3) .And.BeEquivalentTo(initalDevices); sut.Devices .Skip(1).All(device => device.IsConnected) .Should().BeTrue(); sut.Devices .First().IsConnected .Should().BeFalse(); }
public void DisconnectAllDevicesIfNotFound([Greedy] ScanningDevices sut) { sut.RefreshDevices(); sut.Devices.All(device => !device.IsConnected).Should().BeTrue(); }