public void InitialiseSuccessfully() { var path = Path.Combine(TestRootDir, PermissionsMissingTestJson); var permissionRepo = new PermissionRepo(TestRootDir, PermissionsMissingTestJson); var status = permissionRepo.Initialise(); status.Should().BeOfType <Success>(); File.Exists(path).Should().BeTrue(); var fileContent = File.ReadAllText(path); var deserializeObject = JsonConvert.DeserializeObject <Dictionary <UserRole, List <Permission> > >(fileContent); deserializeObject.Should().ContainKeys(UserRole.Administrator, UserRole.Developer, UserRole.Guest, UserRole.ProductOwner); }
public RequestHandlerFactory(IConfiguration configuration) { _handler = new Lazy <RequestHandler>(() => { var rootPath = configuration.GetValue <string>("App:DataRootPath"); var userRepo = new UserRepo(rootPath, "users.json"); var backlogRepo = new BacklogRepo(rootPath); var permissionsRepo = new PermissionRepo(rootPath, "permissions.json"); if (userRepo.Initialise() is Failure || backlogRepo.Initialise() is Failure || permissionsRepo.Initialise() is Failure) { throw new FailedRepositoryCreationException(); } return(new RequestHandler(backlogRepo, new TotalOrder(), userRepo, new Security(), permissionsRepo)); }); }