Beispiel #1
0
        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])));
            }
        }
Beispiel #2
0
        public void Associations_ExpertShouldBeSaved()
        {
            var serviceUnderTest = CreateServiceUnderTest();
            var session          = CreateSession();
            var expert           = FromExpertRepositoryReturnFakeExpert("expertName", session);

            serviceUnderTest.Associations(new List <string>(), "expertName", session);

            FakeExpertRepository.Received(1).AddOrUpdate(Arg.Is(expert));
        }
Beispiel #3
0
        public void RelationTypes_ExpertShouldBeSaved()
        {
            var serviceUnderTest = CreateServiceUnderTest();
            var session          = CreateSession();
            var expert           = FromExpertRepositoryReturnFakeExpert("expertName", session);

            serviceUnderTest.RelationTypes(new RelationTupleDto(), "expertName", session);

            FakeExpertRepository.Received(1).AddOrUpdate(Arg.Is(expert));
        }
Beispiel #4
0
        private Expert FromExpertRepositoryReturnFakeExpert(string expertName, SessionOfExperts session)
        {
            var expert = Substitute.For <Expert>();

            FakeExpertRepository.GetExpertByNameAndSession(
                Arg.Is <GetExpertByNameAndSessionSpecification>(
                    x => x.ExpertName == expertName && x.SessionOfExperts == session))
            .Returns(expert);

            return(expert);
        }
Beispiel #5
0
        public void JoinSession_ExpertRepositorySave()
        {
            var serviceUnderTest = CreateServiceUnderTest();
            var session          = Substitute.For <SessionOfExperts>();

            serviceUnderTest.JoinSession("testExpert", session);

            FakeExpertRepository.Received(1).AddOrUpdate(
                Arg.Is <Expert>(
                    e => e.Name == "testExpert" && e.SessionOfExperts == session));
        }
Beispiel #6
0
        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));
            }
        }
Beispiel #7
0
 private void FromExpertRepositoryReturnNullExpert()
 {
     FakeExpertRepository.GetExpertByNameAndSession(
         Arg.Any <GetExpertByNameAndSessionSpecification>())
     .Returns((Expert)null);
 }