public void CoordinatesRemove() { var coordsRep = new UsersRepository(); var count = coordsRep.Remove(null); Assert.That(count, Is.EqualTo(0)); }
public void UserRemove() { var userRep = new UsersRepository(); var count = userRep.Remove(null); Assert.That(count, Is.EqualTo(0)); }
public async void CoordinatesCreationAsync() { var coordsRep = new CoordinatesRepository(); var usersRep = new UsersRepository(); var user = await usersRep.CreateAsync(101); var coords = new Coordinates { UserId = user.Id, Date = DateTime.Now }; var putCount = await coordsRep.PutAsync(coords); try { Assert.That(putCount, Is.EqualTo(1)); Assert.That(coords.Id, Is.GreaterThan(0)); var getted = await coordsRep.GetAsync(user.Name); Assert.That(getted.Length, Is.EqualTo(1)); Assert.That(getted[0].Id, Is.EqualTo(coords.Id)); } finally { var count = coordsRep.Remove(coords); Assert.That(count, Is.EqualTo(1)); usersRep.Remove(user); } }
public async void UserValidationAsync() { var userRep = new UsersRepository(); var user = await userRep.CreateAsync(102); try { Assert.That(user.Id, Is.GreaterThan(0)); Assert.That(user.Name, Is.EqualTo(102)); Assert.IsTrue(await userRep.IsUserValid(user.Name, user.Password)); Assert.IsFalse(await userRep.IsUserValid(user.Name + 1, user.Password)); Assert.IsFalse(await userRep.IsUserValid(user.Name, Guid.Empty)); } finally { var count = userRep.Remove(user); Assert.That(count, Is.EqualTo(1)); } }
public async void UserCreationAsync() { var userRep = new UsersRepository(); var user = await userRep.CreateAsync(102); try { Assert.That(user.Id, Is.GreaterThan(0)); Assert.That(user.Name, Is.EqualTo(102)); var changedUser = await userRep.CreateAsync(user.Name); Assert.That(changedUser.Id, Is.EqualTo(user.Id)); Assert.That(changedUser.Password, Is.Not.EqualTo(user.Password)); } finally { var count = userRep.Remove(user); Assert.That(count, Is.EqualTo(1)); } }
public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context) { var userRep = new UsersRepository(); if (!await userRep.IsUserValid(int.Parse(context.UserName), Guid.Parse(context.Password))) { Logger.Trace("Отказано в выдаче токена."); context.SetError("invalid_grant", "Имя пользователя или пароль неправильны."); context.Rejected(); return; } Logger.Trace("Токен выдан."); var identity = new ClaimsIdentity(context.Options.AuthenticationType); identity.AddClaim(new Claim("user_name", context.UserName)); context.Validated(identity); }
public UsersController() { var container = LightInjectCore.Get(); _rep = container.GetInstance<UsersRepository>(); Logger.Trace("Создан контроллер."); }