public async Task ShouldUpdateAutomation() { // arrange var automation = new AutomationObject { Id = AutomationId, Alias = $"test_automation_{AutomationId}", Description = $"This is an updated test automation {DateTime.Now.ToLongDateString()}", Actions = new List <Dictionary <string, object> >() { new Dictionary <string, object>() { { "entity_id", "switch.switch" }, { "service", "switch.turn_off" } } } }; var client = ClientFactory.GetClient <AutomationClient>(); // act var result = await client.Update(automation); // assert Assert.IsNotNull(result); Assert.AreEqual("ok", result.Result); }
public async Task OneTimeSetUp() { // arrange AutomationId = Guid.NewGuid().ToString(); Instance = new Uri(Environment.GetEnvironmentVariable("HADotNet:Tests:Instance")); ApiKey = Environment.GetEnvironmentVariable("HADotNet:Tests:ApiKey"); ClientFactory.Initialize(Instance, ApiKey); var client = ClientFactory.GetClient <AutomationClient>(); var automation = new AutomationObject { Id = AutomationId, Alias = $"test_automation_{AutomationId}", Description = $"This is a test automation {DateTime.Now.ToLongDateString()}", Actions = new List <Dictionary <string, object> >() { new Dictionary <string, object>() { { "entity_id", "switch.switch" }, { "service", "switch.turn_on" } } } }; // act var result = await client.Create(automation); // assert Assert.IsNotNull(result); Assert.AreEqual("ok", result.Result); }
/// <summary> /// Update the <see cref="AutomationObject"/>. /// </summary> /// <param name="automation">The <see cref="AutomationObject"/>.</param> /// <returns>The <see cref="AutomationResultObject"/>.</returns> public async Task <AutomationResultObject> Update(AutomationObject automation) => await Create(automation);
/// <summary> /// Create the <see cref="AutomationObject"/>. /// </summary> /// <param name="automation">The <see cref="AutomationObject"/>.</param> /// <returns>The <see cref="AutomationResultObject"/>.</returns> public async Task <AutomationResultObject> Create(AutomationObject automation) => await Post <AutomationResultObject>($"/api/config/automation/config/{automation.Id}", automation);