示例#1
0
        public void FileContentReaderConstructorIsAddParametersSuccessful1()
        {
            string            payloadFilename = string.Empty; // TODO: Initialize to an appropriate value
            FileContentReader target          = new FileContentReader(payloadFilename);

            Assert.Inconclusive("TODO: Implement code to verify target");
        }
示例#2
0
        public void ReadAllAsByteIsAddParametersSuccessful()
        {
            FileContentReader target   = new FileContentReader(); // TODO: Initialize to an appropriate value
            string            fileName = @"mini_benetton.CSV";    // TODO: Initialize to an appropriate value
            string            readed   = string.Empty;
            MemoryStream      ms       = new MemoryStream();

            byte[] buff = new byte[1024];

            using (FileStream fs = new FileStream(fileName, FileMode.Open))
            {
                while (true)
                {
                    int len = fs.Read(buff, 0, buff.Length);
                    if (len > 0)
                    {
                        ms.Write(buff, 0, len);
                    }

                    if (len < buff.Length)
                    {
                        break;
                    }
                }
            }
            byte[] expected = ms.ToArray(); // TODO: Initialize to an appropriate value
            byte[] actual;
            actual = target.ReadAllAsByte(fileName);
            CollectionAssert.AreEqual(actual, expected);
        }
        public void should_read_file_content_from_localfile()
        {
            IStorePolicy policy = ServiceActivator.Get <LocalPolicy>();

            FileContentReader reader = new FileContentReader(policy);
            var content = reader.Read(file);

            Console.WriteLine(content);
        }
示例#4
0
        public void ReadAllAsStringIsAddParametersSuccessful()
        {
            FileContentReader target   = new FileContentReader();                // TODO: Initialize to an appropriate value
            string            fileName = @"mini_benetton.CSV";                   // TODO: Initialize to an appropriate value
            string            expected = new StreamReader(fileName).ReadToEnd(); // TODO: Initialize to an appropriate value
            string            actual;

            actual = target.ReadAllAsString(fileName);
            Assert.AreEqual(expected, actual);
        }
        public void should_read_file_content_from_mongo_db()
        {
            IStorePolicy policy     = ServiceActivator.Get <MongoPolicy>();
            string       remoteFile = "sample.docx";

            policy.Add(file, remoteFile);
            FileContentReader reader = new FileContentReader(policy);
            var content = reader.Read(remoteFile);

            Console.WriteLine(content);
            policy.Delete(remoteFile);
        }
示例#6
0
        public static void Main(string[] args)
        {
            var floppyData       = FloppyLoader.Load(args[0]);
            var floppyHeader     = FloppyHeaderParser.Parse(floppyData);
            var firstFatData     = FatParser.Parse(floppyHeader, floppyData, 0);
            var secondFatData    = FatParser.Parse(floppyHeader, floppyData, 1);
            var fatDirectory     = FatDirectoryTableParser.Parse(floppyHeader, floppyData);
            var firstFileContent = FileContentReader.GetContent(floppyHeader, floppyData, new List <ushort> {
                2, 3, 4, 5
            });

            DisplayFloppyHeader(floppyHeader);
            DisplayChains(firstFatData);
            DisplayFat(fatDirectory);

            Console.WriteLine(firstFileContent);
            Console.ReadLine();
        }
示例#7
0
        public static ISourceReader GetAppropriateReader(ReaderType readerType)
        {
            ISourceReader reader = null;

            switch (readerType)
            {
            case ReaderType.UserInputText:
                reader = new UserInputReader();
                break;

            case ReaderType.TextFromFile:
                reader = new FileContentReader();
                break;

            default:
                break;
            }

            return(reader);
        }
示例#8
0
        private byte[] PrepareContent(string filename)
        {
            // Prepare content parameters and their values
            // Parameters are <ProductName>, <StockCode> & <Barcode>
            // see afterParameterizing.LBL contents
            IContentParameters param = new ContentParameters();

            param.Add("<ProductName>", "My Sample Products");
            param.Add("<StockCode>", "PC-01");
            param.Add("<Barcode>", "8693332221117");

            // Read payload file
            IFileContentReader reader = new FileContentReader(filename);

            byte[] payload = reader.ReadAllAsByte();

            // Do the replacing
            IContentReplacer replacer = new ContentReplacer(param, Encoding.UTF8);

            return(replacer.Replace(payload));
        }
示例#9
0
        public void FileContentReaderConstructorIsAddParametersSuccessful2()
        {
            FileContentReader target = new FileContentReader();

            Assert.Inconclusive("TODO: Implement code to verify target");
        }