public void CreateSemanticNetworkFromNodeCandidates_CreateNodeForRootAndForNodeCandidates() { #region arrange var serviceUnderTests = CreateServiceUnderTest(); FakeNodeRepository.GetByNotionAndType(Arg.Any <string>(), Arg.Any <NotionType>()).Returns((Node)null); var generalType = ReturnsGeneralNotionTypeFromRepository(); var notionTypeId = GeneratedGuids.First; var notionType = Substitute.For <NotionType>(); FakeNotionTypeRepository.GetById(Arg.Is(notionTypeId)).Returns(notionType); var nodeCandidate = new NodeCandidate { IsSaveAsNode = true, Notion = "notion", TypeId = notionTypeId }; var session = CreateFakeSession("baseNotion"); #endregion serviceUnderTests.CreateSemanticNetworkFromNodeCandidates(nodeCandidate.Enumerate(), session); FakeNodeRepository.Received(1) .AddOrUpdate(Arg.Is <Node>(x => x.Notion == "baseNotion" && x.Type == generalType)); FakeNodeRepository.Received(1).AddOrUpdate(Arg.Is <Node>(x => x.Notion == "notion" && x.Type == notionType)); }
public void CreateSemanticNetworkFromNodeCandidates_IfNodeExistsInRepo_UpdateIt() { #region arrange var serviceUnderTests = CreateServiceUnderTest(); var generalType = ReturnsGeneralNotionTypeFromRepository(); var notionTypeId = GeneratedGuids.First; var notionType = Substitute.For <NotionType>(); FakeNotionTypeRepository.GetById(Arg.Is(notionTypeId)).Returns(notionType); var root = Substitute.For <Node>(); FakeNodeRepository.GetByNotionAndType(Arg.Is("baseNotion"), Arg.Is(generalType)).Returns(root); var node = Substitute.For <Node>(); FakeNodeRepository.GetByNotionAndType(Arg.Is("notion"), Arg.Is(notionType)).Returns(node); var nodeCandidate = new NodeCandidate { IsSaveAsNode = true, Notion = "notion", TypeId = GeneratedGuids.First }; var session = CreateFakeSession("baseNotion"); #endregion serviceUnderTests.CreateSemanticNetworkFromNodeCandidates(nodeCandidate.Enumerate(), session); FakeNodeRepository.Received(1).AddOrUpdate(Arg.Is(root)); FakeNodeRepository.Received(1).AddOrUpdate(Arg.Is(node)); }
public void CreateSemanticNetworkFromNodeCandidates_LinkNodeAndSession() { #region arrange var serviceUnderTests = CreateServiceUnderTest(); var node = Substitute.For <Node>(); FakeNodeRepository.GetByNotionAndType(Arg.Is("baseNotion"), Arg.Any <NotionType>()) .Returns(node); var session = CreateFakeSession("baseNotion"); var nodeCandidates = new NodeCandidate[0]; #endregion serviceUnderTests.CreateSemanticNetworkFromNodeCandidates(nodeCandidates, session); node.Received(1).AddSessionOfExperts(session); }