GetAllAssemblyResourceInfos() public method

public GetAllAssemblyResourceInfos ( string baseNamespace ) : IEnumerable
baseNamespace string
return IEnumerable
        public void GetAllAssemblyResourceInfos_AssemblyContainsNoResourcesTheSuppliedBaseNameSpace_NoResultsAreReturned(string baseNamespace)
        {
            // Arrange
            var assemblyResourceNames = new[]
                {
                    string.Format(AssemblyResourcePattern, "Some.Other.Namespace1", 1),
                    string.Format(AssemblyResourcePattern, "Some.Other.Namespace1", 2),
                    string.Format(AssemblyResourcePattern, "Some.Other.Namespace1", 3),
                    string.Format(AssemblyResourcePattern, "Some.Other.Namespace2", 1)
                };

            var sourceAssembly = new Mock<_Assembly>();
            sourceAssembly.Setup(a => a.GetManifestResourceNames()).Returns(assemblyResourceNames);

            var assemblyResourceFilePathProvider = new Mock<IAssemblyResourceFilePathProvider>().Object;
            IAssemblyFileResourceProvider assemblyFileResourceProvider = new AssemblyFileResourceProvider(sourceAssembly.Object, assemblyResourceFilePathProvider);

            // Act
            var results = assemblyFileResourceProvider.GetAllAssemblyResourceInfos(baseNamespace);

            // Assert.
            Assert.AreEqual(0, results.Count());
        }
        public void GetAllAssemblyResourceInfos_SuppliedBaseNamespaceIsNotSet_ArgumentExceptionIsThrown(string baseNamespace)
        {
            // Arrange
            var assemblyResourceNames = new[]
                {
                    string.Format(AssemblyResourcePattern, "Some.Other.Namespace1", 1),
                    string.Format(AssemblyResourcePattern, "Some.Other.Namespace1", 2),
                    string.Format(AssemblyResourcePattern, "Some.Other.Namespace1", 3),
                    string.Format(AssemblyResourcePattern, "Some.Other.Namespace2", 1)
                };

            var sourceAssembly = new Mock<_Assembly>();
            sourceAssembly.Setup(a => a.GetManifestResourceNames()).Returns(assemblyResourceNames);

            var assemblyResourceFilePathProvider = new Mock<IAssemblyResourceFilePathProvider>().Object;
            IAssemblyFileResourceProvider assemblyFileResourceProvider = new AssemblyFileResourceProvider(sourceAssembly.Object, assemblyResourceFilePathProvider);

            // Act
            assemblyFileResourceProvider.GetAllAssemblyResourceInfos(baseNamespace);
        }
        public void GetAllAssemblyResourceInfos_AssemblyResourceFilePathProvider_GetRelativeFilePath_GetCalledForEachResource()
        {
            // Arrange
            int numberOfTimesGetRelativeFilePathGotCalled = 0;
            string baseNamespace = "Assembly.Resource";

            var assemblyResourceNames = new[]
                {
                    string.Format(AssemblyResourcePattern, baseNamespace, 1),
                    string.Format(AssemblyResourcePattern, baseNamespace, 2),
                    string.Format(AssemblyResourcePattern, baseNamespace, 3)
                };

            var sourceAssembly = new Mock<_Assembly>();
            sourceAssembly.Setup(a => a.GetManifestResourceNames()).Returns(assemblyResourceNames);

            var assemblyResourceFilePathProvider = new Mock<IAssemblyResourceFilePathProvider>();
            assemblyResourceFilePathProvider.Setup(p => p.GetRelativeFilePath(It.IsAny<string>(), It.IsAny<string>())).Returns(
                () =>
                    {
                        numberOfTimesGetRelativeFilePathGotCalled++;
                        return "Some\\Path\\" + numberOfTimesGetRelativeFilePathGotCalled;
                    });

            IAssemblyFileResourceProvider assemblyFileResourceProvider = new AssemblyFileResourceProvider(sourceAssembly.Object, assemblyResourceFilePathProvider.Object);

            // Act
            var results = assemblyFileResourceProvider.GetAllAssemblyResourceInfos(baseNamespace);

            // Assert.
            Assert.AreEqual(results.Count(), numberOfTimesGetRelativeFilePathGotCalled);
        }