public void ResourceFile_GetResource_ShouldGetResourceStream()
        {
            var anchorAssembly = typeof(Anchor).Assembly;
            var file = new ResourceFile()
            {
                Assembly = anchorAssembly,
                ResourcePath = "ResourceProvider.Test.Example.folder.Class1.txt"
            };

            Action action = (() => file.GetResourceStream());
            action.ShouldNotThrow("It should return the resource stream");
        }
        public void ResourceFile_GetResource_ShouldGetResourceString()
        {
            var anchorAssembly = typeof(Anchor).Assembly;
            var file = new ResourceFile()
            {
                Assembly = anchorAssembly,
                ResourcePath = "RP.Test.Example.folder.Class1.txt"
            };

            Action action = (() => file.GetResourceString());
            action.ShouldNotThrow("It should return the resource string");

            var result = file.GetResourceString();
            result.Should().NotBeNullOrWhiteSpace("The file should have contents from the stream");
        }
        /// <summary>
        /// Caches the assembly resources.
        /// We also cache a list of all the overrides (there could be more than one!), so they can be accessed by certian code if needed.
        /// </summary>
        /// <param name="assembly">The assembly.</param>
        /// <param name="assemblyName">Name of the assembly.</param>
        /// <param name="namespaces">The namespaces.</param>
        /// <param name="resources">The resources.</param>
        private void CacheAssemblyResources(Assembly assembly, string assemblyName, IEnumerable<string> namespaces, string[] resources)
        {
            foreach (var resource in resources)
            {
                var namespaceName = namespaces.First(x => resource.StartsWith(x));
                // +1 for trailing dot.
                var substringIndex = GetAssemblyPrefix(namespaceName, resource).Length + 1;
                var relativeResourcePath = GetEmbeddedFileNamePath(resource.Substring(substringIndex));
                // Create our item
                IResourceFile item = new ResourceFile()
                {
                    Assembly = assembly,
                    ResourcePath = resource,
                    ProjectPath = _assemblyProjectPath.GetOrAdd(assemblyName, String.Empty)
                };

                // Get list of items.
                IList<IResourceFile> items = null;
                this._embeddedResourceItemCollections.TryGetValue(relativeResourcePath, out items);

                // No items, create list, and this is the first resource, so lets add the list, and also add this item as the default item.
                // This handles the case where we have an override file, but we can also expose the other files, if we need to get access to them for some reason.
                if (items == null)
                {
                    items = new List<IResourceFile>();

                    this._embeddedResourceItemCollections.TryAdd(relativeResourcePath, items);
                    this._embeddedResourceItems.TryAdd(relativeResourcePath, item);
                }
                items.Add(item);
            }
        }