public void SetLampColorAsync_SetsTheLampColor() { // Arrange string lightId = "lightId221"; string expectedColor = _red; IEnumerable <Light> lightList = new List <Light>() { new Light() { UniqueId = lightId } }; _loggerMock.Setup(m => m.Information(It.Is <string>(a => a.Contains(lightId) && a.Contains(expectedColor)))); _hueClientMock.Setup(m => m.GetLightsAsync()).Returns(Task.FromResult(lightList)); var hueController = new HueController(_loggerMock.Object, _configMock.Object, _hueClientMock.Object); //Act var result = hueController.SetLampColorAsync(expectedColor, lightId); //Assert Assert.IsNotNull(result); _loggerMock.Verify(m => m.Information(It.Is <string>(a => a.Contains(lightId) && a.Contains(expectedColor))), Times.Once); }
public void SetLampColorAsync_SetsTheLampColor() { // Arrange string uniqueId = "lightId221"; string lightId = "1"; string expectedColor = _red; IEnumerable <Light> lightList = new List <Light>() { new Light() { UniqueId = uniqueId, Id = lightId } }; RGBColor rgbColor = new RGBColor(expectedColor); var command = new LightCommand(); command.TurnOn().SetColor(rgbColor); _loggerMock.Setup(m => m.Information(It.Is <string>(a => a.Contains(uniqueId) && a.Contains(expectedColor)))); _hueClientMock.Setup(m => m.GetLightsAsync()).Returns(Task.FromResult(lightList)); _hueClientMock.Setup(m => m.SendCommandAsync(It.IsAny <LightCommand>(), It.Is <IEnumerable <string> >(lc => lc.Contains(lightId)))); var hueController = new HueController(_loggerMock.Object, _configMock.Object, _hueClientMock.Object); //Act var result = hueController.SetLampColorAsync(expectedColor, uniqueId); //Assert Assert.IsNotNull(result); _loggerMock.Verify(m => m.Information(It.Is <string>(a => a.Contains(uniqueId) && a.Contains(expectedColor))), Times.Once); _hueClientMock.Verify(m => m.SendCommandAsync(It.IsAny <LightCommand>(), It.Is <IEnumerable <string> >(lc => lc.Contains(lightId))), Times.Once); }