public async Task SetAliasForAppliance_ClearAlias_Succeeds() { (await _client.AuthenticateUserAsync("mwilson", "password")).AddAuthorization(_httpClient); SuccessfulRequestDto response = null; Assert.Null(await Record.ExceptionAsync(async() => response = await _client.Customer_SetAliasForApplianceAsync( new SetAliasForApplianceDto { Alias = "ApplianceAlias", ApplianceId = 20501 }))); Assert.NotNull(response); SuccessfulRequestDto response1 = null; Assert.Null(await Record.ExceptionAsync(async() => response1 = await _client.Customer_SetAliasForApplianceAsync( new SetAliasForApplianceDto { Alias = null, ApplianceId = 20501 }))); Assert.NotNull(response1); CustomerAppliancesDto response2 = null; Assert.Null(await Record.ExceptionAsync(async() => response2 = await _client.Customer_GetAppliancesAsync())); Assert.NotNull(response2); Assert.Contains(response2.Appliances, x => x.ApplianceName == null && x.ApplianceId == 20501); }
public async Task GetAppliances_ValidRequest_Succeeds() { using (var context = _factory.GetKIOTContext()) { var type = context.ApplianceTypes.SingleOrDefault(x => x.ApplianceTypeId == 1); if (type == null) { type = new ApplianceType(1, "TestAppliance"); context.ApplianceTypes.Add(type); context.SaveChanges(); } context.CustomerAppliances.Add(new CustomerAppliance(20501, "TestAlias", -1, type)); context.SaveChanges(); } (await _client.AuthenticateUserAsync("mwilson", "password")).AddAuthorization(_httpClient); CustomerAppliancesDto response = null; Assert.Null(await Record.ExceptionAsync(async() => response = await _client.Customer_GetAppliancesAsync())); Assert.NotNull(response); Assert.NotEmpty(response.Appliances); Assert.Contains(response.Appliances, x => x.ApplianceId == 20501 && x.ApplianceName == "TestAlias"); }