public void CreateVersionWithArrangement() { int arrangementId; using (DatabaseContext ctx = new DatabaseContext()) { var arrangementDao = ctx.GetRepository<ArrangementRepository>(); Arrangement arrangement = arrangementDao.Add(); arrangement.BpNumber = "123456789"; arrangement.Name = "Koops"; ctx.SaveChanges(); arrangementId = arrangement.Id; } using (DatabaseContext ctx = new DatabaseContext()) { var arrangementDao = ctx.GetRepository<ArrangementRepository>(); var versionDao = ctx.GetRepository<ArrangementVersionRepository>(); var arrangement = arrangementDao.GetSingle(a => a.Id == arrangementId); ArrangementVersion version = versionDao.Add(); version.Version = 1; arrangement.Versions.Add(version); ctx.SaveChanges(); } using (DatabaseContext ctx = new DatabaseContext()) { var arrangementDao = ctx.GetRepository<ArrangementRepository>(); var arrangement = arrangementDao.GetSingle(a => a.Id == arrangementId); Assert.IsNotEmpty(arrangement.Versions); Assert.AreEqual(1, arrangement.Versions.Single().Id); ctx.SaveChanges(); } }
public void CreateUserWithMultipleArrangements() { Arrangement arr1, arr2; using (DatabaseContext ctx = new DatabaseContext()) { var arrangementDao = ctx.GetRepository<ArrangementRepository>(); { arr1 = arrangementDao.Add(); arr1.BpNumber = "1"; arr1.Name = "Vendor 1"; arr2 = arrangementDao.Add(); arr2.BpNumber = "2"; arr2.Name = "Vendor 2"; } var userDao = ctx.GetRepository<UserRepository>(); var user = userDao.Add(); { user.FullName = "Everest BV"; user.Email = "*****@*****.**"; user.UserName = "******"; user.Arrangements.Add(arr1); user.Arrangements.Add(arr2); } ctx.SaveChanges(); { Assert.AreEqual("Everest BV", user.FullName); Assert.AreEqual("*****@*****.**", user.Email); Assert.AreEqual("everest_nl", user.UserName); Assert.AreEqual(2, user.Arrangements.Count()); Assert.AreEqual(1, arr1.Users.Count); Assert.AreEqual(1, arr2.Users.Count); } } }
public void CreateVersionWithoutArrangement() { using (DatabaseContext ctx = new DatabaseContext()) { var dao = ctx.GetRepository<ArrangementVersionRepository>(); ArrangementVersion version = dao.Add(); version.Version = 1; // Oeps, no arrangement version is set !! ctx.SaveChanges(); } }
public void CreateUserWithoutArrangement() { using (DatabaseContext ctx = new DatabaseContext()) { var userRepos = ctx.GetRepository<UserRepository>(); var user = userRepos.Add(); { user.Email = "*****@*****.**"; user.FullName = "Everest BV"; user.UserName = "******"; } ctx.SaveChanges(); } }