public void UserWithRolesCreationTest() { using (var db = new IdentityDbContext()) { var role = new Role { Name = "TestRole" }; db.Roles.Add(role); db.SaveChanges(); var user = new User { Email = "asd", FirstName = "el", IsActive = true, LastName = "asd", LastVisitDate = DateTime.Now, Password = "******", RegistrationDate = DateTime.Now, Salt = "asd", Roles = new List<Role> { role } }; db.Users.Add(user); var count = db.SaveChanges(); Assert.AreEqual(2, count); Assert.IsTrue(db.Users.FirstOrDefault(u => u.Id == user.Id).Roles.Contains(role)); } }
public AuthorizationService() { _db = new IdentityDbContext(); }