locked
Mole Enumerator RRS feed

  • Question

  • Hi,

    I am trying to create a Test Method for following sharepoint code

    SPWebTemplateCollection templates = web.GetAvailableWebTemplates((uint)1033);<br/>
              Collection<SPWebTemplate> collection = new Collection<SPWebTemplate>();<br/>
              foreach (SPWebTemplate template in templates)<br/>
              {<br/>
                for (int i = 0; i < webTemplates.Length; i++)<br/>
                {<br/>
                  if (template.Name.Equals(webTemplates[i].ToString()))<br/>
                  {<br/>
                    collection.Add(template);<br/>
                  }<br/>
                }<br/>
              }
    

    But I am getting the following MoleNotImplemented Exception for the following testmethod.

    SPWeb web = new MSPWeb()<br/>
          {<br/>
            GetAvailableWebTemplatesUInt32 = temp => new MSPWebTemplateCollection()<br/>
            {<br/>
              <br/>
            }<br/>
    <br/>
          };
    
    Can you please suggest me how to mole an enumerator class.

    Monday, December 20, 2010 8:07 AM

All replies

  • You can create a List<SPWebTemplate> and use the 'Bind' method defined on the MSPWebTemplateCollection to replace the IEnumerable implementation of SPWebTemplateCollection with the one from List<SPWebTemplate>.

    Jonathan "Peli" de Halleux - Try Pex online at www.pexforfun.com!
    Monday, January 10, 2011 11:21 PM