public void CanDeleteLicence() { using (EF_ZMT_DbContext.EF_ZMT_DbContext context = new EF_ZMT_DbContext.EF_ZMT_DbContext()) { context.Context.ExecuteStoreCommand("DELETE FROM Licence"); context.Context.ExecuteStoreCommand("DELETE FROM MembershipUser"); context.Context.ExecuteStoreCommand("DELETE FROM Kind"); context.Context.ExecuteStoreCommand("DELETE FROM FixedAsset"); FixedAssetService transaction = new FixedAssetService(); FixedAsset asset = new FixedAsset() { id = 2222, inventory_number = "aaaa", date_of_activation = DateTime.Now, cassation = false }; MembershipUser user = new MembershipUser() { login = "******", email = "*****@*****.**", creation_date = DateTime.Now, is_online = false, name = "Jan", surname = "Kowalski", is_active = true, last_login_date = DateTime.Now, password = "******" }; Kind kind = new Kind() { name = "Oprogramowanie" }; Licence licence = new Licence() { inventory_number = "xxxx", name = "Windows XP", created_by = user.login, MembershipUser = user, FixedAsset = asset, Kind = kind, last_modified_login = user.login, last_modified_date = DateTime.Now }; transaction.AddLicence(licence); Assert.AreEqual(context.Context.Licences.Count(), 1); transaction.DeleteLicence(licence); Assert.AreEqual(context.Context.Licences.Count(), 0); licence = context.Context.Licences.FirstOrDefault(x => x.inventory_number == "xxxx"); Assert.IsNull(licence); } }