public IEnumerable <TestCase> Collect(IEnumerable <NPath> sourceFiles) { _rootDirectory.DirectoryMustExist(); _testCaseAssemblyPath.FileMustExist(); using (var caseAssemblyDefinition = AssemblyDefinition.ReadAssembly(_testCaseAssemblyPath.ToString())) { foreach (var file in sourceFiles) { if (CreateCase(caseAssemblyDefinition, file, out TestCase? testCase) && testCase != null) { yield return(testCase); } } } }
public MockInjector(NPath assembliesDir) { var mockTypesPath = assembliesDir .DirectoryMustExist() .Combine(typeof(MockPlaceholderType).Assembly.Location.ToNPath().FileName); var assemblyBits = File.ReadAllBytes(mockTypesPath); using (var md5 = MD5.Create()) { var hash = md5.ComputeHash(assemblyBits); k_MarkAsPatchedValue = hash.ToHexString(); } using (var mockTypesAssembly = AssemblyDefinition.ReadAssembly(mockTypesPath)) { k_MarkAsPatchedKey = mockTypesAssembly.Name.FullName; k_MockPlaceholderType = mockTypesAssembly.MainModule .GetType(typeof(MockPlaceholderType).FullName); k_PatchedAssemblyBridgeTryMock = mockTypesAssembly.MainModule .GetType(typeof(PatchedAssemblyBridge).FullName) .Methods .Single(m => m.Name == nameof(PatchedAssemblyBridge.TryMock)); } }