public void BreakLocksNoSvnFolderTest() { // Prepare List <string> remotes = new List <string>(); Mock <IFileSystem> mockFs = new Mock <IFileSystem>(MockBehavior.Strict); mockFs.Setup(m => m.DirectoryExists(lockDir)).Returns(false); // No other calls should happen since there is no remote SVN folder. Options options = new Options { BreakLocks = true }; LockBreaker uut = new LockBreaker( null, options, mockFs.Object ); // Act uut.BreakLocksIfEnabled(); // Assert mockFs.VerifyAll(); }
public void BreakLocksNoRemotesTest() { // Prepare List <string> remotes = new List <string>(); Mock <IFileSystem> mockFs = new Mock <IFileSystem>(MockBehavior.Strict); mockFs.Setup(m => m.DirectoryExists(lockDir)).Returns(true); mockFs.Setup(m => m.GetChildDirectories(lockDir)).Returns(remotes); // No other calls should happen since there is no child directories specified. Options options = new Options { BreakLocks = true }; LockBreaker uut = new LockBreaker( null, options, mockFs.Object ); // Act uut.BreakLocksIfEnabled(); // Assert mockFs.VerifyAll(); }
public void BreakLocksDisabledTest() { // Prepare List <string> remotes = new List <string>(); Mock <IFileSystem> mockFs = new Mock <IFileSystem>(MockBehavior.Strict); // No other calls should happen since this is disabled. Options options = new Options { BreakLocks = false }; LockBreaker uut = new LockBreaker( null, options, mockFs.Object ); // Act uut.BreakLocksIfEnabled(); // Assert mockFs.VerifyAll(); }
public void BreakLocksFileExistsTest() { // Prepare List <string> remotes = new List <string> { "remote1", "remote2" }; Mock <IFileSystem> mockFs = new Mock <IFileSystem>(MockBehavior.Strict); mockFs.Setup(m => m.DirectoryExists(lockDir)).Returns(true); mockFs.Setup(m => m.GetChildDirectories(lockDir)).Returns(remotes); mockFs.Setup(m => m.DeleteFileIfItExists(Path.Combine(remotes[0], "index.lock"))); mockFs.Setup(m => m.DeleteFileIfItExists(Path.Combine(remotes[1], "index.lock"))); Options options = new Options { BreakLocks = true }; LockBreaker uut = new LockBreaker( null, options, mockFs.Object ); // Act uut.BreakLocksIfEnabled(); // Assert mockFs.VerifyAll(); }
private void OnTriggerEnter(Collider other) { //If the door has a lock and it is currently locked if (lockType != ELockType.NONE && locked) { //If the object entering trigger has the key script as a component if (other.GetComponent <Key>()) { //Get a reference to the key script and compare it with the compatible keys list Key usedKey = other.GetComponent <Key>(); bool isCompatible = false; float count = compatibleKeys.Length; for (int i = 0; i < count; i++) { if (compatibleKeys[i] == usedKey) { isCompatible = true; break; } } //If the key was compatible, open door if (isCompatible) { Debug.Log("Compatible key used, unlocking door!"); Unlock(); } else { Debug.Log("Tried to use uncompatible key!"); } } } if (lockType == ELockType.BREAKABLE) { if (other.GetComponent <LockBreaker>()) { LockBreaker lockBreaker = other.GetComponent <LockBreaker>(); float velocity = lockBreaker.GetVelocity(); if (velocity >= lockBreakVelocityThreshold) { Break(); } } } }