public void ReadLiteral()
        {
            XmlSerializer           ss   = new XmlSerializer(GetLiteralTypeMapping());
            XmlSerializerNamespaces nams = new XmlSerializerNamespaces();

            StreamReader sr   = new StreamReader(TestResourceHelper.GetFullPathOfResource("Test/XmlFiles/literal-data.xml"));
            Test         data = (Test)ss.Deserialize(sr);

            sr.Close();

            CheckObjectContent(BuildTestObject(), data);
        }
예제 #2
0
        public void ZipReadNonSeekableStream()
        {
            var tmpFile = Path.GetTempFileName();

            File.Copy(TestResourceHelper.GetFullPathOfResource("Test/resources/test.nupkg"), tmpFile, overwrite: true);
            var stream = new MyFakeStream(tmpFile, FileMode.Open);

            using (var archive = new ZipArchive(stream, ZipArchiveMode.Read))
            {
            }
            File.Delete(tmpFile);
        }
예제 #3
0
        public void GetString_ResourceSet_Disposed()
        {
            ResourceManager rm = ResourceManager.
                                 CreateFileBasedResourceManager("MyResources", TestResourceHelper.GetFullPathOfResource("Test/resources"), null);
            ResourceSet rs = rm.GetResourceSet(new CultureInfo("de"),
                                               true, true);

            rs.Dispose();

            Assert.IsNull(rm.GetString("deHelloWorld"));
            rm.ReleaseAllResources();
        }
예제 #4
0
        public void BgrndImageChangedTest()
        {
            Control c = new Control();

            // Test BackgroundImageChanged Event
            c.BackgroundImageChanged += new EventHandler(Event_Handler1);
            string abc = TestResourceHelper.GetFullPathOfResource("Test/resources/M.gif");

            eventhandled      = false;
            c.BackgroundImage = Image.FromFile(abc);
            Assert.AreEqual(true, eventhandled, "#A2");
        }
예제 #5
0
        public void TestMissingImport1()
        {
            string documentString = @"
                                <Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
					<Import Project='"                     + TestResourceHelper.GetFullPathOfResource("Test/resources/NonExistantProject.csproj") + @"'/>
                                </Project>";

            engine = new Engine(Consts.BinPath);

            project = engine.CreateNewProject();
            project.LoadXml(documentString, ProjectLoadSettings.None);
        }
예제 #6
0
        public void Bitmap24bitPixels()
        {
            string sInFile = TestResourceHelper.GetFullPathOfResource("Test/System.Drawing/bitmaps/almogaver24bits.bmp");

            using (Bitmap bmp = new Bitmap(sInFile)) {
#if false
                for (int x = 0; x < bmp.Width; x += 32)
                {
                    for (int y = 0; y < bmp.Height; y += 32)
                    {
                        Console.WriteLine("\t\t\t\tAssert.AreEqual ({0}, bmp.GetPixel ({1}, {2}).ToArgb (), \"{1},{2}\");", bmp.GetPixel(x, y).ToArgb(), x, y);
                    }
                }
#else
                // sampling values from a well known bitmap
                Assert.AreEqual(-1645353, bmp.GetPixel(0, 32).ToArgb(), "0,32");
                Assert.AreEqual(-461332, bmp.GetPixel(0, 64).ToArgb(), "0,64");
                Assert.AreEqual(-330005, bmp.GetPixel(0, 96).ToArgb(), "0,96");
                Assert.AreEqual(-2237489, bmp.GetPixel(0, 128).ToArgb(), "0,128");
                Assert.AreEqual(-1251105, bmp.GetPixel(0, 160).ToArgb(), "0,160");
                Assert.AreEqual(-3024947, bmp.GetPixel(32, 0).ToArgb(), "32,0");
                Assert.AreEqual(-2699070, bmp.GetPixel(32, 32).ToArgb(), "32,32");
                Assert.AreEqual(-2366734, bmp.GetPixel(32, 64).ToArgb(), "32,64");
                Assert.AreEqual(-4538413, bmp.GetPixel(32, 96).ToArgb(), "32,96");
                Assert.AreEqual(-6116681, bmp.GetPixel(32, 128).ToArgb(), "32,128");
                Assert.AreEqual(-7369076, bmp.GetPixel(32, 160).ToArgb(), "32,160");
                Assert.AreEqual(-13024729, bmp.GetPixel(64, 0).ToArgb(), "64,0");
                Assert.AreEqual(-7174020, bmp.GetPixel(64, 32).ToArgb(), "64,32");
                Assert.AreEqual(-51, bmp.GetPixel(64, 64).ToArgb(), "64,64");
                Assert.AreEqual(-16053503, bmp.GetPixel(64, 96).ToArgb(), "64,96");
                Assert.AreEqual(-8224431, bmp.GetPixel(64, 128).ToArgb(), "64,128");
                Assert.AreEqual(-16579326, bmp.GetPixel(64, 160).ToArgb(), "64,160");
                Assert.AreEqual(-2502457, bmp.GetPixel(96, 0).ToArgb(), "96,0");
                Assert.AreEqual(-9078395, bmp.GetPixel(96, 32).ToArgb(), "96,32");
                Assert.AreEqual(-12696508, bmp.GetPixel(96, 64).ToArgb(), "96,64");
                Assert.AreEqual(-70772, bmp.GetPixel(96, 96).ToArgb(), "96,96");
                Assert.AreEqual(-4346279, bmp.GetPixel(96, 128).ToArgb(), "96,128");
                Assert.AreEqual(-11583193, bmp.GetPixel(96, 160).ToArgb(), "96,160");
                Assert.AreEqual(-724763, bmp.GetPixel(128, 0).ToArgb(), "128,0");
                Assert.AreEqual(-7238268, bmp.GetPixel(128, 32).ToArgb(), "128,32");
                Assert.AreEqual(-2169612, bmp.GetPixel(128, 64).ToArgb(), "128,64");
                Assert.AreEqual(-3683883, bmp.GetPixel(128, 96).ToArgb(), "128,96");
                Assert.AreEqual(-12892867, bmp.GetPixel(128, 128).ToArgb(), "128,128");
                Assert.AreEqual(-3750464, bmp.GetPixel(128, 160).ToArgb(), "128,160");
                Assert.AreEqual(-3222844, bmp.GetPixel(160, 0).ToArgb(), "160,0");
                Assert.AreEqual(-65806, bmp.GetPixel(160, 32).ToArgb(), "160,32");
                Assert.AreEqual(-2961726, bmp.GetPixel(160, 64).ToArgb(), "160,64");
                Assert.AreEqual(-2435382, bmp.GetPixel(160, 96).ToArgb(), "160,96");
                Assert.AreEqual(-2501944, bmp.GetPixel(160, 128).ToArgb(), "160,128");
                Assert.AreEqual(-9211799, bmp.GetPixel(160, 160).ToArgb(), "160,160");
#endif
            }
        }
예제 #7
0
        public void ValidateRelaxngGrammar()
        {
            // validate relaxng.rng with relaxng.rng
            RVR r = new RVR(
                new XmlTextReader(TestResourceHelper.GetFullPathOfResource("Test/XmlFiles/relaxng.rng")),
                new XmlTextReader(TestResourceHelper.GetFullPathOfResource("Test/XmlFiles/relaxng.rng")));

            while (!r.EOF)
            {
                r.Read();
            }
        }
예제 #8
0
        public void CustomResolverUsedForXmlStream()
        {
            XmlReaderSettings settings = new XmlReaderSettings();

            settings.XmlResolver = new ThrowExceptionResolver();
            using (XmlReader xr = XmlReader.Create(TestResourceHelper.GetFullPathOfResource("Test/XmlFiles/simple.xml"), settings)) {
                while (!xr.EOF)
                {
                    xr.Read();
                }
            }
        }
예제 #9
0
        public void NullResolver()
        {
            XmlReaderSettings settings = new XmlReaderSettings();

            settings.XmlResolver = null;
            using (XmlReader xr = XmlReader.Create(TestResourceHelper.GetFullPathOfResource("Test/XmlFiles/simple.xml"), settings)) {
                while (!xr.EOF)
                {
                    xr.Read();
                }
            }
        }
예제 #10
0
        public void CreateValidatorFromNonIXmlNamespaceResolver()
        {
            XmlReaderSettings settings = new XmlReaderSettings();

            settings.Schemas.Add(null, TestResourceHelper.GetFullPathOfResource("Test/XmlFiles/xsd/xml.xsd"));
            settings.ValidationType = ValidationType.Schema;
            XmlReader xr = XmlReader.Create(new StringReader("<root/>"));
            XmlReader dr = new Commons.Xml.XmlDefaultReader(xr);
            // XmlDefaultReader does not implement IXmlNamespaceResolver
            // but don't reject because of that fact.
            XmlReader r = XmlReader.Create(dr, settings);
        }
예제 #11
0
파일: ClaimTest.cs 프로젝트: zzwwqqq/mono
        public void CreateClaims()
        {
            Claim c;

            // premises
            Assert.AreEqual("http://schemas.xmlsoap.org/ws/2005/05/identity/right/identity", Rights.Identity, "#1");
            Assert.AreEqual("http://schemas.xmlsoap.org/ws/2005/05/identity/right/possessproperty", Rights.PossessProperty, "#2");

            c = Claim.CreateDnsClaim("123.45.6.7");
            AssertClaim("Dns", c, ClaimTypes.Dns, "123.45.6.7", Rights.PossessProperty);

            Uri uri = new Uri("http://www.example.com");

            c = Claim.CreateUriClaim(uri);
            AssertClaim("Uri", c, ClaimTypes.Uri, uri, Rights.PossessProperty);

            MailAddress mail = new MailAddress("*****@*****.**");

            c = Claim.CreateMailAddressClaim(mail);
            AssertClaim("Mail", c, ClaimTypes.Email, mail, Rights.PossessProperty);

            c = Claim.CreateNameClaim("Rupert");
            AssertClaim("Name", c, ClaimTypes.Name, "Rupert", Rights.PossessProperty);

            c = Claim.CreateSpnClaim("foo");
            AssertClaim("Spn", c, ClaimTypes.Spn, "foo", Rights.PossessProperty);

            c = Claim.CreateUpnClaim("foo");
            AssertClaim("Upn", c, ClaimTypes.Upn, "foo", Rights.PossessProperty);

            //SecurityIdentifier sid = new SecurityIdentifier (blah);
            //c = Claim.CreateWindowsSidClaim (sid);
            //AssertClaim ("Sid", c, ClaimTypes.Sid, blah, Rights.PossessProperty);

            byte [] hash = new byte [] { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
            c = Claim.CreateHashClaim(hash);
            AssertClaim("Hash", c, ClaimTypes.Hash, hash, Rights.PossessProperty);

            RSA rsa = RSA.Create();

            c = Claim.CreateRsaClaim(rsa);
            AssertClaim("Rsa", c, ClaimTypes.Rsa, rsa, Rights.PossessProperty);

            X509Certificate2 cert = new X509Certificate2(TestResourceHelper.GetFullPathOfResource("Test/Resources/test.pfx"), "mono");

            byte [] chash = cert.GetCertHash();
            c = Claim.CreateThumbprintClaim(chash);
            AssertClaim("Thumbprint", c, ClaimTypes.Thumbprint, chash, Rights.PossessProperty);

            c = Claim.CreateX500DistinguishedNameClaim(cert.SubjectName);
            AssertClaim("X500Name", c, ClaimTypes.X500DistinguishedName, cert.SubjectName, Rights.PossessProperty);
        }
예제 #12
0
        public void IgnoreCase()
        {
            ResourceManager rm = ResourceManager.
                                 CreateFileBasedResourceManager("MyResources", TestResourceHelper.GetFullPathOfResource("Test/resources"), null);

            Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture;
            Assert.IsFalse(rm.IgnoreCase, "#A1");
            Assert.IsNull(rm.GetString("helloWORLD"), "#A2");
            rm.IgnoreCase = true;
            Assert.IsTrue(rm.IgnoreCase, "#B1");
            Assert.AreEqual("Hello World", rm.GetString("HelloWorld"), "#B2");
            rm.ReleaseAllResources();
        }
예제 #13
0
        public void CreateFileBasedResourceManager_UsingResourceSet_Null()
        {
            ResourceManager rm = ResourceManager.CreateFileBasedResourceManager(
                "MyResources", TestResourceHelper.GetFullPathOfResource("Test/resources"), (Type)null);

            Assert.IsNotNull(rm.BaseName, "#1");
            Assert.AreEqual("MyResources", rm.BaseName, "#2");
            Assert.IsFalse(rm.IgnoreCase, "#3");
            Assert.IsNotNull(rm.ResourceSetType, "#4");
            Assert.IsTrue(typeof(ResourceSet).IsAssignableFrom(rm.ResourceSetType), "#5");
            Assert.IsFalse(typeof(ResourceSet) == rm.ResourceSetType, "#6");
            Assert.AreEqual("RuntimeResourceSet", rm.ResourceSetType.Name, "#7");
        }
예제 #14
0
        // bug #77687
        public void CompileFillsSchemaPropertyInExternal()
        {
            string        schemaFileName = TestResourceHelper.GetFullPathOfResource("Test/XmlFiles/xsd/77687.xsd");
            XmlTextReader tr             = new XmlTextReader(schemaFileName);

            XmlSchema        schema = XmlSchema.Read(tr, null);
            XmlSchemaInclude inc    = (XmlSchemaInclude)schema.Includes [0];

            Assert.IsNull(inc.Schema);
            schema.Compile(null);
            tr.Close();
            Assert.IsNotNull(inc.Schema);
        }
예제 #15
0
        public void EnumerationFacetOnAttribute()
        {
            string              xml    = "<test mode='NOT AN ENUMERATION VALUE' />";
            XmlSchema           schema = XmlSchema.Read(new XmlTextReader(TestResourceHelper.GetFullPathOfResource("Test/XmlFiles/xsd/79650.xsd")), null);
            XmlValidatingReader xvr    = new XmlValidatingReader(xml, XmlNodeType.Document, null);

            xvr.ValidationType = ValidationType.Schema;
            xvr.Schemas.Add(schema);
            while (!xvr.EOF)
            {
                xvr.Read();
            }
        }
예제 #16
0
파일: TestIcon.cs 프로젝트: nsivov/mono
        public void SetUp()
        {
            String path = TestResourceHelper.GetFullPathOfResource("Test/System.Drawing/bitmaps/smiley.ico");

            icon = new Icon(path);
            fs1  = new FileStream(path, FileMode.Open);

            icon16 = new Icon(TestResourceHelper.GetFullPathOfResource("Test/System.Drawing/bitmaps/16x16x16.ico"));
            icon32 = new Icon(TestResourceHelper.GetFullPathOfResource("Test/System.Drawing/bitmaps/32x32x16.ico"));
            icon48 = new Icon(TestResourceHelper.GetFullPathOfResource("Test/System.Drawing/bitmaps/48x48x1.ico"));
            icon64 = new Icon(TestResourceHelper.GetFullPathOfResource("Test/System.Drawing/bitmaps/64x64x256.ico"));
            icon96 = new Icon(TestResourceHelper.GetFullPathOfResource("Test/System.Drawing/bitmaps/96x96x256.ico"));
        }
예제 #17
0
        public void TestSampleFileComplexTables3()
        {
            DataSet ds = new DataSet();

            ds.ReadXmlSchema(TestResourceHelper.GetFullPathOfResource("Test/System.Data/schemas/test013.xsd"));
            AssertDataSet("013", ds, "root", 1, 0);

            DataTable dt = ds.Tables [0];

            AssertDataTable("root", dt, "e", 2, 0, 0, 0, 0, 0);
            AssertDataColumn("attr", dt.Columns [0], "a", true, false, 0, 1, "a", MappingType.Attribute, typeof(string), DBNull.Value, String.Empty, -1, String.Empty, 0, String.Empty, false, false);
            AssertDataColumn("simple", dt.Columns [1], "e_text", false, false, 0, 1, "e_text", MappingType.SimpleContent, typeof(decimal), DBNull.Value, String.Empty, -1, String.Empty, 1, String.Empty, false, false);
        }
예제 #18
0
        public void ReadConstraints()
        {
            DataSet ds = new DataSet();

            ds.Tables.Add(new DataTable());
            ds.Tables.Add(new DataTable());
            ds.Tables[0].ReadXmlSchema(TestResourceHelper.GetFullPathOfResource("Test/System.Data/schemas/test015.xsd"));
            ds.Tables[1].ReadXmlSchema(TestResourceHelper.GetFullPathOfResource("Test/System.Data/schemas/test015.xsd"));
            Assert.AreEqual(0, ds.Relations.Count, "#1");
            Assert.AreEqual(1, ds.Tables [0].Constraints.Count, "#2");
            Assert.AreEqual(0, ds.Tables [1].Constraints.Count, "#3");
            Assert.AreEqual("Constraint1", ds.Tables [0].Constraints [0].ConstraintName, "#4");
        }
예제 #19
0
 public void EndOfBufferIsCR()
 {
     using (StreamReader reader = new StreamReader(TestResourceHelper.GetFullPathOfResource("Test/resources/Fergie.GED"))) {
         string line;
         int    count = 0;
         while ((line = reader.ReadLine()) != null)
         {
             Assert.IsFalse(line.Length > 1000, "#1 " + count);
             count++;
         }
         Assert.AreEqual(16107, count, "#2");
     }
 }
예제 #20
0
        public void TestLoadAndSave3()
        {
            var referenceProject = TestResourceHelper.GetFullPathOfResource("Test/resources/FunctionalTestReferenceProject3.csproj");
            var project          = ProjectRootElement.Open(referenceProject);
            var projectFileName  = String.Format("Test{0}FunctionalTestProject3.csproj",
                                                 Path.DirectorySeparatorChar);

            project.Save(projectFileName);

            Assert.AreEqual(new Guid("{793B20A9-E263-4B54-BB31-305B602087CE}"), GetProjectId(project),
                            "#05");
            FileAssert.AreEqual(referenceProject, projectFileName, "#06");
        }
예제 #21
0
        public void Extensions()
        {
            FileStream    fs  = new FileStream(TestResourceHelper.GetFullPathOfResource("Test/System.Web.Services.Description/test.wsdl"), FileMode.Open, FileAccess.Read);
            XmlTextReader xtr = new XmlTextReader(fs);

            ServiceDescription sd = ServiceDescription.Read(xtr);

            fs.Close();

            Assert.IsNotNull(sd.Extensions);
            Assert.AreEqual(1, sd.Extensions.Count);

            CheckExtensions(sd, "sdElem", "sdVal");
            CheckExtensions(sd.Messages [0], "msgElem", "msgVal");
            CheckExtensions(sd.Messages [0].Parts [0], "partElem", "partVal");

            CheckExtensions(sd.PortTypes [0], "ptElem", "ptVal");
            CheckExtensions(sd.PortTypes [0].Operations [0], "opElem", "opVal");

            //Binding [0]
            Assert.IsNotNull(sd.Bindings [0].Extensions);
            Assert.AreEqual(2, sd.Bindings [0].Extensions.Count);
            CheckXmlElement(sd.Bindings [0].Extensions [0], "binElem");
            Assert.AreEqual(typeof(SoapBinding), sd.Bindings [0].Extensions [1].GetType());

            //Binding [0].Operations [0]
            Assert.IsNotNull(sd.Bindings [0].Operations [0].Extensions);
            Assert.AreEqual(1, sd.Bindings [0].Operations [0].Extensions.Count);
            Assert.AreEqual(typeof(SoapOperationBinding), sd.Bindings [0].Operations [0].Extensions [0].GetType());

            //Service
            CheckExtensions(sd.Services [0], "svcElem", "svcVal");

            //Service.Port
            Assert.IsNotNull(sd.Services [0].Ports [0].Extensions);
            Assert.AreEqual(2, sd.Services [0].Ports [0].Extensions.Count);
            Assert.AreEqual(typeof(SoapAddressBinding), sd.Services [0].Ports [0].Extensions [0].GetType());
            CheckXmlElement(sd.Services [0].Ports [0].Extensions [1], "portElem");

            string out_file = Path.GetTempFileName();

            try {
                using (FileStream out_fs = new FileStream(out_file, FileMode.Create))
                    sd.Write(out_fs);
            } finally {
                if (!String.IsNullOrEmpty(out_file))
                {
                    File.Delete(out_file);
                }
            }
        }
예제 #22
0
파일: TestIcon.cs 프로젝트: nsivov/mono
 public void Icon256ToBitmap_Request0()
 {
     // 415581.ico has 2 images, the 256 and 48
     using (FileStream fs = File.OpenRead(TestResourceHelper.GetFullPathOfResource("Test/System.Drawing/bitmaps/415581.ico"))) {
         Icon icon = new Icon(fs, 0, 0);
         using (Bitmap b = icon.ToBitmap()) {
             Assert.AreEqual(0, b.Palette.Entries.Length, "#B1");
             Assert.AreEqual(48, b.Height, "#B2");
             Assert.AreEqual(48, b.Width, "#B3");
             Assert.IsTrue(b.RawFormat.Equals(ImageFormat.MemoryBmp), "#B4");
             Assert.AreEqual(2, b.Flags, "#B5");
         }
     }
 }
예제 #23
0
파일: TestIcon.cs 프로젝트: nsivov/mono
        public void Constructor_Icon_DoesntReturn256Passing1()
        {
            string filepath = TestResourceHelper.GetFullPathOfResource("Test/System.Drawing/bitmaps/323511.ico");

            Icon orig = new Icon(filepath);

            Assert.AreEqual(32, orig.Height);
            Assert.AreEqual(32, orig.Width);

            Icon ret = new Icon(orig, 1, 1);

            Assert.AreNotEqual(0, ret.Height);
            Assert.AreNotEqual(0, ret.Width);
        }
예제 #24
0
파일: TestIcon.cs 프로젝트: nsivov/mono
        public void Constructor_Icon_GetNormalSizeFromIconWith256()
        {
            string filepath = TestResourceHelper.GetFullPathOfResource("Test/System.Drawing/bitmaps/323511.ico");

            Icon orig = new Icon(filepath);

            Assert.AreEqual(32, orig.Height);
            Assert.AreEqual(32, orig.Width);

            Icon ret = new Icon(orig, 48, 48);

            Assert.AreEqual(48, ret.Height);
            Assert.AreEqual(48, ret.Width);
        }
예제 #25
0
        public void CreateProviderX509()
        {
            SecurityTokenRequirement r =
                new RecipientServiceModelSecurityTokenRequirement();

            r.TokenType = SecurityTokenTypes.X509Certificate;
            def_c.ServiceCredentials.ServiceCertificate.Certificate =
                new X509Certificate2(TestResourceHelper.GetFullPathOfResource("Test/Resources/test.pfx"), "mono");
            X509SecurityTokenProvider p =
                def_c.CreateSecurityTokenProvider(r)
                as X509SecurityTokenProvider;

            Assert.IsNotNull(p, "#1");
        }
예제 #26
0
        public void TestTaskName()
        {
            string documentString = @"
				<Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
					<UsingTask
						AssemblyFile='"                         + TestResourceHelper.GetFullPathOfResource("Test/resources/TestTasks.dll") + @"'
					/>
				</Project>
			"            ;

            engine  = new Engine(Consts.BinPath);
            project = engine.CreateNewProject();
            project.LoadXml(documentString);
        }
예제 #27
0
        static SniHandlerTest()
        {
            X509Certificate2 tlsCertificate  = TestResourceHelper.GetTestCertificate();
            X509Certificate2 tlsCertificate2 = TestResourceHelper.GetTestCertificate2();

//#if NETCOREAPP_3_0_GREATER
//            SslProtocols serverProtocol = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? SslProtocols.Tls13 : SslProtocols.Tls12;
//#else
            SslProtocols serverProtocol = SslProtocols.Tls12;

//#endif
            SettingMap[tlsCertificate.GetNameInfo(X509NameType.DnsName, false)]  = new ServerTlsSettings(tlsCertificate, false, false, serverProtocol);
            SettingMap[tlsCertificate2.GetNameInfo(X509NameType.DnsName, false)] = new ServerTlsSettings(tlsCertificate2, false, false, serverProtocol);
        }
예제 #28
0
        public void Bug463267()
        {
            var         datatypeLibrary = SetupMyDataProvider();
            XmlDocument xml             = new XmlDocument();

            xml.LoadXml("<root> <v2>1</v2> <v1>mytype</v1> </root>");
            XmlDocument schemaXml = ReadDoc(TestResourceHelper.GetFullPathOfResource("Test/XmlFiles/463267.rng"));
            XmlReader   reader    = new RelaxngValidatingReader(new XmlNodeReader(xml), new XmlNodeReader(schemaXml), datatypeLibrary);

            while (reader.Read())
            {
                ;
            }
        }
예제 #29
0
        static async Task <Tuple <EmbeddedChannel, SslStream> > SetupStreamAndChannelAsync(bool isClient, IEventExecutor executor, IWriteStrategy writeStrategy, SslProtocols protocol, List <Task> writeTasks)
        {
            X509Certificate2 tlsCertificate = TestResourceHelper.GetTestCertificate();
            string           targetHost     = tlsCertificate.GetNameInfo(X509NameType.DnsName, false);
            TlsHandler       tlsHandler     = isClient ?
                                              new TlsHandler(stream => new SslStream(stream, true, (sender, certificate, chain, errors) => true), new ClientTlsSettings(targetHost)) :
                                              TlsHandler.Server(tlsCertificate);
            //var ch = new EmbeddedChannel(new LoggingHandler("BEFORE"), tlsHandler, new LoggingHandler("AFTER"));
            var ch = new EmbeddedChannel(tlsHandler);

            IByteBuffer readResultBuffer = Unpooled.Buffer(4 * 1024);
            Func <ArraySegment <byte>, Task <int> > readDataFunc = async output =>
            {
                if (writeTasks.Count > 0)
                {
                    await Task.WhenAll(writeTasks).WithTimeout(TestTimeout);

                    writeTasks.Clear();
                }

                if (readResultBuffer.ReadableBytes < output.Count)
                {
                    await ReadOutboundAsync(async() => ch.ReadOutbound <IByteBuffer>(), output.Count - readResultBuffer.ReadableBytes, readResultBuffer, TestTimeout);
                }
                Assert.NotEqual(0, readResultBuffer.ReadableBytes);
                int read = Math.Min(output.Count, readResultBuffer.ReadableBytes);
                readResultBuffer.ReadBytes(output.Array, output.Offset, read);
                return(read);
            };
            var mediationStream = new MediationStream(readDataFunc, input =>
            {
                Task task = executor.SubmitAsync(() => writeStrategy.WriteToChannelAsync(ch, input)).Unwrap();
                writeTasks.Add(task);
                return(task);
            });

            var driverStream = new SslStream(mediationStream, true, (_1, _2, _3, _4) => true);

            if (isClient)
            {
                await Task.Run(() => driverStream.AuthenticateAsServerAsync(tlsCertificate)).WithTimeout(TimeSpan.FromSeconds(5));
            }
            else
            {
                await Task.Run(() => driverStream.AuthenticateAsClientAsync(targetHost, null, protocol, false)).WithTimeout(TimeSpan.FromSeconds(5));
            }
            writeTasks.Clear();

            return(Tuple.Create(ch, driverStream));
        }
예제 #30
0
        public void ZipEnumerateArchiveDefaultLastWriteTime()
        {
            var tmpFile = Path.GetTempFileName();

            File.Copy(TestResourceHelper.GetFullPathOfResource("Test/resources/test.nupkg"), tmpFile, overwrite: true);
            using (var archive = new ZipArchive(File.Open(tmpFile, FileMode.Open, FileAccess.ReadWrite),
                                                ZipArchiveMode.Read))
            {
                var entry = archive.GetEntry("_rels/.rels");
                Assert.AreEqual(new DateTime(624511296000000000).Ticks, entry.LastWriteTime.Ticks);
                Assert.IsNotNull(entry);
            }
            File.Delete(tmpFile);
        }