Esempio n. 1
0
 public async Task VisitAsync(ODataPath path)
 {
     NotFound       = false;
     BadRequest     = false;
     Result         = null;
     ResultType     = null;
     PropertySetter = null;
     Index          = 0;
     foreach (var segment in path)
     {
         await(segment switch
         {
             TypeSegment typeSegment => VisitAsync(typeSegment),
             NavigationPropertySegment navigationPropertySegment => VisitAsync(navigationPropertySegment),
             EntitySetSegment entitySetSegment => VisitAsync(entitySetSegment),
             SingletonSegment singletonSegment => VisitAsync(singletonSegment),
             KeySegment keySegment => VisitAsync(keySegment),
             PropertySegment propertySegment => VisitAsync(propertySegment),
             AnnotationSegment annotationSegment => VisitAsync(annotationSegment),
             OperationImportSegment operationImportSegment => VisitAsync(operationImportSegment),
             OperationSegment operationSegment => VisitAsync(operationSegment),
             DynamicPathSegment dynamicPathSegment => VisitAsync(dynamicPathSegment),
             CountSegment countSegment => VisitAsync(countSegment),
             FilterSegment filterSegment => VisitAsync(filterSegment),
             ReferenceSegment referenceSegment => VisitAsync(referenceSegment),
             EachSegment eachSegment => VisitAsync(eachSegment),
             NavigationPropertyLinkSegment navigationPropertyLinkSegment => VisitAsync(navigationPropertyLinkSegment),
             ValueSegment valueSegment => VisitAsync(valueSegment),
             BatchSegment batchSegment => VisitAsync(batchSegment),
             BatchReferenceSegment batchReferenceSegment => VisitAsync(batchReferenceSegment),
             MetadataSegment metadataSegment => VisitAsync(metadataSegment),
             PathTemplateSegment pathTemplateSegment => VisitAsync(pathTemplateSegment),
             _ => throw new NotSupportedException()
         });
 public void EqualityIsCorrect() 
 {
     IEdmEntityType type = HardCodedTestModel.GetPersonType();
     BatchReferenceSegment batchReferenceSegment1 = new BatchReferenceSegment("$0", type, HardCodedTestModel.GetPeopleSet());
     BatchReferenceSegment batchReferenceSegment2 = new BatchReferenceSegment("$0", type, HardCodedTestModel.GetPeopleSet());
     batchReferenceSegment1.Equals(batchReferenceSegment2).Should().BeTrue();
 }
Esempio n. 3
0
 /// <summary>
 /// Translate a BatchReferenceSegment
 /// </summary>
 /// <param name="segment">the segment to Translate</param>
 /// <returns>Translated WebApi path segment.</returns>
 public override IEnumerable <ODataPathSegment> Translate(BatchReferenceSegment segment)
 {
     throw new ODataException(Error.Format(
                                  SRResources.TargetKindNotImplemented,
                                  typeof(Semantic.ODataPathSegment).Name,
                                  typeof(BatchReferenceSegment).Name));
 }
        public static BatchReferenceSegment ShouldBeBatchReferenceSegment(this ODataPathSegment segment, IEdmType resultingType)
        {
            Assert.NotNull(segment);
            BatchReferenceSegment batchReferenceSegment = Assert.IsType <BatchReferenceSegment>(segment);

            Assert.Same(resultingType, batchReferenceSegment.EdmType);
            return(batchReferenceSegment);
        }
        public void EqualityIsCorrect()
        {
            IEdmEntityType        type = HardCodedTestModel.GetPersonType();
            BatchReferenceSegment batchReferenceSegment1 = new BatchReferenceSegment("$0", type, HardCodedTestModel.GetPeopleSet());
            BatchReferenceSegment batchReferenceSegment2 = new BatchReferenceSegment("$0", type, HardCodedTestModel.GetPeopleSet());

            batchReferenceSegment1.Equals(batchReferenceSegment2).Should().BeTrue();
        }
Esempio n. 6
0
        public static AndConstraint <BatchReferenceSegment> ShouldBeBatchReferenceSegment(this ODataPathSegment segment, IEdmType resultingType)
        {
            segment.Should().BeOfType <BatchReferenceSegment>();
            BatchReferenceSegment batchReferenceSegment = segment.As <BatchReferenceSegment>();

            batchReferenceSegment.EdmType.Should().Be(resultingType);
            return(new AndConstraint <BatchReferenceSegment>(batchReferenceSegment));
        }
Esempio n. 7
0
        public void TranslateWithBatchReferenceSegmentReturnsFalse()
        {
            IsCollectionTranslator translator = new IsCollectionTranslator();
            var segment = new BatchReferenceSegment(
                "$0", HardCodedTestModel.GetDogType(), HardCodedTestModel.GetDogsSet());

            Assert.False(translator.Translate(segment));
        }
 public void ContentIDSetCorrectly()
 {
     IEdmEntityType type = HardCodedTestModel.GetPersonType();
     BatchReferenceSegment batchReferenceSegment = new BatchReferenceSegment("$40", type, HardCodedTestModel.GetPeopleSet());
     batchReferenceSegment.ShouldBeBatchReferenceSegment(type).And.ContentId.Should().Be("$40");
     IEdmEntityType dogType = HardCodedTestModel.GetDogType();
     BatchReferenceSegment containedBatchReferenceSegment = new BatchReferenceSegment("$40", dogType, HardCodedTestModel.GetContainedDogEntitySet());
     containedBatchReferenceSegment.ShouldBeBatchReferenceSegment(dogType).And.ContentId.Should().Be("$40");
 }
 public void EntitySetSetCorrectly()
 {
     IEdmEntityType type = HardCodedTestModel.GetPersonType();
     BatchReferenceSegment batchReferenceSegment = new BatchReferenceSegment("$0", type, HardCodedTestModel.GetPeopleSet());
     batchReferenceSegment.EntitySet.Should().BeSameAs(HardCodedTestModel.GetPeopleSet());
     IEdmEntityType dogType = HardCodedTestModel.GetDogType();
     BatchReferenceSegment containedBatchReferenceSegment = new BatchReferenceSegment("$40", dogType, HardCodedTestModel.GetContainedDogEntitySet());
     containedBatchReferenceSegment.EntitySet.Should().Be(HardCodedTestModel.GetContainedDogEntitySet());
 }
Esempio n. 10
0
        public void Translate_BatchReferenceSegment_Throws()
        {
            // Arrange
            IEdmEntityType        entityType = _model.FindDeclaredType("System.Web.OData.Routing.RoutingCustomer") as IEdmEntityType;
            IEdmEntitySet         entityset  = _model.FindDeclaredEntitySet("RoutingCustomers");
            BatchReferenceSegment segment    = new BatchReferenceSegment("$10", entityType, entityset);

            // Act & Assert
            Assert.Throws <ODataException>(() => _translator.Translate(segment), "'ODataPathSegment' of kind 'BatchReferenceSegment' is not implemented.");
        }
        public void ContentIDSetCorrectly()
        {
            IEdmEntityType        type = HardCodedTestModel.GetPersonType();
            BatchReferenceSegment batchReferenceSegment = new BatchReferenceSegment("$40", type, HardCodedTestModel.GetPeopleSet());

            batchReferenceSegment.ShouldBeBatchReferenceSegment(type).And.ContentId.Should().Be("$40");
            IEdmEntityType        dogType = HardCodedTestModel.GetDogType();
            BatchReferenceSegment containedBatchReferenceSegment = new BatchReferenceSegment("$40", dogType, HardCodedTestModel.GetContainedDogEntitySet());

            containedBatchReferenceSegment.ShouldBeBatchReferenceSegment(dogType).And.ContentId.Should().Be("$40");
        }
        public void EntitySetSetCorrectly()
        {
            IEdmEntityType        type = HardCodedTestModel.GetPersonType();
            BatchReferenceSegment batchReferenceSegment = new BatchReferenceSegment("$0", type, HardCodedTestModel.GetPeopleSet());

            batchReferenceSegment.EntitySet.Should().BeSameAs(HardCodedTestModel.GetPeopleSet());
            IEdmEntityType        dogType = HardCodedTestModel.GetDogType();
            BatchReferenceSegment containedBatchReferenceSegment = new BatchReferenceSegment("$40", dogType, HardCodedTestModel.GetContainedDogEntitySet());

            containedBatchReferenceSegment.EntitySet.Should().Be(HardCodedTestModel.GetContainedDogEntitySet());
        }
        public void InEqualityIsCorrect()
        {
            IEdmEntityType        type1 = HardCodedTestModel.GetPersonType();
            IEdmEntityType        type2 = HardCodedTestModel.GetDogType();
            BatchReferenceSegment batchReferenceSegment1 = new BatchReferenceSegment("$0", type1, HardCodedTestModel.GetPeopleSet());
            BatchReferenceSegment batchReferenceSegment2 = new BatchReferenceSegment("$0", type2, HardCodedTestModel.GetDogsSet());
            BatchReferenceSegment batchReferenceSegment3 = new BatchReferenceSegment("$10", type1, HardCodedTestModel.GetPeopleSet());
            BatchReferenceSegment batchReferenceSegment4 = new BatchReferenceSegment("$10", type2, HardCodedTestModel.GetContainedDogEntitySet());

            batchReferenceSegment1.Equals(batchReferenceSegment2).Should().BeFalse();
            batchReferenceSegment1.Equals(batchReferenceSegment3).Should().BeFalse();
            batchReferenceSegment2.Equals(batchReferenceSegment4).Should().BeFalse();
        }
Esempio n. 14
0
        public void ODataPathSegmentToTemplateHandler_Throws_BatchReferenceSegment()
        {
            // Arrange
            ODataPathSegmentToTemplateHandler handler = new ODataPathSegmentToTemplateHandler(null);

            EdmEntityContainer    entityContainer = new EdmEntityContainer("NS", "Default");
            EdmEntityType         customer        = new EdmEntityType("NS", "Customer");
            EdmEntitySet          customers       = entityContainer.AddEntitySet("Customers", customer);
            BatchReferenceSegment segment         = new BatchReferenceSegment("$4", customer, customers);

            // Act
            Action test = () => handler.Handle(segment);

            // Assert
            ExceptionAssert.Throws <ODataException>(test, "'ODataPathSegment' of kind 'BatchReferenceSegment' is not implemented.");
        }
 /// <summary>
 /// Translate a BatchReferenceSegment
 /// </summary>
 /// <param name="segment">the segment to Translate</param>
 /// <returns>Defined by the implementer.</returns>
 public override string Translate(BatchReferenceSegment segment)
 {
     throw new NotImplementedException();
 }
 /// <summary>
 /// Translate a BatchReferenceSegment
 /// </summary>
 /// <param name="segment">the segment to Translate</param>
 /// <returns>Translated the path segment template.</returns>
 public override ODataPathSegmentTemplate Translate(BatchReferenceSegment segment)
 {
     throw new ODataException(/*TODO: Error.Format(SRResources.TargetKindNotImplemented, "ODataPathSegment", "BatchReferenceSegment")*/);
 }
Esempio n. 17
0
        public override void Handle(BatchReferenceSegment segment)
        {
            this.ThrowIfResolved();

            throw Utility.BuildException(HttpStatusCode.NotImplemented, "BatchReferenceSegment is not supported.", null);
        }
Esempio n. 18
0
 /// <summary>
 /// Handle a BatchReferenceSegment
 /// </summary>
 /// <param name="segment">the segment to Handle</param>
 public virtual void Handle(BatchReferenceSegment segment)
 {
     throw new NotImplementedException();
 }
 /// <summary>
 /// Translate a BatchReferenceSegment
 /// </summary>
 /// <param name="segment">the segment to Translate</param>
 /// <returns>Defined by the implementer.</returns>
 public override string Translate(BatchReferenceSegment segment)
 {
     return(string.Empty);
 }
 /// <summary>
 /// Translate a BatchReferenceSegment
 /// </summary>
 /// <param name="segment">the segment to Translate</param>
 /// <returns>UserDefinedValue</returns>
 /// <exception cref="System.ArgumentNullException">Throws if the input segment is null.</exception>
 public override bool Translate(BatchReferenceSegment segment)
 {
     ExceptionUtils.CheckArgumentNotNull(segment, "segment");
     return(false);
 }
Esempio n. 21
0
 /// <summary>
 /// Handle a BatchReferenceSegment
 /// </summary>
 /// <param name="segment">the segment to Handle</param>
 public virtual void Handle(BatchReferenceSegment segment)
 {
     throw new NotImplementedException();
 }
Esempio n. 22
0
 /// <summary>
 /// Translate a BatchReferenceSegment
 /// </summary>
 /// <param name="segment">the segment to Translate</param>
 /// <returns>Defined by the implementer.</returns>
 public virtual T Translate(BatchReferenceSegment segment)
 {
     throw new NotImplementedException();
 }
Esempio n. 23
0
 /// <summary>
 /// Translate a BatchReferenceSegment.
 /// </summary>
 /// <param name="segment">the segment to Translate</param>
 /// <returns>Translated the path segment template.</returns>
 public override void Handle(BatchReferenceSegment segment)
 {
     throw new ODataException(Error.Format(SRResources.TargetKindNotImplemented, "ODataPathSegment", "BatchReferenceSegment"));
 }
Esempio n. 24
0
 /// <summary>
 /// Handle validating a BatchReferenceSegment
 /// </summary>
 /// <param name="segment">The batch reference segment to valdiate.</param>
 public override void Handle(BatchReferenceSegment segment)
 {
     ValidatePath(segment);
     ValidateItem(segment.EntitySet);
 }
 public void InEqualityIsCorrect()
 {
     IEdmEntityType type1 = HardCodedTestModel.GetPersonType();
     IEdmEntityType type2 = HardCodedTestModel.GetDogType();
     BatchReferenceSegment batchReferenceSegment1 = new BatchReferenceSegment("$0", type1, HardCodedTestModel.GetPeopleSet());
     BatchReferenceSegment batchReferenceSegment2 = new BatchReferenceSegment("$0", type2, HardCodedTestModel.GetDogsSet());
     BatchReferenceSegment batchReferenceSegment3 = new BatchReferenceSegment("$10", type1, HardCodedTestModel.GetPeopleSet());
     BatchReferenceSegment batchReferenceSegment4 = new BatchReferenceSegment("$10", type2, HardCodedTestModel.GetContainedDogEntitySet());
     batchReferenceSegment1.Equals(batchReferenceSegment2).Should().BeFalse();
     batchReferenceSegment1.Equals(batchReferenceSegment3).Should().BeFalse();
     batchReferenceSegment2.Equals(batchReferenceSegment4).Should().BeFalse();
 }
Esempio n. 26
0
        public override void Handle(BatchReferenceSegment segment)
        {
            this.ThrowIfResolved();

            throw Utility.BuildException(HttpStatusCode.NotImplemented, "BatchReferenceSegment is not supported.", null);
        }
 /// <summary>
 /// Translate a BatchReferenceSegment
 /// </summary>
 /// <param name="segment">the segment to Translate</param>
 /// <returns>Defined by the implementer.</returns>
 public override string Translate(BatchReferenceSegment segment)
 {
     Debug.Assert(segment != null, "segment != null");
     return("/" + segment.ContentId);
 }
 /// <summary>
 /// Handle a BatchReferenceSegment
 /// </summary>
 /// <param name="segment">the segment to Handle</param>
 public override void Handle(BatchReferenceSegment segment)
 {
     CommonHandler(segment);
 }
        public void Translate_BatchReferenceSegment_Throws()
        {
            // Arrange
            IEdmEntityType entityType = _model.FindDeclaredType("System.Web.OData.Routing.RoutingCustomer") as IEdmEntityType;
            IEdmEntitySet entityset = _model.FindDeclaredEntitySet("RoutingCustomers");
            BatchReferenceSegment segment = new BatchReferenceSegment("$10", entityType, entityset);

            // Act & Assert
            Assert.Throws<ODataException>(() => _translator.Translate(segment), "'ODataPathSegment' of kind 'BatchReferenceSegment' is not implemented.");
        }
Esempio n. 30
0
 /// <summary>
 /// Translate BatchReferenceSegment to linq expression.
 /// </summary>
 /// <param name="segment">The BatchReferenceSegment</param>
 /// <returns>The linq expression</returns>
 public override Expression Translate(BatchReferenceSegment segment)
 {
     throw new NotImplementedException("BatchReferenceSegment translation is not supported");
 }
Esempio n. 31
0
 public override string Translate(BatchReferenceSegment segment)
 {
     return(string.Format("(${0})", segment.ContentId));
 }