예제 #1
0
        public void AddFile_FileNotExists_AddsFile()
        {
            var path       = "test.html";
            var content    = Encoding.ASCII.GetBytes("content");
            var dictionary = new Dictionary <string, byte[]>();
            var testee     = new DictionaryZipWrapper(dictionary);

            testee.AddFile(path, content);

            var result = dictionary[path];

            Assert.AreEqual(content, result);
        }
예제 #2
0
        public void DeleteFile_FileExists_DeletesFile()
        {
            var path       = "test.html";
            var content    = Encoding.ASCII.GetBytes("content");
            var dictionary = new Dictionary <string, byte[]>
            {
                { path, content }
            };
            var testee = new DictionaryZipWrapper(dictionary);

            testee.DeleteFile(path);

            Assert.IsFalse(dictionary.Any());
        }
예제 #3
0
        public void GetFileContent_WithFileExists_ReturnsFile()
        {
            var path       = "test.html";
            var content    = Encoding.ASCII.GetBytes("content");
            var dictionary = new Dictionary <string, byte[]>
            {
                { path, content }
            };
            var testee = new DictionaryZipWrapper(dictionary);

            var result = testee.GetFileContent(path);

            Assert.AreEqual(content, result);
        }
예제 #4
0
        public void EnumerateFiles_FileExists_EnumeratesFiles()
        {
            var path       = "test.html";
            var content    = Encoding.ASCII.GetBytes("content");
            var dictionary = new Dictionary <string, byte[]>
            {
                { path, content }
            };
            var testee = new DictionaryZipWrapper(dictionary);

            var result = testee.EnumerateFiles().Single();

            Assert.AreEqual(result.Item1, path);
            Assert.AreEqual(result.Item2, content);
        }
예제 #5
0
        public void GetFileStream_WithFileExists_ReturnsStream()
        {
            var path       = "test.html";
            var content    = Encoding.ASCII.GetBytes("content");
            var dictionary = new Dictionary <string, byte[]>
            {
                { path, content }
            };
            var testee = new DictionaryZipWrapper(dictionary);

            using var reader = new BinaryReader(testee.GetFileStream(path));
            var result = reader.ReadBytes(content.Length);

            CollectionAssert.AreEqual(content, result);
        }