public async Task PutItem() { var connection = new SqliteConnection("DataSource=:memory:"); try { new DbInitializer().Initialize(connection, GetPropertyContext, UomTestData.GetInitialData()); using (var context = GetPropertyContext(connection)) { var uomRepository = new UomWriteRepository(context); var itemToPut = new Uom(3, "cubits", "The description"); await uomRepository.PutAsync(itemToPut); var uoms = await context.Uoms.OrderBy(u => u.Name).ToListAsync(); Assert.NotNull(uoms); Assert.AreEqual(UomTestData.GetUomsArray().Length, uoms.Count); Assert.True(UomEqual.Check(itemToPut, uoms[0])); } } finally { connection.Close(); } }
public void PutNullItem() { var connection = new SqliteConnection("DataSource=:memory:"); try { new DbInitializer().Initialize(connection, GetPropertyContext, UomTestData.GetInitialData()); using (var context = GetPropertyContext(connection)) { var uomRepository = new UomWriteRepository(context); Assert.ThrowsAsync <ArgumentNullException> ( async() => await uomRepository.PutAsync(null) ); } } finally { connection.Close(); } }