public void UnitTest5() { var context = new CalDavContext(); var user1 = context.Users.First(); var id = user1.UserId; context.Users.Remove(user1); context.SaveChanges(); Assert.Null(context.Users.FirstOrDefault(x => x.UserId == id)); }
public void UnitTest4() { using (var context = new CalDavContext()) { var prinRepository = new PrincipalRepository(context); prinRepository.CreateStudentInSystem("*****@*****.**", "Student1", _password, _career, _group, _year); context.SaveChanges(); var user = context.Students.FirstOrDefaultAsync(x => x.Email == _email && x.Career == _career); Assert.NotNull(user); } }
public void UnitTest8() { using (var cont = new CalDavContext()) { var col = new CalendarCollection(SystemProperties._groupCollectionUrl + _group + "/", $"Group {_group} Calendar"); cont.CalendarCollections.Add(col); cont.SaveChanges(); // Assert.NotNull(cont.CalendarCollections.FirstOrDefault(x=>x.Group == _group)); } }
public void UnitTest7() { using (var _ctx = new CalDavContext()) { var principal = new Principal { PrincipalURL = SystemProperties._userPrincipalUrl + _email }; _ctx.Principals.Add(principal); _ctx.SaveChanges(); //Assert.NotNull(_ctx.Principals.FirstOrDefault(p=>p.Displayname == "Adriano Flechilla")); } }
public void UnitTest9() { var context = new CalDavContext(new DbContextOptions <CalDavContext>()); var prinRepository = new PrincipalRepository(context); var user = prinRepository.CreateWorkerInSystem("*****@*****.**", "worker", "UnitTest9 worker", _faculty, "Weboo"); context.SaveChanges(); Assert.True(context.Workers.Count() > 0); var worker = context.Workers.FirstOrDefault(x => x.Email == "*****@*****.**"); Assert.NotNull(worker); Assert.NotNull(context.Principals.FirstOrDefault(x => x.PrincipalId == worker.PrincipalId.Value)); Assert.NotNull(context.CalendarCollections.FirstOrDefault(x => x.PrincipalId == worker.PrincipalId.Value)); }
public async Task UnitTest1() { var context = new CalDavContext(new DbContextOptions <CalDavContext>()); var prinRepository = new PrincipalRepository(context); var user = prinRepository.CreateUserInSystem(_email, _fullName, _password); Assert.NotNull(user); context.SaveChanges(); Assert.True(context.Users.Any()); var dbUser = context.Users.FirstOrDefault(x => x.Email == _email); Assert.NotNull(dbUser); Assert.True(await prinRepository.ExistByStringIs(_email)); }
public void Add(Principal entity) { _context.Principals.Add(entity); _context.SaveChanges(); }