本文整理汇总了C#中RhetosTestContainer.AddLogMonitor方法的典型用法代码示例。如果您正苦于以下问题:C# RhetosTestContainer.AddLogMonitor方法的具体用法?C# RhetosTestContainer.AddLogMonitor怎么用?C# RhetosTestContainer.AddLogMonitor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RhetosTestContainer
的用法示例。
在下文中一共展示了RhetosTestContainer.AddLogMonitor方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestPermissionsCachingOnChange
public void TestPermissionsCachingOnChange(Action<Common.ExecutionContext> change, bool[] expectedPermissionsAfterChange, string expectedCacheMisses)
{
using (var container = new RhetosTestContainer(commitChanges: false))
{
var log = new List<string>();
container.AddLogMonitor(log);
container.AddFakeUser(User1Name);
var repository = container.Resolve<Common.DomRepository>();
var context = container.Resolve<Common.ExecutionContext>();
var authorizationManager = container.Resolve<IAuthorizationManager>();
AuthorizationDataCache.ClearCache();
// Get user authorization:
Assert.AreEqual(TestUtility.Dump(new[] { true, true, false }),
TestUtility.Dump(authorizationManager.GetAuthorizations(new[] { Claim1, Claim2, Claim3 })));
Assert.AreEqual("Claims, Principal, PrincipalPermissions, PrincipalRoles, RolePermissions, RolePermissions, RoleRoles, RoleRoles, Roles",
ReportCacheMisses(log, "Initial authorization"), "Initial permission should yield cache misses. See test output log for details.");
// Modify the permissions. Part of the cache might be invalidated:
change(context);
// Get user authorization, with parially invalidated cache:
Assert.AreEqual(TestUtility.Dump(expectedPermissionsAfterChange),
TestUtility.Dump(authorizationManager.GetAuthorizations(new[] { Claim1, Claim2, Claim3 })));
Assert.AreEqual(expectedCacheMisses, ReportCacheMisses(log, "Authorization after cache invalidation"), "See test output log for details.");
}
}
示例2: KeepSynchronizedSimple
public void KeepSynchronizedSimple()
{
using (var container = new RhetosTestContainer())
{
var log = new List<string>();
container.AddLogMonitor(log);
var repository = container.Resolve<Common.DomRepository>();
var doc1 = new Test9.Document { Name = "doc1" };
var doc2 = new Test9.Document { Name = "doc2" };
repository.Test9.Document.Insert(new[] { doc1, doc2 });
container.Resolve<Common.ExecutionContext>().EntityFrameworkContext.ClearCache();
Assert.AreEqual(0, SimpleNumParts(repository, "doc1"), "initial");
container.Resolve<Common.ExecutionContext>().EntityFrameworkContext.ClearCache();
var st1 = new Test9.Part { HeadID = doc1.ID, Name = "st1" };
repository.Test9.Part.Insert(new[] { st1 });
container.Resolve<Common.ExecutionContext>().EntityFrameworkContext.ClearCache();
Assert.AreEqual(1, SimpleNumParts(repository, "doc1"), "after insert detail");
container.Resolve<Common.ExecutionContext>().EntityFrameworkContext.ClearCache();
var st2 = new Test9.Part { HeadID = doc1.ID, Name = "st2" };
repository.Test9.Part.Insert(new[] { st2 });
container.Resolve<Common.ExecutionContext>().EntityFrameworkContext.ClearCache();
Assert.AreEqual(2, SimpleNumParts(repository, "doc1"), "after insert detail 2");
container.Resolve<Common.ExecutionContext>().EntityFrameworkContext.ClearCache();
st1.HeadID = doc2.ID;
log.Clear();
repository.Test9.Part.Update(new[] { st1 });
container.Resolve<Common.ExecutionContext>().EntityFrameworkContext.ClearCache();
Assert.AreEqual("DocumentAggregates i0 u2 d0, DocumentSimpleAggregate i0 u2 d0",
ReportRecompute(log)); // Optimized IEnumerable<Guid> filters in ChangesOnChangedItems merges IDs retrieved before and after save, to avoid two calls to the Recompute() function.
Assert.AreEqual(1, SimpleNumParts(repository, "doc1"), "after update detail");
container.Resolve<Common.ExecutionContext>().EntityFrameworkContext.ClearCache();
st1.Name += "x";
log.Clear();
repository.Test9.Part.Update(new[] { st1 });
container.Resolve<Common.ExecutionContext>().EntityFrameworkContext.ClearCache();
Assert.AreEqual("DocumentAggregates i0 u0 d0, DocumentSimpleAggregate i0 u0 d0",
ReportRecompute(log)); // Optimized IEnumerable<Guid> filters in ChangesOnChangedItems merges IDs retrieved before and after save, to avoid two calls to the Recompute() function.
Assert.AreEqual(1, SimpleNumParts(repository, "doc1"), "after update detail");
container.Resolve<Common.ExecutionContext>().EntityFrameworkContext.ClearCache();
repository.Test9.Part.Delete(new[] { st2 });
container.Resolve<Common.ExecutionContext>().EntityFrameworkContext.ClearCache();
Assert.AreEqual(0, SimpleNumParts(repository, "doc1"), "after delete detail 2");
container.Resolve<Common.ExecutionContext>().EntityFrameworkContext.ClearCache();
}
}
示例3: TestExecuteDataMigrationScripts
private List<string> TestExecuteDataMigrationScripts(string[] scriptsDescriptions, string expectedResult, bool skipScriptsWithWrongOrder = false)
{
using (var container = new RhetosTestContainer())
{
var log = new List<string>();
container.AddLogMonitor(log);
var sqlExecuter = container.Resolve<ISqlExecuter>();
sqlExecuter.ExecuteSql("DELETE FROM Rhetos.DataMigrationScript");
foreach (string scriptsDescription in scriptsDescriptions)
{
var scriptsProvider = new SimpleScriptsProvider(scriptsDescription);
var configuration = new MockConfiguration(new Dictionary<string, object>
{
{ "DataMigration.SkipScriptsWithWrongOrder", skipScriptsWithWrongOrder }
});
var dataMigration = new DataMigration(sqlExecuter, container.Resolve<ILogProvider>(), scriptsProvider, configuration);
dataMigration.ExecuteDataMigrationScripts();
}
var report = new List<string>();
sqlExecuter.ExecuteReader("SELECT Path, Active FROM Rhetos.DataMigrationScript ORDER BY OrderExecuted",
reader => report.Add(reader.GetString(0).Replace(".sql", "") + (reader.GetBoolean(1) ? "" : "-")));
Assert.AreEqual(expectedResult, string.Join(", ", report));
return log;
}
}