Пример #1
0
 public User CreateUser()
 {
     var user = new User();
     using (var ctx = new IPContext())
     {
         ctx.Users.Add(user);
         ctx.SaveChanges();
     }
     return user;
 }
Пример #2
0
 public void CreateUser()
 {
     var user = new User()
     {
         //Have to initialize the empty list because otherwise the JSON comparison borks
         //TODO: custom serializer?
         LogEntries = new List<LogEntry>()
     };
     using (var ctx = new IPContext())
     {
         ctx.Users.Add(user);
         ctx.SaveChanges();
     }
     using (var ctx = new IPContext())
     {
         var fromDb = ctx.Users.Find(user.UserId);
         var originalJson = serializer.Serialize(user);
         var fromDbJson = serializer.Serialize(fromDb);
         Assert.IsTrue(CompareJson(originalJson, fromDbJson));
     }
 }