Exemplo n.º 1
0
        public void AddRelationsWithAnswer()
        {
            // Arrange
            var relationsRequest = new List <NodeRelationRequest>()
            {
                new NodeRelationRequest()
                {
                    NodeId     = 1,
                    ChildrenId = 2,
                    AnswerId   = 3
                },
                new NodeRelationRequest()
                {
                    NodeId     = 1,
                    ChildrenId = 3,
                    AnswerId   = 2
                },
            };

            A.CallTo(() => _nodeService.GetNode(1)).Returns(new QuestionNode()
            {
                Children = { new TimerNode(), new QuestionNode(), new FirstNode() }
            });

            // Act
            _target.AddRelationsWithAnswers(relationsRequest);
            // Assert
            A.CallTo(() => _nodeService.GetNode(1)).MustHaveHappened();
            A.CallTo(() => _nodeService.RemoveAllChildren(A <Node> ._)).MustHaveHappened(Repeated.Exactly.Once);
            A.CallTo(() => _nodeService.AddChildren(A <int> ._, A <int> ._)).MustHaveHappened(Repeated.Exactly.Twice);
            A.CallTo(() => _nodeService.LinkAnswerToNode(A <int> ._, A <int> ._)).MustHaveHappened(Repeated.Exactly.Twice);
        }