예제 #1
0
파일: CRUDTest.cs 프로젝트: Allen-Zhou/AF
        public void Add_SeparateDBTest()
        {
            var category = new Category() { Name = "Add_DemoTest" };
            var vehicle = new Vehicle() { Name = "Add_DemoBTest" };
            using (var repo = RepositoryContext.GetRepository())
            {
                repo.Add(category);

                repo.Add(vehicle);
                Assert.AreEqual(vehicle.SysState, EntityStateEnum.Inserting);
                repo.SaveChanges();
            }

            using (var repo1 = RepositoryContext.GetRepository())
            {
                var addedDemo = repo1.GetByID<Category>(category.ID);
                Assert.IsNotNull(addedDemo);
                Assert.IsTrue(addedDemo.Name == category.Name);

                var addedDemoB = repo1.GetByID<Vehicle>(vehicle.ID);
                Assert.IsNotNull(addedDemoB);
                Assert.IsTrue(addedDemoB.Name == vehicle.Name);
            }
        }
예제 #2
0
파일: CRUDTest.cs 프로젝트: Allen-Zhou/AF
        public void Add_DemoBTest()
        {
            var vehicle = new Vehicle() { Name = "Add_DemoBTest" };
            using (var repo = RepositoryContext.GetRepository())
            {
                repo.Add(vehicle);
                Assert.AreEqual(vehicle.SysState, EntityStateEnum.Inserting);
                repo.SaveChanges();
            }

            using (var repo1 = RepositoryContext.GetRepository())
            {
                var added = repo1.GetByID<Vehicle>(vehicle.ID);
                Assert.IsNotNull(added);
                Assert.IsTrue(added.Name == vehicle.Name);
            }
        }