public void CanAddContractor() { using (EF_ZMT_DbContext.EF_ZMT_DbContext context = new EF_ZMT_DbContext.EF_ZMT_DbContext()) { FixedAssetService transaction = new FixedAssetService(); context.Context.ExecuteStoreCommand("DELETE FROM Contractor"); int count = context.Context.Contractors.Count(); Assert.AreEqual(count, 0); Contractor contractor = new Contractor() { name = "ABC", city = "Kraków", nip = 555123213, postal_code = "31-987", street = "Królewska", country = "Polska" }; transaction.AddContractor(contractor); count = context.Context.Contractors.Count(); Assert.AreEqual(count, 1); Contractor temp = context.Context.Contractors.FirstOrDefault(x => x.name == "ABC"); Assert.IsNotNull(temp); Assert.AreEqual(temp.nip, 555123213); } }
public void CantAddContractorWithoutData() { using(EF_ZMT_DbContext.EF_ZMT_DbContext context = new EF_ZMT_DbContext.EF_ZMT_DbContext()) { context.Context.ExecuteStoreCommand("DELETE FROM Contractor"); FixedAssetService transaction = new FixedAssetService(); Contractor contractor = new Contractor() { name = "ABC", city = "Kraków"}; transaction.AddContractor(contractor); } }
public void CantEditNotExistingContractor() { using (EF_ZMT_DbContext.EF_ZMT_DbContext context = new EF_ZMT_DbContext.EF_ZMT_DbContext()) { FixedAssetService transaction = new FixedAssetService(); context.Context.ExecuteStoreCommand("DELETE FROM Contractor"); int count = context.Context.Contractors.Count(); Assert.AreEqual(count, 0); Contractor contractor = new Contractor() { name = "ABC", city = "Kraków", nip = 555123213, postal_code = "31-987", street = "Królewska", country = "Polska" }; transaction.AddContractor(contractor); Contractor contractor2 = new Contractor() { name = "XXX", city = "Warszawa", nip = 6666666, postal_code = "22-987", street = "Wrocławska", country = "Polska" }; transaction.EditContractor(contractor2); count = context.Context.Contractors.Count(); Assert.AreEqual(count, 1); } }