public void AddingNodeTriggersAddedSignal() { var eventFired = false; var mockNode = new MockNode(); _nodes.NodeAdded += delegate { eventFired = true; }; _nodes.Add(mockNode); Assert.IsTrue(eventFired); }
public void SetUp() { var mockedParent = new MockNode().AddNodeTypeAlias("Site").AddUrlName("SiteName").Mock(10); MockedNode = new MockNode().AddNodeTypeAlias("test").AddParent(mockedParent).Mock(90); NodeFactoryFacade.GetNode(MockedNode.Id).Returns(MockedNode); MockedContentService.AddNode(MockedNode); DataService.ContentService.Returns(MockedContentService); }
public void AndCategories_SetUp() { MockedNode = new MockNode(MockedNode) .AddProperty("categories", "1063,1064") .Mock(90); NodeFactoryFacade.GetNode(MockedNode.Id).Returns(MockedNode); MockedContentService.AddNode(MockedNode); DataService.ContentService.Returns(MockedContentService); }
public void NodesInitiallySortedInOrderOfAddition() { var node1 = new MockNode(); var node2 = new MockNode(); var node3 = new MockNode(); _nodes.Add(node1); _nodes.Add(node2); _nodes.Add(node3); var expected = new List<Node> { node1, node2, node3 }; var actual = new List<Node> { _nodes.Head, _nodes.Head.Next, _nodes.Tail }; Assert.AreEqual(expected, actual); }
public void AllNodesAreCoveredDuringIteration() { var nodeArray = new List<Node>(); for (var i = 0; i < 5; ++i) { var node = new MockNode(); nodeArray.Add(node); _nodes.Add(node); } for (var node = _nodes.Head; node != null; node = node.Next) { var index = nodeArray.IndexOf(node); nodeArray.RemoveAt(index); } Assert.AreEqual(0, nodeArray.Count); }
public void TestEngineConfigurationQuery() { var node = new MockNode(100002); SetupTest.RegisteredNodes.TryAdd(100002, node); var task = Core.QueryEngineConfigurationAsync(100002, "localsym", "h323chan.yate"); var message = node.RetrieveMessage(); Assert.AreEqual <string>(message.OutgoingMessage, "%%>setlocal:config.localsym.h323chan.yate:\n"); message.SetIncoming(node, "%%<setlocal:config.localsym.h323chan.yate:yes:true"); Dispatcher.Process(message).Wait(); task.Wait(); var result = task.Result; Assert.IsTrue(result.Success); Assert.AreEqual <string>(result.Result, "yes"); }
public void SwappingAdjacentNodesChangesTheirPositions() { var node1 = new MockNode(); var node2 = new MockNode(); var node3 = new MockNode(); var node4 = new MockNode(); _nodes.Add(node1); _nodes.Add(node2); _nodes.Add(node3); _nodes.Add(node4); _nodes.Swap(node2, node3); var expected = new List <Node> { node1, node3, node2, node4 }; var actual = new List <Node> { _nodes.Head, _nodes.Head.Next, _nodes.Tail.Previous, _nodes.Tail }; Assert.AreEqual(expected, actual); }
public void NodePathModel_AddingNodeRange_SumIsCorrect() { INode nodeOne = new MockNode { Value = 7 }; INode nodeTwo = new MockNode { Value = 4 }; var nodeRange = new List <INode> { nodeOne, nodeTwo }; var expectedTotal = nodeOne.Value + nodeTwo.Value; INodePath nodePath = new NodePath(); nodePath.AddNodeRange(nodeRange); Assert.AreEqual(expectedTotal, nodePath.Sum); Assert.AreEqual(2, nodePath.PathNodes.Count); }
public void SetUp() { var mockedParentOne = new MockNode().AddNodeTypeAlias("Site").AddUrlName("SiteNameOne").Mock(10); var mockedParentTwo = new MockNode().AddNodeTypeAlias("Site").AddUrlName("SiteNameTwo").Mock(11); var mockedNodeOne = new MockNode() .AddNodeTypeAlias("test") .AddParent(mockedParentOne) .Mock(90); var mockedNodeTwo = new MockNode() .AddNodeTypeAlias("test") .AddParent(mockedParentTwo) .Mock(91); NodeFactoryFacade.GetNode(mockedNodeOne.Id).Returns(mockedNodeOne); NodeFactoryFacade.GetNode(mockedNodeTwo.Id).Returns(mockedNodeTwo); MockedContentService.AddNode(mockedNodeOne); MockedContentService.AddNode(mockedNodeTwo); DataService.ContentService.Returns(MockedContentService); }
public void TestEngineTimer() { var node = new MockNode(1); var incomingMessage = new MockMessage(); incomingMessage.SetIncoming(node, string.Join(":", "%%>message", "051EFE60.1969150591", UnixTimestamp.ToString(), "engine.timer", "", "time=1468577974", "nodename=WIN-E2OH1TVPT5C" )); Dispatcher.Process(incomingMessage).Wait(); var result = node.RetrieveMessage(); // Assert - split because MS are measured for 'clwaitingtime,clprocessingtime' and change between runs Assert.AreEqual <string>(result.OutgoingMessage, "%%<message:051EFE60.1969150591:false:engine.timer::time=1468577974\n"); }
public void RemovingCurrentNodeDuringIterationIsValid() { var nodeArray = new List<Node>(); for (var i = 0; i < 5; ++i) { var node = new MockNode(); nodeArray.Add(node); _nodes.Add(node); } var count = 0; for (var node = _nodes.Head; node != null; node = node.Next) { var index = nodeArray.IndexOf(node); nodeArray.RemoveAt(index); if (++count == 2) { _nodes.Remove(node); } } Assert.AreEqual(0, nodeArray.Count); }
public void TestEngineParameterQuery() { var node = new MockNode(100001); SetupTest.RegisteredNodes.TryAdd(100001, node); var task = Core.QueryParameterAsync(100001, EngineParameter.NodeName); var message = node.RetrieveMessage(); Assert.AreEqual <string>(message.OutgoingMessage, "%%>setlocal:engine.nodename:\n"); message.SetIncoming(node, "%%<setlocal:engine.nodename:ubuntuyate:true"); Dispatcher.Process(message).Wait(); task.Wait(); var result = task.Result; Assert.IsTrue(result.Success); Assert.AreEqual <EngineParameter>((EngineParameter)result.Parameter, EngineParameter.NodeName); Assert.AreEqual <string>(result.Result, "ubuntuyate"); }
public void RemovingNextNodeDuringIterationIsValid() { var nodeArray = new List <Node>(); for (var i = 0; i < 5; ++i) { var node = new MockNode(); nodeArray.Add(node); _nodes.Add(node); } var count = 0; for (var node = _nodes.Head; node != null; node = node.Next) { var index = nodeArray.IndexOf(node); nodeArray.RemoveAt(index); if (++count == 2) { _nodes.Remove(node.Next); } } Assert.AreEqual(1, nodeArray.Count); }
private static bool SearchBlocked(MockNode node) => node.Key > 9 || node.Key < 0;
private IGeneralTree <object> BuildTreeForTest() { // 1 // /\ \ // 2 3 4 // /\ /\ \ // 5 6 7 8 9 // / \ // 10 11 var rootNode = new MockNode { Id = 1 }; var nodeFour = new MockNode { Id = 4, Parent = rootNode }; var nodeThree = new MockNode { Id = 3, Parent = rootNode }; var nodeTwo = new MockNode { Id = 2, Parent = rootNode }; var nodeSix = new MockNode { Id = 6, Parent = nodeTwo }; var nodeTen = new MockNode { Id = 10, Parent = nodeSix }; var nodeNine = new MockNode { Id = 9, Parent = nodeFour }; var nodeEight = new MockNode { Id = 8, Parent = nodeThree }; var nodeSeven = new MockNode { Id = 7, Parent = nodeThree }; var nodeFive = new MockNode { Id = 5, Parent = nodeTwo }; var nodeEleven = new MockNode { Id = 11, Parent = nodeNine }; nodeFive.Children.Add(nodeTen); nodeTwo.Children.Add(nodeFive); nodeTwo.Children.Add(nodeSix); nodeThree.Children.Add(nodeSeven); nodeThree.Children.Add(nodeEight); nodeFour.Children.Add(nodeNine); nodeNine.Children.Add(nodeEleven); rootNode.Children.Add(nodeTwo); rootNode.Children.Add(nodeThree); rootNode.Children.Add(nodeFour); return(new GeneralTree <object> { RootNode = rootNode }); }
public void TestBlendingRoute2() { var node = new MockNode(700000); var incomingMessage = new MockMessage(); incomingMessage.SetIncoming(node, string.Join(":", "%%>message", "234479208", UnixTimestamp.ToString(), "call.route", "id=sip/852978", "module=sip", "error=", "reason=", "status=incoming", "address=71.0.0.1%z5060", "billid=1418778188-53", "answered=false", "direction=incoming", "caller=00012521339915", "called=1111101", "callername=00012521339915", "sip_Tracking-ID=", "sip_Gateway-ID=" )); Dispatcher.Process(incomingMessage).Wait(); var result = node.RetrieveMessage(); var routingTree = getRoutingTree(node, "1418778188-53", true); // Assert - split because MS are measured for 'clwaitingtime,clprocessingtime' and change between runs Assert.IsTrue(result.OutgoingMessage.StartsWith("%%<message:234479208:true:call.route::error=:" + "reason=:location=fork:fork.calltype=:fork.autoring=:fork.automessage=:fork.ringer=:clnodeid=700000:" + "clcustomerid=700000:clcustomeripid=700000:cltrackingid=1418778188-53:clprocessingtime=")); Assert.IsTrue(result.OutgoingMessage.Contains(":clcustomerpriceid=700000:clcustomerpricepermin=30:clcustomercurrency=USD:cldialcodemasterid=3:clwaitingtime=")); Assert.IsTrue(result.OutgoingMessage.EndsWith(CopyParams + ":callto.1=sip/sip%[email protected]%z5057:callto.1.called=1111101:callto.1.caller=00012521339915:callto.1.callername=00012521339915:callto.1.format=g729:" + "callto.1.formats=g729,alaw,mulaw:callto.1.line=:callto.1.maxcall=65000:callto.1.osip_P-Asserted-Identity=:callto.1.osip_Gateway-ID=:callto.1.osip_Tracking-ID=:" + "callto.1.rtp_addr=90.0.0.103:callto.1.rtp_forward=true:callto.1.rtp_port=6057:callto.1.oconnection_id=general:callto.1.clgatewayid=700007:callto.1.clgatewayaccountid=:" + "callto.1.clgatewayipid=700007:callto.1.cltechcalled=sip/sip%[email protected]%z5057:" + "callto.1.clgatewaypriceid=700007:callto.1.clgatewaypricepermin=0,006:callto.1.clgatewaycurrency=USD:callto.1.cldecision=8:callto.1.timeout=1085:" + "callto.2=|next=10000:" + "callto.3=sip/sip%[email protected]%z5057:callto.3.called=1111101:callto.3.caller=00012521339915:callto.3.callername=00012521339915:callto.3.format=g729:" + "callto.3.formats=g729,alaw,mulaw:callto.3.line=:callto.3.maxcall=65000:callto.3.osip_P-Asserted-Identity=:callto.3.osip_Gateway-ID=:callto.3.osip_Tracking-ID=:" + "callto.3.rtp_addr=90.0.0.101:callto.3.rtp_forward=true:callto.3.rtp_port=6057:callto.3.oconnection_id=general:callto.3.clgatewayid=700002:callto.3.clgatewayaccountid=:" + "callto.3.clgatewayipid=700002:callto.3.cltechcalled=sip/sip%[email protected]%z5057:" + "callto.3.clgatewaypriceid=700002:callto.3.clgatewaypricepermin=0,006:callto.3.clgatewaycurrency=USD:callto.3.cldecision=4:callto.3.timeout=1085:" + "callto.4=|next=10000:" + "callto.5=sip/sip%[email protected]%z5057:callto.5.called=1111101:callto.5.caller=00012521339915:callto.5.callername=00012521339915:callto.5.format=g729:" + "callto.5.formats=g729,alaw,mulaw:callto.5.line=:callto.5.maxcall=65000:callto.5.osip_P-Asserted-Identity=:callto.5.osip_Gateway-ID=:callto.5.osip_Tracking-ID=:" + "callto.5.rtp_addr=90.0.0.104:callto.5.rtp_forward=true:callto.5.rtp_port=6057:callto.5.oconnection_id=general:callto.5.clgatewayid=700003:callto.5.clgatewayaccountid=:" + "callto.5.clgatewayipid=700003:callto.5.cltechcalled=sip/sip%[email protected]%z5057:" + "callto.5.clgatewaypriceid=700003:callto.5.clgatewaypricepermin=0,006:callto.5.clgatewaycurrency=USD:callto.5.cldecision=4:callto.5.timeout=1085:" + "callto.6=|next=10000:" + "callto.7=sip/sip%[email protected]%z5057:callto.7.called=1111101:callto.7.caller=00012521339915:callto.7.callername=00012521339915:callto.7.format=g729:" + "callto.7.formats=g729,alaw,mulaw:callto.7.line=:callto.7.maxcall=65000:callto.7.osip_P-Asserted-Identity=:callto.7.osip_Gateway-ID=:callto.7.osip_Tracking-ID=:" + "callto.7.rtp_addr=90.0.0.102:callto.7.rtp_forward=true:callto.7.rtp_port=6057:callto.7.oconnection_id=general:callto.7.clgatewayid=700008:callto.7.clgatewayaccountid=:" + "callto.7.clgatewayipid=700008:callto.7.cltechcalled=sip/sip%[email protected]%z5057:" + "callto.7.clgatewaypriceid=700008:callto.7.clgatewaypricepermin=0,006:callto.7.clgatewaycurrency=USD:callto.7.cldecision=4:callto.7.timeout=1085\n")); Assert.IsNotNull(routingTree); Assert.AreEqual(routingTree.Context.Endpoint, Utilities.RoutingTree.TargetType.Context); Assert.AreEqual(routingTree.Context.Id, 700000); Assert.IsNull(routingTree.Context.InternalRoutedGateway); Assert.IsNull(routingTree.Context.BlendingContext); Assert.IsNotNull(routingTree.Context.Route); Assert.AreEqual(routingTree.Context.Route.Id, 700001); Assert.AreEqual(routingTree.Context.Route.IsFallbackToLCR, false); Assert.AreEqual(routingTree.Context.Route.BlendingContext.Count, 0); Assert.AreEqual(routingTree.Context.Route.Targets.Count, 3); Assert.AreEqual(routingTree.Context.Route.Targets[0].Endpoint, Utilities.RoutingTree.TargetType.Gateway); Assert.AreEqual(routingTree.Context.Route.Targets[0].Id, 700002); Assert.AreEqual(routingTree.Context.Route.Targets[0].TargetReason, Utilities.RoutingTree.Reason.OK); Assert.AreEqual(routingTree.Context.Route.Targets[1].Endpoint, Utilities.RoutingTree.TargetType.Gateway); Assert.AreEqual(routingTree.Context.Route.Targets[1].Id, 700003); Assert.AreEqual(routingTree.Context.Route.Targets[1].TargetReason, Utilities.RoutingTree.Reason.OK); Assert.AreEqual(routingTree.Context.Route.Targets[2].Endpoint, Utilities.RoutingTree.TargetType.Context); Assert.AreEqual(routingTree.Context.Route.Targets[2].Id, 700004); Assert.AreEqual(routingTree.Context.Route.Targets[2].TargetReason, Utilities.RoutingTree.Reason.OK); Assert.AreEqual((routingTree.Context.Route.Targets[2] as Utilities.RoutingTree.Context).TargetReason, Utilities.RoutingTree.Reason.OK); Assert.IsNull((routingTree.Context.Route.Targets[2] as Utilities.RoutingTree.Context).BlendingContext); Assert.IsNull((routingTree.Context.Route.Targets[2] as Utilities.RoutingTree.Context).InternalRoutedGateway); Assert.AreEqual((routingTree.Context.Route.Targets[2] as Utilities.RoutingTree.Context).LCRGateways.Count, 0); Assert.IsNotNull((routingTree.Context.Route.Targets[2] as Utilities.RoutingTree.Context).Route); Assert.AreEqual((routingTree.Context.Route.Targets[2] as Utilities.RoutingTree.Context).Route.Id, 700005); Assert.AreEqual((routingTree.Context.Route.Targets[2] as Utilities.RoutingTree.Context).Route.BlendingContext.Count, 1); Assert.IsNull((routingTree.Context.Route.Targets[2] as Utilities.RoutingTree.Context).Route.BlendingContext[0].BlendingContext); Assert.AreEqual((routingTree.Context.Route.Targets[2] as Utilities.RoutingTree.Context).Route.BlendingContext[0].Endpoint, Utilities.RoutingTree.TargetType.Context); Assert.AreEqual((routingTree.Context.Route.Targets[2] as Utilities.RoutingTree.Context).Route.BlendingContext[0].Id, 700006); Assert.IsNull((routingTree.Context.Route.Targets[2] as Utilities.RoutingTree.Context).Route.BlendingContext[0].InternalRoutedGateway); Assert.AreEqual((routingTree.Context.Route.Targets[2] as Utilities.RoutingTree.Context).Route.BlendingContext[0].LCRGateways.Count, 1); Assert.AreEqual((routingTree.Context.Route.Targets[2] as Utilities.RoutingTree.Context).Route.BlendingContext[0].LCRGateways[0].Endpoint, Utilities.RoutingTree.TargetType.Gateway); Assert.AreEqual((routingTree.Context.Route.Targets[2] as Utilities.RoutingTree.Context).Route.BlendingContext[0].LCRGateways[0].Id, 700007); Assert.AreEqual((routingTree.Context.Route.Targets[2] as Utilities.RoutingTree.Context).Route.BlendingContext[0].LCRGateways[0].TargetReason, Utilities.RoutingTree.Reason.Blending); Assert.AreEqual((routingTree.Context.Route.Targets[2] as Utilities.RoutingTree.Context).Route.IsFallbackToLCR, false); Assert.AreEqual((routingTree.Context.Route.Targets[2] as Utilities.RoutingTree.Context).Route.Targets.Count, 1); Assert.AreEqual((routingTree.Context.Route.Targets[2] as Utilities.RoutingTree.Context).Route.Targets[0].Endpoint, Utilities.RoutingTree.TargetType.Gateway); Assert.AreEqual((routingTree.Context.Route.Targets[2] as Utilities.RoutingTree.Context).Route.Targets[0].Id, 700008); Assert.AreEqual((routingTree.Context.Route.Targets[2] as Utilities.RoutingTree.Context).Route.Targets[0].TargetReason, Utilities.RoutingTree.Reason.OK); Assert.AreEqual((routingTree.Context.Route.Targets[2] as Utilities.RoutingTree.Context).RoutingAction, Utilities.RoutingTree.ContextAction.Fixed); Assert.AreEqual((routingTree.Context.Route.Targets[2] as Utilities.RoutingTree.Context).TargetReason, Utilities.RoutingTree.Reason.OK); Assert.AreEqual(routingTree.GatewayOrder.Count, 4); Assert.AreEqual(routingTree.GatewayOrder[0], 700007); Assert.AreEqual(routingTree.GatewayOrder[1], 700002); Assert.AreEqual(routingTree.GatewayOrder[2], 700003); Assert.AreEqual(routingTree.GatewayOrder[3], 700008); }
internal virtual Node CreateNode() { Node target = new MockNode(); return(target); }
private void BuildTreeForTest() { // 1 // /\ \ // 2 3 4 // /\ /\ \ // 5 6 7 8 9 // / // 10 var rootNode = new MockNode { Id = 1 }; var nodeFour = new MockNode { Id = 4, Parent = rootNode }; var nodeThree = new MockNode { Id = 3, Parent = rootNode }; var nodeTwo = new MockNode { Id = 2, Parent = rootNode }; var nodeSix = new MockNode { Id = 6, Parent = nodeTwo }; var nodeTen = new MockNode { Id = 10, Parent = nodeSix }; var nodeNine = new MockNode { Id = 9, Parent = nodeFour }; var nodeEight = new MockNode { Id = 8, Parent = nodeThree }; var nodeSeven = new MockNode { Id = 7, Parent = nodeThree }; var nodeFive = new MockNode { Id = 5, Parent = nodeTwo }; nodeFive.Children.Add(nodeTen); nodeTwo.Children.Add(nodeFive); nodeTwo.Children.Add(nodeSix); nodeThree.Children.Add(nodeSeven); nodeThree.Children.Add(nodeEight); nodeFour.Children.Add(nodeNine); rootNode.Children.Add(nodeTwo); rootNode.Children.Add(nodeThree); rootNode.Children.Add(nodeFour); _tree.RootNode = rootNode; }
public void SwappingOnlyTwoNodesChangesTheirOrder() { var node1 = new MockNode(); var node2 = new MockNode(); _nodes.Add(node1); _nodes.Add(node2); _nodes.Swap(node1, node2); var expected = new List<Node> { node2, node1 }; var actual = new List<Node> { _nodes.Head, _nodes.Tail }; Assert.AreEqual(expected, actual); }
public void SwappingNonAdjacentNodesChangesTheirPositions() { var node1 = new MockNode(); var node2 = new MockNode(); var node3 = new MockNode(); var node4 = new MockNode(); var node5 = new MockNode(); _nodes.Add(node1); _nodes.Add(node2); _nodes.Add(node3); _nodes.Add(node4); _nodes.Add(node5); _nodes.Swap(node2, node4); var expected = new List<Node> { node1, node4, node3, node2, node5 }; var actual = new List<Node> { _nodes.Head, _nodes.Head.Next, _nodes.Head.Next.Next, _nodes.Tail.Previous, _nodes.Tail }; Assert.AreEqual(expected, actual); }
public void SwappingEndNodesChangesTheirPositions() { var node1 = new MockNode(); var node2 = new MockNode(); var node3 = new MockNode(); _nodes.Add(node1); _nodes.Add(node2); _nodes.Add(node3); _nodes.Swap(node1, node3); var expected = new List<Node> { node3, node2, node1 }; var actual = new List<Node> { _nodes.Head, _nodes.Head.Next, _nodes.Tail }; Assert.AreEqual(expected, actual); }