Ejemplo n.º 1
0
        /// <summary>
        /// Test resource enumerator
        /// </summary>
        /// <typeparam name="T">type of enumerator</typeparam>
        /// <param name="storageName">storage name</param>
        /// <param name="testItemDataList">test item data list</param>
        private static void TestGeneric <T>(string storageName, Tuple <string, int, string, string>[] testItemDataList)
        {
            var    informationCollection = new ResourceInformationCollection <T>();
            string content;
            string resourceName;
            KeyValuePair <string, string> pair;
            T id;

            Assert.AreEqual(storageName ?? typeof(T).Name, informationCollection.StorageName);
            foreach (var testItemData in testItemDataList)
            {
                resourceName = testItemData.Item3 ?? testItemData.Item1;
                content      = informationCollection.GetContent(resourceName);
                Assert.AreEqual(testItemData.Item4, content);

                id = (T)Enum.ToObject(typeof(T), testItemData.Item2);
                Assert.IsTrue(informationCollection.TryGetResourceInformation(id, out pair));
                Assert.AreEqual(resourceName, pair.Key);
                Assert.AreEqual(testItemData.Item4, pair.Value);
            }

            //Test bad resource name
            resourceName = TestHelper.CreateUniqueName("ResourceName{0}");
            content      = informationCollection.GetContent(resourceName);
            Assert.IsNull(content);

            //Test bad id
            id = (T)(object)(testItemDataList.Length * 5);
            Assert.IsFalse(informationCollection.TryGetResourceInformation(id, out pair));
        }
Ejemplo n.º 2
0
 public void ResourceInformationCollection_GetContent_NullResourceName()
 {
     var informationCollection = new ResourceInformationCollection <TestResource>();
     var content = informationCollection.GetContent(null);
 }