/// <summary>
        /// Helper method that will new up an AX and matching TLB reference, and verify that the AX reference 
        /// sets its RCW appropriately. 
        /// </summary>
        private void CheckAxReferenceRCWTlbExists(RcwStyle rcwStyle, bool includeVersionInInteropName)
        {
            Guid axGuid = Guid.NewGuid();
            ComReferenceInfo tlbRefInfo;

            ResolveComReference rcr = new ResolveComReference();
            rcr.BuildEngine = new MockEngine();
            rcr.IncludeVersionInInteropName = includeVersionInInteropName;

            rcr.allProjectRefs = new List<ComReferenceInfo>();

            TaskItem axTaskItem = CreateComReferenceTaskItem("ref", axGuid.ToString(), "1", "2", "1033", ComReferenceTypes.aximp);
            ComReferenceInfo axRefInfo = CreateComReferenceInfo(axTaskItem, "RefLibName", "RefLibPath");
            rcr.allProjectRefs.Add(axRefInfo);

            switch (rcwStyle)
            {
                case RcwStyle.GenerateTlb: break;
                case RcwStyle.PreexistingTlb:
                    {
                        TaskItem tlbTaskItem = CreateComReferenceTaskItem("ref", axGuid.ToString(), "1", "2", "1033", ComReferenceTypes.tlbimp, "true");
                        tlbRefInfo = CreateComReferenceInfo(tlbTaskItem, "RefLibName", "RefLibPath");
                        rcr.allProjectRefs.Add(tlbRefInfo);
                        break;
                    }
                case RcwStyle.PreexistingPia:
                    {
                        TaskItem tlbTaskItem = CreateComReferenceTaskItem("ref", axGuid.ToString(), "1", "2", "1033", ComReferenceTypes.primary, "true");
                        tlbRefInfo = CreateComReferenceInfo(tlbTaskItem, "RefLibName", "RefLibPath");
                        rcr.allProjectRefs.Add(tlbRefInfo);
                        break;
                    }
            }

            rcr.AddMissingTlbReferences();

            Assert.AreEqual(2, rcr.allProjectRefs.Count, "Should be two references");

            tlbRefInfo = (ComReferenceInfo)rcr.allProjectRefs[1];
            var embedInteropTypes = tlbRefInfo.taskItem.GetMetadata(ItemMetadataNames.embedInteropTypes);
            Assert.AreEqual("false", embedInteropTypes, "The tlb wrapper for the activex control should have EmbedInteropTypes=false not " + embedInteropTypes);
            Assert.IsTrue(ComReference.AreTypeLibAttrEqual(tlbRefInfo.attr, axRefInfo.attr), "reference information should be the same");
            Assert.AreEqual
                (
                    TlbReference.GetWrapperFileName
                        (
                        axRefInfo.taskItem.GetMetadata(ComReferenceItemMetadataNames.tlbReferenceName),
                        includeVersionInInteropName,
                        axRefInfo.attr.wMajorVerNum,
                        axRefInfo.attr.wMinorVerNum
                        ),
                    TlbReference.GetWrapperFileName
                        (
                        tlbRefInfo.typeLibName,
                        includeVersionInInteropName,
                        tlbRefInfo.attr.wMajorVerNum,
                        tlbRefInfo.attr.wMinorVerNum
                        ),
                    "Expected Ax reference's RCW name to match the new TLB"
                );
        }
        public void CheckAddMissingTlbReference()
        {
            TYPELIBATTR axAttr, tlbAttr, piaAttr, notInProjectAttr;
            ComReferenceInfo axRefInfo, tlbRefInfo, piaRefInfo;

            CreateTestReferences(out axRefInfo, out tlbRefInfo, out piaRefInfo,
                out axAttr, out tlbAttr, out piaAttr, out notInProjectAttr);

            ResolveComReference rcr = new ResolveComReference();
            rcr.BuildEngine = new MockEngine();

            // populate the ResolveComReference's list of project references
            rcr.allProjectRefs = new List<ComReferenceInfo>();
            rcr.allProjectRefs.Add(axRefInfo);
            rcr.allProjectRefs.Add(tlbRefInfo);
            rcr.allProjectRefs.Add(piaRefInfo);

            rcr.AddMissingTlbReferences();

            Assert.IsTrue(rcr.allProjectRefs.Count == 4, "There should be four references now");

            ComReferenceInfo newTlbInfo = (ComReferenceInfo)rcr.allProjectRefs[3];
            Assert.IsTrue(axRefInfo.primaryOfAxImpRef == newTlbInfo, "axRefInfo should hold back reference to tlbRefInfo");
            Assert.IsTrue(ComReference.AreTypeLibAttrEqual(newTlbInfo.attr, axRefInfo.attr), "The added reference should have the same attributes as the Ax reference");
            Assert.IsTrue(newTlbInfo.typeLibName == axRefInfo.typeLibName, "The added reference should have the same type lib name as the Ax reference");
            Assert.IsTrue(newTlbInfo.strippedTypeLibPath == axRefInfo.strippedTypeLibPath, "The added reference should have the same type lib path as the Ax reference");

            Assert.IsTrue(newTlbInfo.taskItem.ItemSpec == axRefInfo.taskItem.ItemSpec, "The added reference should have the same task item spec as the Ax reference");
            Assert.IsTrue(newTlbInfo.taskItem.GetMetadata(ComReferenceItemMetadataNames.wrapperTool) == ComReferenceTypes.primaryortlbimp, "The added reference should have the tlbimp/primary wrapper tool");

            rcr.AddMissingTlbReferences();
            Assert.IsTrue(rcr.allProjectRefs.Count == 4, "There should still be four references");
        }