Exemplo n.º 1
0
        public void UpdateNode_NonExistingId_Throws()
        {
            var modelService = CreateModelService();

            var    node1 = new TestModelNode("Node1");
            Action a     = () => modelService.UpdateNode(node1);

            a.Should().Throw <InvalidOperationException>().Where(i => i.Message.Contains("not found"));
        }
Exemplo n.º 2
0
        public void AddNode_Works()
        {
            var modelService = CreateModelService();

            var node1 = new TestModelNode("Node1");

            modelService.AddNode(node1);

            modelService.Model.Nodes.Should().BeEquivalentTo(node1);
        }
Exemplo n.º 3
0
        public void AddNode_PublishesEvent()
        {
            var modelService = CreateModelService();

            using (var monitoredSubject = modelService.Monitor())
            {
                var node1 = new TestModelNode("Node1");
                modelService.AddNode(node1);

                monitoredSubject.Should().Raise(nameof(IModelService.ModelChanged))
                .WithArgs <ModelNodeAddedEvent>(args => args.NewModel == modelService.Model && args.AddedNode == node1);
            }
        }
Exemplo n.º 4
0
        public void AddNodeWithParent_Works()
        {
            var modelService = CreateModelService();

            var parent = new TestModelNode("Parent");

            modelService.AddNode(parent);
            var child = new TestModelNode("Child");

            modelService.AddNode(child, parent.Id);

            modelService.Model.Nodes.Should().BeEquivalentTo(parent, child);
            modelService.Model.GetRelatedNodes(child.Id, CommonDirectedModelRelationshipTypes.Container).Should().BeEquivalentTo(parent);
            modelService.Model.GetRelatedNodes(parent.Id, CommonDirectedModelRelationshipTypes.Contained).Should().BeEquivalentTo(child);
        }