public void FindManifestResourceStream()
 {
     System.Reflection.Assembly assembly = typeof(AssemblyExtensionTest).Assembly;
     Assert.IsNull(assembly.FindManifestResourceStream("?"));
     Assert.NotNull(assembly.FindManifestResourceStream("Object.Coverage.json"));
     Assert.NotNull(assembly.FindManifestResourceStream("Node.Net.Test.Resources.Object.Coverage.json"));
 }
        public void DeepUpdateParents()
        {
            System.Reflection.Assembly assembly = typeof(IDictionaryExtensionTest).Assembly;
            IDictionary data = new Reader().Read <IDictionary>(assembly.FindManifestResourceStream("Object.Coverage.json"));

            Assert.NotNull(data, nameof(data));
            data.DeepUpdateParents();
            IDictionaryExtension.DeepUpdateParents(null);
            data.ComputeHashCode();
        }
        public void Find()
        {
            System.Reflection.Assembly assembly = typeof(IDictionaryExtensionTest).Assembly;
            IDictionary data = new Reader().Read <IDictionary>(assembly.FindManifestResourceStream("Object.Coverage.json"));

            Assert.NotNull(data, nameof(data));
            //data.DeepUpdateParents();
            IDictionary a = data.Find <IDictionary>("objectA");

            Assert.NotNull(a, nameof(a));
        }
        public void Collect()
        {
            System.Reflection.Assembly assembly = typeof(IDictionaryExtensionTest).Assembly;
            IDictionary data = new Reader().Read <IDictionary>(assembly.FindManifestResourceStream("Object.Coverage.json"));

            Assert.NotNull(data, nameof(data));
            data.Collect(typeof(IDictionary));
            data.Collect <IDictionary>(Filter);
            data.Collect <IDictionary>("");
            data.Collect <IDictionary>("test");
            data.CollectKeys();
        }
Example #5
0
        public void Read(string name)
        {
            Reader reader = new Reader();

            System.Reflection.Assembly assembly = typeof(ReaderTest).Assembly;
            Stream stream = assembly.FindManifestResourceStream(name);

            Assert.NotNull(stream, nameof(stream));
            using MemoryStream memory = new MemoryStream();
            stream.CopyTo(memory);
            memory.Seek(0, SeekOrigin.Begin);

            MemoryStream memory2 = new MemoryStream();

            memory.CopyTo(memory2);
            memory.Seek(0, SeekOrigin.Begin);

            IDictionary i = reader.Read <IDictionary>(memory);

            Assert.NotNull(i, nameof(i));
            Assert.True(i.Contains("string_symbol"), "i.Contains 'string_symbol'");
            Assert.AreEqual("0°", i["string_symbol"].ToString(), "i['string_symbol']");

            memory2.Seek(0, SeekOrigin.Begin);
            string filename = Path.GetTempFileName();

            using (FileStream fs = new FileStream(filename, FileMode.Create))
            {
                memory2.CopyTo(fs);
            }
            IDictionary d = reader.Read(filename) as IDictionary;

            Assert.NotNull(d, nameof(d));
            Assert.True(d.Contains("string_symbol"), "d.Contains 'string_symbol'");
            Assert.AreEqual("0°", d["string_symbol"].ToString(), "d['string_symbol']");

            using MemoryStream memory3 = new MemoryStream();
            d.Save(memory3);
        }