public void replace_device() { var deviceId = Guid.NewGuid(); var firstDevice = new HOTASDevice(Substitute.For <IDirectInput>(), Guid.Empty, deviceId, "existing device", Substitute.For <IHOTASQueue>()); var replaceDevice = new HOTASDevice(Substitute.For <IDirectInput>(), Guid.Empty, deviceId, "replace device", Substitute.For <IHOTASQueue>()); var subDeviceFactory = Substitute.For <HOTASDeviceFactory>(); subDeviceFactory.CreateHOTASDevice(Arg.Any <IDirectInput>(), Arg.Any <Guid>(), Arg.Any <Guid>(), Arg.Any <string>(), Arg.Any <IHOTASQueue>()).Returns(firstDevice); var list = new HOTASCollection(Substitute.For <DirectInputFactory>(), Substitute.For <JoystickFactory>(), Substitute.For <HOTASQueueFactory>(Substitute.For <IKeyboard>()), subDeviceFactory); firstDevice.ButtonMap.Add(new HOTASButton()); list.AddDevice(firstDevice); var currentDevice = list.Devices.First(d => d.DeviceId == deviceId); Assert.Equal(firstDevice.Name, currentDevice.Name); list.ReplaceDevice(replaceDevice); currentDevice = list.Devices.First(d => d.DeviceId == deviceId); Assert.Equal(replaceDevice.Name, currentDevice.Name); }