public void Ctor_TakingAction_InitializesPropertyActionName() { // Arrange EdmEntityContainer container = new EdmEntityContainer("NS", "Container"); Mock<IEdmActionImport> edmAction = new Mock<IEdmActionImport>(); edmAction.Setup(a => a.Name).Returns("SomeAction"); edmAction.Setup(a => a.Container).Returns(container); // Act ActionPathSegment actionPathSegment = new ActionPathSegment(edmAction.Object); // Assert Assert.Equal("NS.Container.SomeAction", actionPathSegment.ActionName); }
public void GetEdmType_Returns_ActionReturnType() { // Arrange Mock<IEdmEntityType> returnType = new Mock<IEdmEntityType>(); EdmEntityContainer container = new EdmEntityContainer("NS", "Container"); Mock<IEdmActionImport> edmAction = new Mock<IEdmActionImport>(); edmAction.Setup(a => a.Name).Returns("SomeAction"); edmAction.Setup(a => a.Container).Returns(container); edmAction.Setup(a => a.Action.ReturnType).Returns(new EdmEntityTypeReference(returnType.Object, isNullable: false)); // Act ActionPathSegment segment = new ActionPathSegment(edmAction.Object); // Assert Assert.Same(returnType.Object, segment.GetEdmType(previousEdmType: null)); }
public void CanParseRootProcedureSegment() { // Arrange string testUrl = "http://myservice/GetCustomerById()"; string expectedText = "Default.Container.GetCustomerById"; IEdmEntitySet expectedSet = _parser.Model.EntityContainers().First().EntitySets().SingleOrDefault(s => s.Name == "Customers"); IEdmFunctionImport expectedEdmElement = _parser.Model.EntityContainers().First().FunctionImports().SingleOrDefault(s => s.Name == "GetCustomerById"); Uri uri = new Uri(testUrl); Uri baseUri = new Uri("http://myservice/"); // Act ODataPath path = _parser.Parse(uri, baseUri); ODataPathSegment segment = path.Segments.Last.Value; // Assert Assert.NotNull(segment); Assert.NotNull(segment.Previous); Assert.Equal(expectedText, segment.ToString()); Assert.Same(expectedSet, segment.EntitySet); Assert.Equal(expectedSet.ElementType, segment.EdmType); ActionPathSegment action = Assert.IsType <ActionPathSegment>(segment); Assert.Same(expectedEdmElement, action.Action); }
public void Property_SegmentKind_IsAction() { ActionPathSegment segment = new ActionPathSegment("SomeAction"); Assert.Equal(ODataSegmentKinds.Action, segment.SegmentKind); }
public void Ctor_TakingActionName_InitializesPropertyActionName() { ActionPathSegment actionPathSegment = new ActionPathSegment("SomeAction"); Assert.Equal("SomeAction", actionPathSegment.ActionName); }
public void TryMatch_ReturnsTrue_IfThePathSegmentRefersToSameAction() { // Arrange EdmEntityContainer container = new EdmEntityContainer("NS", "Container"); Mock<IEdmActionImport> edmAction = new Mock<IEdmActionImport>(); edmAction.Setup(a => a.Name).Returns("SomeAction"); edmAction.Setup(a => a.Container).Returns(container); ActionPathSegment pathSegmentTemplate = new ActionPathSegment(edmAction.Object); ActionPathSegment pathSegment = new ActionPathSegment(edmAction.Object); Dictionary<string, object> values = new Dictionary<string, object>(); // Act & Assert Assert.True(pathSegmentTemplate.TryMatch(pathSegment, values)); Assert.Empty(values); }
public void ToString_ReturnsActionName() { ActionPathSegment segment = new ActionPathSegment(actionName: "SomeAction"); Assert.Equal("SomeAction", segment.ToString()); }