示例#1
0
 public void GetsGenericTypeFromCurrentAssembly()
 {
     var dynamicType = new []{TestMetaData.CreateGenericType()};
     var dynamicAssembly = CodeGenerator.Create(dynamicType, TestUtils.NewName());
     var typeToFind = dynamicAssembly.Types[dynamicType.Single(t => t.IsBusinessEntity)];
     var found = TypeLoader.Create(new string[0])(TypeNameParser.ParseString(ReflectPlatform.FullyQualifiedName(typeToFind)));
     Assert.AreEqual(typeToFind, found.Value);
 }
 public static string GetHomeRealm(string socialIpId)
 {
     var providers = new[] { Google, Yahoo, WindowsLiveId };
     return providers.Single(p => p.Id == socialIpId).HomeRealm;
 }
      public void Should_ReturnParsedAuthors()
      {
         // Arrange

         var data = new[]
         {
            new
            {
               Node = Mock.Of<INode>(),
               Authors = new List<PluralsightAuthor>
               {
                  new PluralsightAuthor
                  {
                     FullName = "Eric Burke",
                     SiteUrl = "http://www.pluralsight.com/author/eric-burke",
                     UrlName = "eric-burke"
                  }
               },
               IsCoAuthors = false
            },
            new
            {
               Node = Mock.Of<INode>(),
               Authors = new List<PluralsightAuthor>
               {
                  new PluralsightAuthor
                  {
                     FullName = "Eric Burke",
                     SiteUrl = "http://www.pluralsight.com/author/eric-burke-other",
                     UrlName = "eric-burke-other"
                  }
               },
               IsCoAuthors = false
            },
            new
            {
               Node = Mock.Of<INode>(),
               Authors = new List<PluralsightAuthor>
               {
                  new PluralsightAuthor
                  {
                     FullName = "Robert Horvick",
                     SiteUrl = "http://www.pluralsight.com/author/robert-horvick",
                     UrlName = "robert-horvick"
                  }
               },
               IsCoAuthors = false
            },
            new
            {
               Node = Mock.Of<INode>(),
               Authors = new List<PluralsightAuthor>
               {
                  new PluralsightAuthor
                  {
                     FullName = "Jan-Erik Sandberg",
                     SiteUrl = "http://www.pluralsight.com/author/janerik-sandberg",
                     UrlName = "janerik-sandberg"
                  }
               },
               IsCoAuthors = false
            },
            new
            {
               Node = Mock.Of<INode>(),
               Authors = new List<PluralsightAuthor>
               {
                  new PluralsightAuthor
                  {
                     FullName = "Eric Burke"
                  },
                  new PluralsightAuthor
                  {
                     FullName = "Jan-Erik Sandberg"
                  },
                  new PluralsightAuthor
                  {
                     FullName = "Jay Mcfarland"
                  },
                  new PluralsightAuthor
                  {
                     FullName = "Jeff Hurd"
                  }
               },
               IsCoAuthors = true
            }
         };


         var nodeSelector = Mock.Of<INodeSelector>(x => x.SelectAuthorNodes() == data.Select(d => d.Node));

         var nodeParser = Mock.Of<INodeParser>();

         Mock.Get(nodeParser).Setup(x => x.IsCoAuthorNode(It.IsAny<INode>()))
            .Returns((INode node) => data.Single(x => x.Node == node).IsCoAuthors);

         Mock.Get(nodeParser).Setup(x => x.ParseCoAuthors(It.IsAny<INode>()))
            .Returns((INode node) => data.Single(x => x.Node == node).Authors);

         Mock.Get(nodeParser).Setup(x => x.ParseAuthor(It.IsAny<INode>()))
            .Returns((INode node) => data.Single(x => x.Node == node).Authors.Single());


         var sut = new PluralsightCatalogParser(nodeSelector, nodeParser);

         // Act
         var result = sut.ParseAuthors();

         // Assert
         Assert.NotNull(result);

         var resultFullnamesakesAuthors = result.FullnamesakesAuthorsContainer.Values;
         Assert.Equal(1, resultFullnamesakesAuthors.Count);

         var resultAuthorsWithUrlNotNull = result.AllAuthorsExceptWhoseUrlNullContainer.Values;
         Assert.Equal(4, resultAuthorsWithUrlNotNull.Count);

         var resultAllAuthorsExceptFullnamesakes = result.AllAuthorsByFullNameExceptFullnamesakesContainer.Values;
         Assert.Equal(4, resultAllAuthorsExceptFullnamesakes.Count);
      }