public void Search_CostType_Test() { using (EntityframeworkContext context = new EntityframeworkContext()) { var model = context.Context.Set <CostType>().First(p => p.Id == 1); Assert.AreEqual(3, model.ChildTypes.Count); } }
public void Create_Account_Test() { using (EntityframeworkContext context = new EntityframeworkContext()) { var model = new Account("Tony", "123456"); context.RegisterNew <Account, int>(model); context.Commit(); Assert.AreNotEqual(0, model.Id); } }
public void Create_Member_Test() { using (EntityframeworkContext context = new EntityframeworkContext()) { var account = context.Context.Set <Account>().Find(1); var model = new Member(account, "Tony.xie", 24); context.RegisterNew <Member, Guid>(model); context.Commit(); Assert.AreNotEqual(Guid.Empty, model.Id); } }
public void Search_MonthIncome_Test() { using (EntityframeworkContext context = new EntityframeworkContext()) { var incomes = context.Context.Set <MonthIncome>() //.Include(p => p.Items) .First(p => p.Id.Equals(new Guid("88434521-0244-E411-8250-005056C00008"))); Assert.IsNotNull(incomes); Assert.AreEqual(incomes.Items.Count, 2); } }
public void Update_CostType_Test() { using (EntityframeworkContext context = new EntityframeworkContext()) { var model = context.Context.Set <CostType>().Find(1); model.ChangeName("生活消费"); context.RegisterModified <CostType, int>(model); context.Commit(); Assert.AreEqual("生活消费", model.Name); } }
public void Update_Account_Test() { using (EntityframeworkContext context = new EntityframeworkContext()) { var model = context.Context.Set <Account>().Find(1); model.RegisterEmail = "*****@*****.**"; context.RegisterModified <Account, int>(model); context.Commit(); Assert.AreEqual("*****@*****.**", model.RegisterEmail); } }
public void Update_Expand_Test() { using (EntityframeworkContext context = new EntityframeworkContext()) { var id = Guid.Parse("20A7115F-2346-E411-8843-005056C00008"); var model = context.Context.Set <Expand>().First(p => p.Id.Equals(id)); model.Describtion = "水电费"; context.RegisterModified <Expand, Guid>(model); context.Commit(); Assert.AreEqual("水电费", model.Describtion); } }
public void Create_Expand_Test() { using (EntityframeworkContext context = new EntityframeworkContext()) { var costType = context.Context.Set <CostType>().First(p => p.ParentType != null); var member = context.Context.Set <Member>().First(); var model = new Expand(costType, 80, member, ""); context.RegisterNew <Expand, Guid>(model); context.Commit(); Assert.AreNotEqual(Guid.Empty, model.Id); } }
public void Create_CostType_Test() { using (EntityframeworkContext context = new EntityframeworkContext()) { var model = new CostType("生活开支", null); model.AddChildType(new CostType("水电气费", model)); model.AddChildType(new CostType("交通费", model)); model.AddChildType(new CostType("日常开支", model)); context.RegisterNew <CostType, int>(model); context.Commit(); Assert.AreNotEqual(0, model.Id); } }
public void Update_Member_Test() { using (EntityframeworkContext context = new EntityframeworkContext()) { var model = context.Context.Set <Member>().Find(Guid.Parse("81B0D18F-3243-E411-8282-005056C00008")); model.ChangeContact(new Contact() { Email = "*****@*****.**", QQ = "350357474" }); context.RegisterModified <Member, Guid>(model); context.Commit(); Assert.AreEqual(model.Contact.Email, "*****@*****.**"); } }
public void Create_MonthIncome_Test() { using (EntityframeworkContext context = new EntityframeworkContext()) { Member member = context.Context.Set <Member>().First(); var model = new MonthIncome(); model.AddItems(new List <IncomeItem>() { new IncomeItem(200, member, model), new IncomeItem(300, member, IncomeType.Other, model) }); context.RegisterNew <MonthIncome, Guid>(model); context.Commit(); Assert.AreNotEqual(Guid.Empty, model.Id); } }
public void Create_Database_Test() { EntityframeworkContext context = new EntityframeworkContext(); context.Context.Database.Initialize(true); }