public async Task TestEnableAutoSaveAsync() { var e = new Enforcer("examples/basic_model.conf", "examples/basic_policy.csv"); e.EnableAutoSave(false); // Because AutoSave is disabled, the policy change only affects the policy in Casbin enforcer, // it doesn't affect the policy in the storage. await e.RemovePolicyAsync("alice", "data1", "read"); // Reload the policy from the storage to see the effect. await e.LoadPolicyAsync(); TestEnforce(e, "alice", "data1", "read", true); TestEnforce(e, "alice", "data1", "write", false); TestEnforce(e, "alice", "data2", "read", false); TestEnforce(e, "alice", "data2", "write", false); TestEnforce(e, "bob", "data1", "read", false); TestEnforce(e, "bob", "data1", "write", false); TestEnforce(e, "bob", "data2", "read", false); TestEnforce(e, "bob", "data2", "write", true); e.EnableAutoSave(true); // Because AutoSave is enabled, the policy change not only affects the policy in Casbin enforcer, // but also affects the policy in the storage. await e.RemovePolicyAsync("alice", "data1", "read"); // However, the file adapter doesn't implement the AutoSave feature, so enabling it has no effect at all here. // Reload the policy from the storage to see the effect. await e.LoadPolicyAsync(); TestEnforce(e, "alice", "data1", "read", true); // Will not be false here. TestEnforce(e, "alice", "data1", "write", false); TestEnforce(e, "alice", "data2", "read", false); TestEnforce(e, "alice", "data2", "write", false); TestEnforce(e, "bob", "data1", "read", false); TestEnforce(e, "bob", "data1", "write", false); TestEnforce(e, "bob", "data2", "read", false); TestEnforce(e, "bob", "data2", "write", true); }