public override void Add(ResUser entity) { string salt = SecretHelper.GetSalt(true, 10); entity.UserPwd = SecretHelper.MD5Encrypt(entity.UserPwd, salt); entity.Salt = salt; base.Add(entity); }
public void TestOne2many() { var logger = new Moq.Mock <ILogger <DataAccess> >(); var sp = new Moq.Mock <IServiceProvider>(); var myContext = new Service.Context.XinDBContext(new Microsoft.EntityFrameworkCore.DbContextOptions <Service.Context.XinDBContext>()); sp.Setup((o) => o.GetService(typeof(IEntityContext))).Returns(myContext); sp.Setup((o) => o.GetService(typeof(IRepository <ResUser>))) .Returns(new GenericEntityRepository <ResUser>(logger.Object)); var provider = new UowProvider(logger.Object, sp.Object); using (var uow = provider.CreateUnitOfWork()) { var repository = uow.GetRepository <ResUser>(); var user = repository.Query(x => x.UserName == "admin" && x.UserPwd == SecretHelper.MD5Encrypt("h111111", "h111111")); } }