public void QueryRunnerShouldCallToReplaceMacrosBeforeRunningQueries()
        {
            //Maybe is a smeel you can really assert that the code is using the right version of the query?
            var tfsContextMock = A.Fake<ITfsContext>(o => o.Wrapping(tfsContext));
            var macroParserMock = A.Fake<IQueryMacroParser>();

            var resultQuery = new ShimQueryDefinition();

            resultQuery.QueryTextGet = () => "SELECT System.ID, System.Title from workitems WHERE Project = \"TestProject\"";

            A.CallTo(() => macroParserMock.Replace(A<QueryDefinition>.Ignored))
             .Returns(resultQuery);

            var query = "SELECT System.ID, System.Title from workitems WHERE Project = @Project";
            var queryRunner = new QueryRunner(tfsContextMock, macroParserMock);

            var queryWithMacros = new ShimQueryDefinition();

            queryWithMacros.QueryTextGet = () => query;

            IEnumerable<WorkItem> workItems = queryRunner.RunQuery(queryDefinition);

            A.CallTo(() => macroParserMock.Replace(A<QueryDefinition>.Ignored)).MustHaveHappened();
            A.CallTo(() => tfsContextMock.CurrentWorkItemStore).MustHaveHappened();

            Assert.IsTrue(workItems.Where(w => w.Title == "Linked Work Item").Any());
        }
        public void Initialize()
        {
            shimContext = ShimsContext.Create();
            queryFinder = A.Fake<IQueryFinder>();
            queryDefinition = new ShimQueryDefinition();
            queryRunner = A.Fake<IQueryRunner>();

            queryDefinition.QueryTextGet = () => "SELECT System.ID, System.Title from workitems";

            A.CallTo(() => queryFinder.FindQuery(project, queryPath, queryName))
                .Returns(queryDefinition);
        }
        public void Initialize()
        {
            queryMacroParser = A.Fake<IQueryMacroParser>();

            SetupQueryMacroParserFake();

            shimContext = ShimsContext.Create();

            tfsContext = new FakeTfsContext(shimContext);
            queryDefinition = new ShimQueryDefinition();
            queryDefinition.QueryTextGet = () => "SELECT System.ID, System.Title from workitems";

            SetupQueryShim(tfsContext);
        }
        public void Initialize()
        {
            shimContext = ShimsContext.Create();

            var project = new ShimProject();

            project.NameGet = () => "TestProject";

            ShimQueryItem.AllInstances.ProjectGet = (q) => project;
            var definition = new ShimQueryDefinition();

            projectMacroMock = A.Fake<IMacro>();

            A.CallTo(() => projectMacroMock.Name).Returns("Project");
            A.CallTo(() => projectMacroMock.GetValue(A<QueryDefinition>.Ignored)).Returns("\"TestProject\"");

            userMacroMock = A.Fake<IMacro>();

            A.CallTo(() => userMacroMock.Name).Returns("Me");
            A.CallTo(() => userMacroMock.GetValue(A<QueryDefinition>.Ignored)).Returns("\"Iñaki Elcoro\"");

            parserWithMacros = new MacroParser(new IMacro[] { projectMacroMock, userMacroMock });
        }
        private List<QueryDefinition> CreateQueryDefinitionList(ShimQueryFolder parent,  ShimQueryDefinition queryDefinitionFake)
        {
            var queryDefinitionBaseFake = new ShimQueryItem(queryDefinitionFake);

            queryDefinitionBaseFake.NameGet = () => "TestQuery";
            queryDefinitionBaseFake.ProjectGet = () => projectFake;
            queryDefinitionBaseFake.ParentGet = () => parent;
            queryDefinitionBaseFake.PathGet = () => "TestProject/TestFolder";

            var queryList = new List<QueryDefinition>() { queryDefinitionFake };
            return queryList;
        }
        private void CreateQueryHierarchyFake()
        {
            hierarchyFake = new ShimQueryHierarchy();

            var queryFolderFake = new ShimQueryFolder();
            var queryDefinitionFake = new ShimQueryDefinition();

            queryDefinitionFake.QueryTextGet = () => "SELECT System.ID, System.Title from workitems";

            var queryList = CreateQueryDefinitionList(queryFolderFake, queryDefinitionFake);

            queryFolderFake = SetupQueryFolderFake(queryFolderFake, queryList);

            hierarchyFake.Bind(new List<QueryFolder>() { queryFolderFake });
            projectFake.QueryHierarchyGet = () => hierarchyFake;
        }