public void ConstructorNegativeTest()
        {
            ExceptionUtils.ExpectedException <ArgumentException>(
                () => new ResourceSetPathExpression(null),
                "Value cannot be null or empty.\r\nParameter name: pathExpression",
                "Cannot use null or empty path expression.");

            ExceptionUtils.ExpectedException <ArgumentException>(
                () => new ResourceSetPathExpression(string.Empty),
                "Value cannot be null or empty.\r\nParameter name: pathExpression",
                "Cannot use null or empty path expression.");
        }
Beispiel #2
0
        public void ResourceSetNamesMustBeUniqueTest()
        {
            var metadataProvider = new ResourceSetsOverrideMetadataProvider("Test", "TestNS");

            metadataProvider.ResourceSetValues = new List <ResourceSet>();
            var type = metadataProvider.AddEntityType("EntityType", null, null, false);

            metadataProvider.ResourceSetValues.Add(new ResourceSet("Entities", type));
            metadataProvider.ResourceSetValues.Add(new ResourceSet("Entities", type));
            var wrapper = new DataServiceMetadataProviderWrapper(metadataProvider);

            ExceptionUtils.ExpectedException <DataServiceException>(
                () => wrapper.ResourceSets.Cast <object>().Count(),
                "The resource set 'Entities' returned by the provider is not read-only. Please make sure that all the resource sets are set to read-only.",
                "Two resource sets with the same name should fail in the wrapper.");
        }
Beispiel #3
0
        public void InvalidCasesTest()
        {
            ResourceType complexType    = new ResourceType(typeof(object), ResourceTypeKind.ComplexType, null, "foo", "Address", false);
            ResourceType primitiveType  = ResourceType.GetPrimitiveResourceType(typeof(int));
            ResourceType collectionType = ResourceType.GetCollectionResourceType(primitiveType);

            AstoriaTestNS.TestUtil.RunCombinations(
                new ResourceType[] { complexType, primitiveType, collectionType },
                (resourceType) =>
            {
                ExceptionUtils.ExpectedException <ArgumentException>(
                    () => new ResourceSet("Foo", resourceType),
                    "The ResourceTypeKind property of a ResourceType instance that is associated with a ResourceSet must have a value of 'EntityType'.",
                    "Cannot add non-entity types to container");
            });
        }
Beispiel #4
0
        public void ServiceOperationsMustBeReadOnlyTest()
        {
            var serviceOperationEntryPoints = new Action <DataServiceMetadataProviderWrapper, string>[] {
                (wrapper, name) => wrapper.TryResolveServiceOperation(name),
            };

            AstoriaTestNS.TestUtil.RunCombinations(
                serviceOperationEntryPoints,
                (serviceOperationEntryPoint) =>
            {
                var metadataProvider = new DSPMetadata("Test", "TestNS");
                var serviceOperation = metadataProvider.AddServiceOperation("ServiceOperation", ServiceOperationResultKind.DirectValue, ResourceType.GetPrimitiveResourceType(typeof(string)), null, "GET", new ServiceOperationParameter[0]);
                var wrapper          = new DataServiceMetadataProviderWrapper(metadataProvider);
                ExceptionUtils.ExpectedException <DataServiceException>(
                    () => serviceOperationEntryPoint(wrapper, serviceOperation.Name),
                    "The service operation '" + serviceOperation.Name + "' returned by the provider is not read-only. Please make sure that all the service operations are set to read-only.",
                    "Accessing writable service operation should fail.");
            });
        }
Beispiel #5
0
        public void TypesMustBeReadOnlyTest()
        {
            var typesToTest = new Func <DSPMetadata, ResourceType>[] {
                (metadata) => metadata.AddEntityType("EntityType", null, null, false),
                (metadata) => metadata.AddComplexType("ComplexType", null, null, false)
            };

            AstoriaTestNS.TestUtil.RunCombinations(
                typesToTest,
                (typeCreate) =>
            {
                var metadataProvider = new DSPMetadata("Test", "TestNS");
                var type             = typeCreate(metadataProvider);
                var wrapper          = new DataServiceMetadataProviderWrapper(metadataProvider);
                ExceptionUtils.ExpectedException <DataServiceException>(
                    () => wrapper.TryResolveResourceType(type.FullName),
                    "The resource type '" + type.FullName + "' returned by the provider is not read-only. Please make sure that all the types are set to read-only.",
                    "Resolving resource type to writable type should fail.");
            });
        }
Beispiel #6
0
        public void SetsMustBeReadOnlyTest()
        {
            var resourceSetEntryPoints = new Action <DataServiceMetadataProviderWrapper, string>[] {
                (wrapper, name) => wrapper.TryResolveResourceSet(name),
                (wrapper, name) => wrapper.ResourceSets.Cast <object>().Count()
            };

            AstoriaTestNS.TestUtil.RunCombinations(
                resourceSetEntryPoints,
                (resourceSetEntryPoint) =>
            {
                var metadataProvider = new DSPMetadata("Test", "TestNS");
                var resourceType     = metadataProvider.AddEntityType("EntityType", null, null, false);
                var resourceSet      = metadataProvider.AddResourceSet("Entities", resourceType);
                resourceType.SetReadOnly();
                var wrapper = new DataServiceMetadataProviderWrapper(metadataProvider);
                ExceptionUtils.ExpectedException <DataServiceException>(
                    () => resourceSetEntryPoint(wrapper, resourceSet.Name),
                    "The resource set '" + resourceSet.Name + "' returned by the provider is not read-only. Please make sure that all the resource sets are set to read-only.",
                    "Accessing writable resource set should fail.");
            });
        }