public void ResolveAssembly_ReferencedGhostChanges_RefreshOnce( Type ghostAssemblyType, Type referencedAssemblyType) { var ghostAssembly = ghostAssemblyType.Assembly; var assemblyName = ghostAssembly.GetName().Name; var assemblyFile = ghostAssembly.Location; var referencedAssembly = referencedAssemblyType.Assembly; var referencedAssemblyName = referencedAssembly.GetName().Name; var referencedLocation = referencedAssembly.Location; var expectMessage = GhostAssemblyException.CreateChangeAssemblyVersionMessage(referencedAssemblyName); var ghostAssemblyPaths = assemblyFile + ";" + referencedLocation; using (var ghostAssemblyLoader = new GhostAssemblyLoader(ghostAssemblyPaths, assemblyName)) { staticMock.For(() => File.GetLastWriteTime(assemblyFile)).Returns(File.GetLastWriteTime(assemblyFile)); staticMock.For(() => File.GetLastWriteTime(referencedLocation)).Returns(File.GetLastWriteTime(referencedLocation)); var asm1 = ghostAssemblyLoader.ResolveAssembly(); ghostAssemblyLoader.ResolveAssembly(referencedAssemblyName); staticMock.For(() => File.GetLastWriteTime(referencedLocation)).Returns(DateTime.Now); var asm2 = ghostAssemblyLoader.ResolveAssembly(); var asm3 = ghostAssemblyLoader.ResolveAssembly(); Assert.That(asm1, Is.Not.EqualTo(asm2)); Assert.That(asm2, Is.EqualTo(asm3)); } }
public void ResolveAssembly_GhostOrReferencedGhostChanges_ExpectVersionChange( Type ghostAssemblyType, Type referencedAssemblyType, bool updateGhost, bool updateReferenced, bool expectVersionChange) { var ghostAssembly = ghostAssemblyType.Assembly; var assemblyName = ghostAssembly.GetName().Name; var assemblyFile = ghostAssembly.Location; var referencedAssembly = referencedAssemblyType.Assembly; var referencedAssemblyName = referencedAssembly.GetName().Name; var referencedLocation = referencedAssembly.Location; var expectMessage = GhostAssemblyException.CreateChangeAssemblyVersionMessage(referencedAssemblyName); var ghostAssemblyPaths = assemblyFile + ";" + referencedLocation; using (var ghostAssemblyLoader = new GhostAssemblyLoader(ghostAssemblyPaths, assemblyName)) { staticMock.For(() => File.GetLastWriteTime(assemblyFile)).Returns(File.GetLastWriteTime(assemblyFile)); staticMock.For(() => File.GetLastWriteTime(referencedLocation)).Returns(File.GetLastWriteTime(referencedLocation)); var asm1 = ghostAssemblyLoader.ResolveAssembly(); var ref1 = findReferencedAssembly(asm1, referencedAssemblyName); ghostAssemblyLoader.ResolveAssembly(referencedAssemblyName); if (updateGhost) { staticMock.For(() => File.GetLastWriteTime(assemblyFile)).Returns(DateTime.Now); } if (updateReferenced) { staticMock.For(() => File.GetLastWriteTime(referencedLocation)).Returns(DateTime.Now); } var asm2 = ghostAssemblyLoader.ResolveAssembly(); var ref2 = findReferencedAssembly(asm2, referencedAssemblyName); if (expectVersionChange) { Assert.That(ref2.Version, Is.Not.EqualTo(ref1.Version)); } else { Assert.That(ref2.Version, Is.EqualTo(ref1.Version)); } } }