public void GetFirstFreeIdIfNoFileIsPresent() { idProvider = new FileIdProvider(); var @out = idProvider.GetId(path, ".png"); Assert.Equal("0", @out); }
public void ThrowExeptionIfGivenDirectoryDoesntExists() { var nPath = "notExistingDir/"; if (Directory.Exists(nPath)) { Directory.Delete(nPath); } idProvider = new FileIdProvider(); Assert.Throws <DirectoryNotFoundException>(() => idProvider.GetId(nPath, ".png")); }
public void ReturnCharacterIfAllNubersAreTaken() { idProvider = new FileIdProvider(); for (int i = 0; i < 10; i++) { File.Create(path + i + ".png").Close(); } var @out = idProvider.GetId(path, ".png"); Assert.Equal("A", @out); for (int i = 0; i < 10; i++) { File.Delete(path + i + ".png"); } }
public void AddNextCharacterIfAllPossibleIdCombitaionTaken() { idProvider = new FileIdProvider(); for (int i = 48; i < 91; i++) { if (Char.IsLetterOrDigit((char)i)) { File.Create(path + (char)i + ".png").Close(); } } var @out = idProvider.GetId(path, ".png"); Assert.Equal("00", @out); for (int i = 48; i < 91; i++) { if (Char.IsLetterOrDigit((char)i)) { File.Delete(path + (char)i + ".png"); } } }