示例#1
0
        public void GetFirstFreeIdIfNoFileIsPresent()
        {
            idProvider = new FileIdProvider();

            var @out = idProvider.GetId(path, ".png");

            Assert.Equal("0", @out);
        }
示例#2
0
        public void ThrowExeptionIfGivenDirectoryDoesntExists()
        {
            var nPath = "notExistingDir/";

            if (Directory.Exists(nPath))
            {
                Directory.Delete(nPath);
            }

            idProvider = new FileIdProvider();

            Assert.Throws <DirectoryNotFoundException>(() => idProvider.GetId(nPath, ".png"));
        }
示例#3
0
        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");
            }
        }
示例#4
0
        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");
                }
            }
        }