public void GenerateActionLinkForFeed_ThrowsArgumentNull_Action() { // Arrange FeedContext feedContext = new FeedContext(); // Act & Assert Assert.ThrowsArgumentNull(() => feedContext.GenerateActionLink(action: null), "action"); }
public void GenerateActionLinkForFeed_ThrowsArgumentNull_FeedContext() { // Arrange FeedContext feedContext = null; IEdmAction action = new Mock <IEdmAction>().Object; // Act & Assert Assert.ThrowsArgumentNull(() => feedContext.GenerateActionLink(action), "feedContext"); }
public void GenerateActionLinkForFeed_ThrowsActionNotBoundToCollectionOfEntity_IfActionHasNoParameters() { // Arrange FeedContext context = new FeedContext(); Mock <IEdmAction> action = new Mock <IEdmAction>(); action.Setup(a => a.Parameters).Returns(Enumerable.Empty <IEdmOperationParameter>()); action.Setup(a => a.Name).Returns("SomeAction"); // Act & Assert Assert.ThrowsArgument( () => context.GenerateActionLink(action.Object), "action", "The action 'SomeAction' is not bound to the collection of entity. Only actions that are bound to entities can have action links."); }
public void GenerateActionLinkForFeed_GeneratesLinkWithCast_IfEntitySetTypeDoesnotMatchActionEntityType() { // Arrange HttpRequestMessage request = GetODataRequest(_model.Model); IEdmAction action = _model.Model.SchemaElements.OfType <IEdmAction>().First(a => a.Name == "UpgradeSpecialAll"); Assert.NotNull(action); // Guard var context = new FeedContext { Request = request, EntitySetBase = _model.Customers, Url = request.GetUrlHelper(), }; // Act Uri link = context.GenerateActionLink(action); // Assert Assert.Equal("http://localhost/Customers/NS.SpecialCustomer/NS.UpgradeSpecialAll", link.AbsoluteUri); }
public void GenerateActionLinkForFeed_GeneratesLinkWithDownCast_IfElementTypeDerivesFromBindingParameterType() { // Arrange HttpRequestMessage request = GetODataRequest(_model.Model); IEdmAction action = _model.Model.SchemaElements.OfType <IEdmAction>().First(a => a.Name == "UpgradeAll"); Assert.NotNull(action); // Guard IEdmEntitySet specialCustomers = new EdmEntitySet(_model.Container, "SpecialCustomers", _model.SpecialCustomer); var context = new FeedContext { Request = request, EntitySetBase = specialCustomers, Url = request.GetUrlHelper(), }; // Act Uri link = context.GenerateActionLink(action); // Assert Assert.Equal("http://localhost/SpecialCustomers/NS.Customer/NS.UpgradeAll", link.AbsoluteUri); }
public void GenerateActionLinkForFeed_GeneratesLinkWithDownCast_IfElementTypeDerivesFromBindingParameterType() { // Arrange HttpRequestMessage request = GetODataRequest(_model.Model); IEdmAction action = _model.Model.SchemaElements.OfType<IEdmAction>().First(a => a.Name == "UpgradeAll"); Assert.NotNull(action); // Guard IEdmEntitySet specialCustomers = new EdmEntitySet(_model.Container, "SpecialCustomers", _model.SpecialCustomer); var context = new FeedContext { Request = request, EntitySetBase = specialCustomers, Url = request.GetUrlHelper(), }; // Act Uri link = context.GenerateActionLink(action); // Assert Assert.Equal("http://localhost/SpecialCustomers/NS.Customer/NS.UpgradeAll", link.AbsoluteUri); }
public void GenerateActionLinkForFeed_GeneratesLinkWithCast_IfEntitySetTypeDoesnotMatchActionEntityType() { // Arrange HttpRequestMessage request = GetODataRequest(_model.Model); IEdmAction action = _model.Model.SchemaElements.OfType<IEdmAction>().First(a => a.Name == "UpgradeSpecialAll"); Assert.NotNull(action); // Guard var context = new FeedContext { Request = request, EntitySetBase = _model.Customers, Url = request.GetUrlHelper(), }; // Act Uri link = context.GenerateActionLink(action); // Assert Assert.Equal("http://localhost/Customers/NS.SpecialCustomer/NS.UpgradeSpecialAll", link.AbsoluteUri); }
public void GenerateActionLinkForFeed_ThrowsActionNotBoundToCollectionOfEntity_IfActionHasNoParameters() { // Arrange FeedContext context = new FeedContext(); Mock<IEdmAction> action = new Mock<IEdmAction>(); action.Setup(a => a.Parameters).Returns(Enumerable.Empty<IEdmOperationParameter>()); action.Setup(a => a.Name).Returns("SomeAction"); // Act & Assert Assert.ThrowsArgument( () => context.GenerateActionLink(action.Object), "action", "The action 'SomeAction' is not bound to the collection of entity. Only actions that are bound to entities can have action links."); }