m new in Unit test and EF Code first Im trying to test function to add data into database by using EF. I dont know whats wrong with my code, it should fail but it Passes Here is m Test function
[TestClass]
public class ProspectControllerTest
{
[TestMethod]
public void Index()
{
DataContext context = new DataContext();
Seller c = new Seller
{
SellerName = "test20",
SellerDivision = "test20",
SellerCity = "City410",
Active = true,
};
context.sellers.Add(c);
context.SaveChanges();
Seller s = (from d in context.sellers
where d.SellerId == c.SellerId
select d).Single();
//This shouldent pass because there is no records in the db !
c.SellerName.Equals(s.SellerName);
}
}
}
Here is m class
public class Seller
{
[Key]
public int SellerId { get; set; }
public string SellerName { get; set; }
public string SellerDiv { get; set; }
public string SellerCity { get; set; }
public Boolean Active { get; set; }
public Div Div { get; set; }
public ICollection<Prospect> prospects { get; set; }
}
Another quastion, Does this test store any data into db ?should i be able to se the records in the database ?
Aucun commentaire:
Enregistrer un commentaire