public UnitOfWorkTests() { context = new TestingContext(); logger = Substitute.For<IAuditLogger>(); unitOfWork = new UnitOfWork(context, logger); context.Set<TestModel>().RemoveRange(context.Set<TestModel>()); context.SaveChanges(); }
public AuditLoggerTests() { context = new TestingContext(); dataContext = new TestingContext(); TestModel model = ObjectFactory.CreateTestModel(); logger = Substitute.ForPartsOf<AuditLogger>(context); entry = dataContext.Entry<BaseModel>(dataContext.Set<TestModel>().Add(model)); dataContext.Set<TestModel>().RemoveRange(dataContext.Set<TestModel>()); dataContext.SaveChanges(); }
public void FilterById_FromCurrentFilter() { TestingContext context = new TestingContext(); Role role = ObjectFactory.CreateRole(); context.Set<Role>().Add(role); context.SaveChanges(); IUnitOfWork unitOfWork = new UnitOfWork(context); datalist = new BaseDatalistProxy<Role, RoleView>(unitOfWork); datalist.CurrentFilter.Id = role.Id; RoleView expected = unitOfWork.Select<Role>().To<RoleView>().Single(); RoleView actual = datalist.BaseFilterById(null).Single(); Assert.Equal(expected.CreationDate, actual.CreationDate); Assert.Equal(expected.Title, actual.Title); Assert.Equal(expected.Id, actual.Id); }
private Account CreateAccountWithPrivilegeFor(String area, String controller, String action, Boolean isLocked = false) { using (TestingContext context = new TestingContext()) { RolePrivilege rolePrivilege = ObjectFactory.CreateRolePrivilege(); Account account = ObjectFactory.CreateAccount(); account.RoleId = rolePrivilege.RoleId; account.IsLocked = isLocked; account.Role = null; rolePrivilege.Privilege.Controller = controller; rolePrivilege.Privilege.Action = action; rolePrivilege.Privilege.Area = area; context.Set<RolePrivilege>().Add(rolePrivilege); context.Set<Account>().Add(account); context.SaveChanges(); SetUpDependencyResolver(); provider.Refresh(); return account; } }