Ejemplo n.º 1
0
        private static bool UpdateQuery(ContainmentQuery query, ContainmentQuerySuffix suffix, RequestVerb verb)
        {
            switch (suffix)
            {
            case ContainmentQuerySuffix.SingleNavigationTwice:
                return(ApplyNavigationProperties(query, Multiplicity.One, Multiplicity.One));

            case ContainmentQuerySuffix.SingleNavigation:
                return(ApplyNavigationProperties(query, Multiplicity.One));

            case ContainmentQuerySuffix.MultipleNavigation:
                return(ApplyNavigationProperties(query, Multiplicity.Many));

            case ContainmentQuerySuffix.LinkedSingleNavigation:
                return(ApplyLink(query, Multiplicity.One));

            case ContainmentQuerySuffix.LinkedMultipleNavigation:
                return(ApplyLink(query, Multiplicity.Many));

            case ContainmentQuerySuffix.SimpleType:
                return(ApplySimpleType(query));

            case ContainmentQuerySuffix.None:
                return(true);

            default:
                return(false);
            }
        }
Ejemplo n.º 2
0
        private static bool MethodAllowed(ContainmentQuery query, ContainmentQuerySuffix suffix, RequestVerb verb)
        {
            if (query.SetExpected)
            {
                if (suffix != ContainmentQuerySuffix.None)
                {
                    AstoriaTestLog.FailAndThrow("Only the NONE suffix can be used when a set is expected");
                }

                return(verb == RequestVerb.Get || verb == RequestVerb.Post);
            }
            else
            {
                return(VerbMap.Valid(suffix, verb));
            }
        }
Ejemplo n.º 3
0
 private static void UpdateErrorState(ContainmentQuery query, ContainmentQuerySuffix suffix, RequestVerb verb)
 {
     if (!MethodAllowed(query, suffix, verb))
     {
         // TODO: set error identifier?
         query.ExpectedStatusCode = HttpStatusCode.MethodNotAllowed;
         switch (verb)
         {
         case RequestVerb.Post:
             query.ExpectedErrorIdentifier = SystemDataServicesResourceIdentifiers.BadRequest_InvalidUriForPostOperation;
             UriQueryBuilder builder = new UriQueryBuilder(query.Workspace, query.Workspace.ServiceEndPoint);
             query.ExpectedErrorArgs = new object[] { builder.Build(query.Query) };
             break;
         }
     }
 }
Ejemplo n.º 4
0
 public static bool AppendSuffix(this ContainmentQuery query, ContainmentQuerySuffix suffix, RequestVerb verb)
 {
     UpdateErrorState(query, suffix, verb);
     return(UpdateQuery(query, suffix, verb));
 }
Ejemplo n.º 5
0
 public static bool AppendSuffix(this ContainmentQuery query, ContainmentQuerySuffix suffix)
 {
     return(query.AppendSuffix(suffix, RequestVerb.Get));
 }
Ejemplo n.º 6
0
 public static bool AppendSuffix(this ContainmentQuery query, ContainmentQuerySuffix suffix, RequestVerb verb)
 {
     UpdateErrorState(query, suffix, verb);
     return UpdateQuery(query, suffix, verb);
 }
Ejemplo n.º 7
0
 public static bool Valid(ContainmentQuerySuffix suffix, RequestVerb verb)
 {
     return(map[suffix].Contains(verb));
 }
Ejemplo n.º 8
0
 public static bool AppendSuffix(this ContainmentQuery query, ContainmentQuerySuffix suffix)
 {
     return query.AppendSuffix(suffix, RequestVerb.Get);
 }
Ejemplo n.º 9
0
        private static bool UpdateQuery(ContainmentQuery query, ContainmentQuerySuffix suffix, RequestVerb verb)
        {
            switch (suffix)
            {
                case ContainmentQuerySuffix.SingleNavigationTwice:
                    return ApplyNavigationProperties(query, Multiplicity.One, Multiplicity.One);

                case ContainmentQuerySuffix.SingleNavigation:
                    return ApplyNavigationProperties(query, Multiplicity.One);

                case ContainmentQuerySuffix.MultipleNavigation:
                    return ApplyNavigationProperties(query, Multiplicity.Many);

                case ContainmentQuerySuffix.LinkedSingleNavigation:
                    return ApplyLink(query, Multiplicity.One);

                case ContainmentQuerySuffix.LinkedMultipleNavigation:
                    return ApplyLink(query, Multiplicity.Many);

                case ContainmentQuerySuffix.SimpleType:
                    return ApplySimpleType(query);

                case ContainmentQuerySuffix.None:
                    return true;

                default:
                    return false;
            }
        }
Ejemplo n.º 10
0
 private static void UpdateErrorState(ContainmentQuery query, ContainmentQuerySuffix suffix, RequestVerb verb)
 {
     if (!MethodAllowed(query, suffix, verb))
     {
         // TODO: set error identifier?
         query.ExpectedStatusCode = HttpStatusCode.MethodNotAllowed;
         switch (verb)
         {
             case RequestVerb.Post:
                 query.ExpectedErrorIdentifier = SystemDataServicesResourceIdentifiers.BadRequest_InvalidUriForPostOperation;
                 UriQueryBuilder builder = new UriQueryBuilder(query.Workspace, query.Workspace.ServiceEndPoint);
                 query.ExpectedErrorArgs = new object[] { builder.Build(query.Query) };
                 break;
         }
     }
 }
Ejemplo n.º 11
0
        private static bool MethodAllowed(ContainmentQuery query, ContainmentQuerySuffix suffix, RequestVerb verb)
        {
            if (query.SetExpected)
            {
                if (suffix != ContainmentQuerySuffix.None)
                {
                    AstoriaTestLog.FailAndThrow("Only the NONE suffix can be used when a set is expected");
                }

                return verb == RequestVerb.Get || verb == RequestVerb.Post;
            }
            else
            {
                return VerbMap.Valid(suffix, verb);
            }
        }
Ejemplo n.º 12
0
 public static bool Valid(ContainmentQuerySuffix suffix, RequestVerb verb)
 {
     return map[suffix].Contains(verb);
 }