protected override void Context() { _file = @"c:\test\toto.txt"; _format = "${0}.{1}.{2}.lock"; EnvironmentHelper.ApplicationName = () => "MyApp"; sut = new LockFilePathBuilder(_format); }
public void should_return_the_id_of_the_user_with_the_lock_on_the_file() { string file = @"c:\test\toto.txt"; string lockFile = @"c:\test\$toto.TOTO.MyApp.lock"; string format = "${0}.{1}.{2}.lock"; EnvironmentHelper.ApplicationName = () => "MyApp"; sut = new LockFilePathBuilder(format); Assert.AreEqual(sut.UserIdFrom(file, lockFile), "TOTO"); }
protected override void Context() { _format = "${0}.{1}.{2}.lock"; EnvironmentHelper.ApplicationName = () => "MyApp"; sut = new LockFilePathBuilder(_format); _fileToAccess = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "toto.txt"); _lock1 = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "$toto.USER1.MyApp.lock"); _lock2 = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "$toto.USER2.MyApp.lock"); _lock3 = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "$toto.USER2.MyApp2.lock"); createFile(_lock1); createFile(_lock2); createFile(_lock3); createFile(_fileToAccess); }
public void should_return_the_path_of_the_lock_file_corresponding_to_the_given_format() { string format = "${0}.{1}.{2}.lock"; sut = new LockFilePathBuilder(format); string expectedResult = $@"c:\test\$toto.{_userId}.MyApp.lock"; expectedResult.ShouldBeEqualTo(sut.LockFilePathFor(_file)); format = "${0}_{1}_{2}.toto"; sut = new LockFilePathBuilder(format); expectedResult = $@"c:\test\$toto_{_userId}_MyApp.toto"; expectedResult.ShouldBeEqualTo(sut.LockFilePathFor(_file)); format = "${0}_{1}_{2}"; sut = new LockFilePathBuilder(format); expectedResult = $@"c:\test\$toto_{_userId}_MyApp"; expectedResult.ShouldBeEqualTo(sut.LockFilePathFor(_file)); }
protected override void Context() { sut = new LockFilePathBuilder(); _fileThatDoesNotExist = "c:\\asdasd.txt"; }