public void TryGetResourceDescriptor_Returns_False_If_Type_Is_IIdentifiable() { // Arrange var resourceType = typeof(String); // Act var descriptor = TypeLocator.TryGetResourceDescriptor(resourceType); // Assert Assert.Null(descriptor); }
public void TryGetResourceDescriptor_Returns_False_If_Type_Is_IIdentifiable() { // Arrange var resourceType = typeof(String); // Act var isJsonApiResource = TypeLocator.TryGetResourceDescriptor(resourceType, out var _); // Assert Assert.False(isJsonApiResource); }
public void TryGetResourceDescriptor_Returns_True_If_Type_Is_IIdentifiable() { // Arrange var resourceType = typeof(Model); // Act var isJsonApiResource = TypeLocator.TryGetResourceDescriptor(resourceType, out var descriptor); // Assert Assert.True(isJsonApiResource); Assert.Equal(resourceType, descriptor.ResourceType); Assert.Equal(typeof(int), descriptor.IdType); }
public void TryGetResourceDescriptor_Returns_Type_If_Type_Is_IIdentifiable() { // Arrange Type resourceType = typeof(Model); var typeLocator = new TypeLocator(); // Act ResourceDescriptor descriptor = typeLocator.TryGetResourceDescriptor(resourceType); // Assert Assert.NotNull(descriptor); Assert.Equal(resourceType, descriptor.ResourceType); Assert.Equal(typeof(int), descriptor.IdType); }
private static HashSet <ResourceDescriptor> GetResourceTypesFromServiceImplementation(Type type) { var resourceDescriptors = new HashSet <ResourceDescriptor>(); var interfaces = type.GetInterfaces(); foreach (var i in interfaces) { if (i.IsGenericType) { var firstGenericArgument = i.GenericTypeArguments.FirstOrDefault(); if (TypeLocator.TryGetResourceDescriptor(firstGenericArgument, out var resourceDescriptor)) { resourceDescriptors.Add(resourceDescriptor); } } } return(resourceDescriptors); }