Beispiel #1
0
        public void GetResourceDescriptorsPerAssembly_Only_Contains_IIdentifiable_Types()
        {
            // Arrange
            Type resourceType = typeof(Model);

            var assemblyCache = new ResourceDescriptorAssemblyCache();

            assemblyCache.RegisterAssembly(resourceType.Assembly);

            // Act
            IReadOnlyCollection <ResourceDescriptor> descriptors = assemblyCache.GetResourceDescriptors();

            // Assert
            descriptors.Should().NotBeEmpty();
            descriptors.Select(descriptor => descriptor.ResourceType).Should().AllBeAssignableTo <IIdentifiable>();
        }
Beispiel #2
0
        public void GetResourceDescriptorsPerAssembly_Locates_Identifiable_Resource()
        {
            // Arrange
            Type resourceType = typeof(Model);

            var assemblyCache = new ResourceDescriptorAssemblyCache();

            assemblyCache.RegisterAssembly(resourceType.Assembly);

            // Act
            IReadOnlyCollection <ResourceDescriptor> descriptors = assemblyCache.GetResourceDescriptors();

            // Assert
            descriptors.Should().NotBeEmpty();
            descriptors.Should().ContainSingle(descriptor => descriptor.ResourceType == resourceType);
        }
Beispiel #3
0
        public void GetResourceDescriptorsPerAssembly_Locates_Identifiable_Resource()
        {
            // Arrange
            var resourceType = typeof(Model);

            var assemblyCache = new ResourceDescriptorAssemblyCache();

            assemblyCache.RegisterAssembly(resourceType.Assembly);

            // Act
            var results = assemblyCache.GetResourceDescriptorsPerAssembly();

            // Assert
            Assert.Contains(results, result => result.resourceDescriptors != null &&
                            result.resourceDescriptors.Any(descriptor => descriptor.ResourceType == resourceType));
        }
Beispiel #4
0
        public void GetResourceDescriptorsPerAssembly_Only_Contains_IIdentifiable_Types()
        {
            // Arrange
            var resourceType = typeof(Model);

            var assemblyCache = new ResourceDescriptorAssemblyCache();

            assemblyCache.RegisterAssembly(resourceType.Assembly);

            // Act
            var results = assemblyCache.GetResourceDescriptorsPerAssembly();

            // Assert
            foreach (var resourceDescriptor in results.SelectMany(result => result.resourceDescriptors))
            {
                Assert.True(typeof(IIdentifiable).IsAssignableFrom(resourceDescriptor.ResourceType));
            }
        }