public void Spot_Should_Now_Throw_Exceptions() { // Arrange var miioDevice = GetMiioDevice("app_spot"); var miRobot = new MiRobotV1(miioDevice.Object); // Act miRobot.Spot(); // Assert miioDevice.Verify(x => x.SendMessage("{\"id\": 1, \"method\": \"app_spot\", \"params\": [\"\"]}"), Times.Once()); }
public async Task FindMeAsync_Should_Now_Throw_ExceptionsAsync() { // Arrange var miioDevice = GetMiioDeviceAsync("find_me"); var miRobot = new MiRobotV1(miioDevice.Object); // Act await miRobot.FindMeAsync(); // Assert miioDevice.Verify(x => x.SendMessageAsync("{\"id\": 1, \"method\": \"find_me\", \"params\": [\"\"]}"), Times.Once()); }
public async Task HomeAsync_Should_Now_Throw_ExceptionsAsync() { // Arrange var miioDevice = GetMiioDeviceAsync("app_pause"); miioDevice .Setup(x => x.SendMessageAsync(It.Is <string>(s => s.Contains("app_charge")))) .Returns(Task.FromResult($"{{\"result\":[\"ok\"],\"id\":2}}")); var miRobot = new MiRobotV1(miioDevice.Object); // Act await miRobot.HomeAsync(); // Assert miioDevice.Verify(x => x.SendMessageAsync("{\"id\": 1, \"method\": \"app_pause\", \"params\": [\"\"]}"), Times.Once()); miioDevice.Verify(x => x.SendMessageAsync("{\"id\": 2, \"method\": \"app_charge\", \"params\": [\"\"]}"), Times.Once()); }
public void ToString_Returns_Valid_State() { // Arrange var response = "{\"result\":[{\"msg_ver\":8,\"msg_seq\":54,\"state\":8,\"battery\":100,\"clean_time\":729,\"clean_area\":9795000,\"error_code\":0,\"map_present\":1,\"in_cleaning\":0,\"fan_power\":60,\"dnd_enabled\":0}],\"id\":6}\0"; var miioDevice = GetMiioDevice("get_status", response); var miRobot = new MiRobotV1(miioDevice.Object); // Act var str = miRobot.ToString(); // Assert miioDevice.Verify(x => x.SendMessage("{\"id\": 1, \"method\": \"get_status\", \"params\": [\"\"]}"), Times.Once()); Assert.Equal($"Model: rockrobo.vacuum.v1\nState: Charging\n" + $"Battery: 100 %\nFanspeed: 60 %\n" + $"Cleaning since: 729 seconds\n" + $"Cleaned area: 9.795 m²\n" + $"IP Address: \nToken: ", str); }