public void CreateRelations_CreateForEachExpertsFromAllNodesExceptSessionNotion() { var serviceUnderTest = CreateServiceUnderTest(); var session = CreateSession(); session.BaseNotion.Returns("notionOfSession"); var notionOfSessionNode = Substitute.For <Node>(); notionOfSessionNode.Notion.Returns("notionOfSession"); var nodes = new List <Node> { notionOfSessionNode, Substitute.For <Node>(), Substitute.For <Node>() }; var experts = new List <Expert> { Substitute.For <Expert>(), Substitute.For <Expert>() }; FakeExpertRepository.GetExpertsBySession( Arg.Is <GetExpertsBySessionSpecification>(s => s.SessionOfExperts == session)).Returns(experts); serviceUnderTest.CreateRelations(session, nodes); foreach (var expert in experts) { expert.Received(1).GenerateRelations( Arg.Is <IReadOnlyCollection <Node> >(nd => nd.Contains(nodes[1]) && nd.Contains(nodes[2]))); } }
public void CreateRelations_AllExpertsShouldBeSaved() { var serviceUnderTest = CreateServiceUnderTest(); var session = CreateSession(); var experts = new List <Expert> { Substitute.For <Expert>(), Substitute.For <Expert>() }; FakeExpertRepository.GetExpertsBySession( Arg.Is <GetExpertsBySessionSpecification>(x => x.SessionOfExperts == session)) .Returns(experts); var nodes = new List <Node> { Substitute.For <Node>(), Substitute.For <Node>() }; serviceUnderTest.CreateRelations(session, nodes); foreach (var expert in experts) { FakeExpertRepository.Received(1).AddOrUpdate(Arg.Is(expert)); } }