public SyncDeviceManagerService(ISyncDeviceSpecifications deviceSpecifications, ISyncDiscoveryService discoveryService) { Console.WriteLine("SyncDeviceManagerService - Starting..."); OnStatusUpdated += (status) => {}; OnDeviceUpdated += (device) => {}; OnDevicesUpdated += (devices) => {}; OnDeviceAdded += (device) => {}; OnDeviceRemoved += (device) => {}; _devices = new List<SyncDevice>(); _deviceSpecifications = deviceSpecifications; _discoveryService = discoveryService; _discoveryService.OnDeviceFound += HandleOnDeviceFound; _discoveryService.OnDiscoveryProgress += HandleOnDiscoveryProgress; _webClient = new WebClientTimeout(3000); _webClientRemote = new WebClientTimeout(3000); }
public void InitializeTests() { PrepareExpectedResults(); // Mock HttpService with expected results var httpServiceMock = new Mock<IHttpService>(); // Only one setup is possible per method. httpServiceMock.Setup(m => m.DownloadString(It.IsAny<string>())) .Returns<string>(s => { var key = _devices.Keys.FirstOrDefault(x => s.Contains(x)); return key == null ? null : _devices[key]; }); // Mock HttpServiceFactory to inject the mocked service var httpServiceFactoryMock = new Mock<IHttpServiceFactory>(); httpServiceFactoryMock.Setup(m => m.CreateService(It.IsAny<int>())) .Returns(() => httpServiceMock.Object); _discoveryService = new SyncDiscoveryService(httpServiceFactoryMock.Object); }