public void NotAuthenticate() { using (var db = new MainAuthExampleContext(_options)) { var authService = new AuthenticateService(db); var result = authService.Authenticate(new AnonymousUser("userNotExists", "pass1")); Assert.Null(result); } }
public void Authenticate() { User result = null; using (var db = new MainAuthExampleContext(_options)) { if (!db.Users.Where(u => u.Username.Equals("user1")).Any()) { db.Users.Add(new UserAuthenticationsEntity { Username = "******", Password = "******" }); db.SaveChanges(); } var authService = new AuthenticateService(db); result = authService.Authenticate(new AnonymousUser("user1", "pass1")); } Assert.Equal(new Employee("user1"), result); }