示例#1
0
        public bool CreateResearcher([Service] IResearcherRepository repo, string name)
        {
            CreateResearcherCommand createCommand = new CreateResearcherCommand(repo, name);

            createCommand.Execute();

            return(true);
        }
        public void CreateResearcherCallsRepoTest()
        {
            Mock <IResearcherRepository> researcherRepository = new Mock <IResearcherRepository>();

            List <Researcher> researchers = new List <Researcher>();
            Researcher        researcher  = new Researcher(name);

            researcherRepository.Setup(p => p.CreateResearcher(name))
            .Callback(() => researchers.Add(researcher));

            CreateResearcherCommand createResearcherCommand = new CreateResearcherCommand(researcherRepository.Object, name);

            createResearcherCommand.Execute();
            Assert.AreEqual(researchers.Count, 1);
        }