public void ValidateWriteToStream()
        {
            string fileName    = Path.GetTempFileName();
            string textToWrite = string.Empty;
            Random random      = new Random(1);

            for (int i = 0; i < 5; i++)
            {
                textToWrite += random.Next().ToString((IFormatProvider)null) + "\n";
            }
            using (File.Create(fileName)) { }
            //File.WriteAllText(fileName, textToWrite);
            FileInfo            fileinfo = new FileInfo(fileName);
            INamedStreamCreator creator  = INamedStreamCreatorExtensions.ToNamedStreamCreator(fileinfo, "Stream");
            string fileName1             = Path.GetTempFileName();

            using (FileStream stream = new FileStream(fileName1, FileMode.Create))
            {
                INamedStreamCreatorExtensions.WriteToStream(creator, stream);
            }
            string line = INamedStreamCreatorExtensions.ReadToEnd(creator);

            Assert.IsNotNull(line);
            Assert.AreEqual(textToWrite, line);
        }
        public void ValidateToNamedStreamCreatorFromFileName()
        {
            string streamname           = "StreamName";
            INamedStreamCreator creator =
                INamedStreamCreatorExtensions.ToNamedStreamCreatorFromFileName("tmp.txt", streamname);

            Assert.AreEqual(streamname, creator.Name);
            Assert.IsNotNull(creator.Creator);
        }
        public void ValidateToNamedStreamCreatorFromString()
        {
            string strstream            = "this is a test string";
            string streamname           = "StreamName";
            INamedStreamCreator creator =
                INamedStreamCreatorExtensions.ToNamedStreamCreatorFromString(strstream, streamname);

            Assert.AreEqual(streamname, creator.Name);
            Assert.IsNotNull(creator.Creator);
        }
        public void ValidateToNamedStreamCreator()
        {
            string              fileName   = "tmp.txt";
            string              streamname = "StreamName";
            FileInfo            fileinfo   = new FileInfo(fileName);
            INamedStreamCreator creator    =
                INamedStreamCreatorExtensions.ToNamedStreamCreator(fileinfo, streamname);

            Assert.AreEqual(streamname, creator.Name);
            Assert.IsNotNull(creator.Creator);
        }
        public void ValidateToNamedStreamCreatorWithManifestResourceName()
        {
            string              fileName     = "tmp.txt";
            string              streamname   = "StreamName";
            string              resourcename = "FileStream";
            FileInfo            fileinfo     = new FileInfo(fileName);
            INamedStreamCreator creator      =
                INamedStreamCreatorExtensions.ToNamedStreamCreator(SpecialFunctions.GetEntryOrCallingAssembly(), resourcename, streamname);

            Assert.AreEqual(streamname, creator.Name);
            Assert.IsNotNull(creator.Creator);
        }
        public void ValidateReadUncommentedLine()
        {
            string fileName    = Path.GetTempFileName();
            string textToWrite = string.Empty;
            Random random      = new Random(1);

            for (int i = 0; i < 5; i++)
            {
                textToWrite += random.Next().ToString((IFormatProvider)null) + "\n";
            }
            using (File.Create(fileName)) { }
            File.WriteAllText(fileName, textToWrite);
            FileInfo            fileinfo = new FileInfo(fileName);
            INamedStreamCreator creator  = INamedStreamCreatorExtensions.ToNamedStreamCreator(fileinfo, "Stream");
            string line = INamedStreamCreatorExtensions.ReadUncommentedLine(creator);

            Assert.IsNotNull(line);
            double num;

            Assert.IsTrue(double.TryParse(line, out num));
        }