public async Task DeleteApplianceCategory_CategoryHasAppliances_Succeeds() { Guid guid; using (var context = _factory.GetKIOTContext()) { var category = new ApplianceCategory("TestCategory", -1); guid = category.Guid; Assert.NotEqual(Guid.Empty, guid); context.ApplianceCategories.Add(category); context.SaveChanges(); } (await _client.AuthenticateUserAsync("mwilson", "password")).AddAuthorization(_httpClient); SuccessfulRequestDto dto1 = null; Assert.Null(await Record.ExceptionAsync(async() => dto1 = await _client.Appliance_SetApplianceCategoryAsync(20501, "TestCategory"))); Assert.NotNull(dto1); SuccessfulRequestDto dto2 = null; Assert.NotNull(await Record.ExceptionAsync(async() => dto2 = await _client.Appliance_DeleteApplianceCategoryAsync(guid))); Assert.Null(dto2); using (var context = _factory.GetKIOTContext()) { Assert.Equal(1, context.ApplianceCategories.Count(x => x.Guid == guid)); } }
public async Task DeleteApplianceCategory_CategoryExists_Succeeds() { Guid guid; using (var context = _factory.GetKIOTContext()) { var category = new ApplianceCategory("TestCategory", -1); guid = category.Guid; context.ApplianceCategories.Add(category); context.SaveChanges(); } (await _client.AuthenticateUserAsync("mwilson", "password")).AddAuthorization(_httpClient); Assert.Null(await Record.ExceptionAsync(async() => Assert.NotNull(await _client.Appliance_DeleteApplianceCategoryAsync(guid)))); using (var context = _factory.GetKIOTContext()) { Assert.Equal(0, context.ApplianceCategories.Count(x => x.CustomerId == -1)); } }
public void SetCategory(ApplianceCategory category) { Category = category; }