Beispiel #1
0
        public void Should_ReturnCourseCoAuthorWithFullnamesakeMark_WhenAuthorNameInFullnamesakeContainer()
        {
            // Arrange
            var author = new PluralsightAuthor
            {
                FullName = "John Smith"
            };

            var course = new PluralsightCourse();

            var fullnamesakesAuthorsContainer =
                new Dictionary <IAuthorFullNameNaturalKey, PluralsightAuthor>(
                    FullNameNaturalKeyEqualityComparer <IAuthorFullNameNaturalKey> .Instance);

            var allAuthorsExceptFullnamesakesContainer =
                new Dictionary <IAuthorFullNameNaturalKey, PluralsightAuthor>(
                    FullNameNaturalKeyEqualityComparer <IAuthorFullNameNaturalKey> .Instance);

            fullnamesakesAuthorsContainer.Add(author, author);

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

            var sut = new PluralsightCatalogParser(nodeSelector, nodeParser);

            // Act
            var result = sut.GetCourseCoAuthor(course, author, allAuthorsExceptFullnamesakesContainer, fullnamesakesAuthorsContainer);

            // Assert
            Assert.NotNull(result);
            Assert.Same(course, result.Course);
            Assert.Same(author, result.Author);

            Assert.Equal(true, result.HasFullnamesake);
        }
Beispiel #2
0
        private void CheckCourseAuthorsEquality(PluralsightCourse expectedCourse,
                                                PluralsightCourse resultCourse)
        {
            Assert.Equal(expectedCourse.CourseAuthors.Count, resultCourse.CourseAuthors.Count);

            foreach (var resultCourseAuthor in resultCourse.CourseAuthors)
            {
                Assert.Same(resultCourseAuthor.Course, resultCourse);

                var expectedCourseAuthor = expectedCourse.CourseAuthors
                                           .First(x => x.Author.FullName == resultCourseAuthor.Author.FullName &&
                                                  x.Author.UrlName == resultCourseAuthor.Author.UrlName);

                Assert.Equal(expectedCourseAuthor, resultCourseAuthor, PluralsightCourseAuthor.PropertiesComparer);

                Assert.Equal(expectedCourseAuthor.Author, resultCourseAuthor.Author, PluralsightAuthor.PropertiesComparer);
            }
        }
        public CoursePage(PluralsightCourse course)
        {
            switch (Device.RuntimePlatform)
            {
            case Device.iOS:
                Padding = new Thickness(10, 20, 10, 0);
                break;

            default:
                Padding = new Thickness(10, 0);
                break;
            }

            BackgroundColor = Color.Gray;

            this.Title = course.TitleShort;

            var titleLabel = new Label
            {
                Text = course.Title,
                Font = Font.SystemFontOfSize(NamedSize.Large)
            };

            var authorLabel = new Label
            {
                Text = course.Author,
                Font = Font.SystemFontOfSize(NamedSize.Small)
            };

            var descriptionLabel = new Label
            {
                Text = course.Description,
                Font = Font.SystemFontOfSize(NamedSize.Medium)
            };

            Content = new ScrollView
            {
                Content = new StackLayout
                {
                    Spacing  = 10,
                    Children = { titleLabel, authorLabel, descriptionLabel }
                }
            };
        }
        public CourseMasterDetail()
        {
            var listView = new ListView();

            listView.ItemsSource = PluralsightCourse.GetCourseList();

            listView.ItemSelected += (s, e) =>
            {
                if (e.SelectedItem != null)
                {
                    Detail = new CoursePage(e.SelectedItem as PluralsightCourse);
                }
            };

            Master = new ContentPage
            {
                Title   = "Courses",
                Content = listView
            };

            Detail = new CoursePage(PluralsightCourse.GetCourseList().First());
        }
Beispiel #5
0
        public void Should_ReturnCourseAuthors()
        {
            // Arrange
            var coAuthors = new[] { "Eric Burke", "Steve Evans", "Rob Windsor" }
            .Select(x => new PluralsightAuthor {
                FullName = x
            }).ToList();

            var author = new PluralsightAuthor {
                FullName = "John Smith", UrlName = "john-smith"
            };

            var coAuthorNode = Mock.Of <INode>();
            var authorNode   = Mock.Of <INode>();

            var course = new PluralsightCourse();

            var fullnamesakesAuthorsContainer = new Dictionary <IAuthorFullNameNaturalKey, PluralsightAuthor>(
                FullNameNaturalKeyEqualityComparer <IAuthorFullNameNaturalKey> .Instance);

            fullnamesakesAuthorsContainer.Add(coAuthors[1], coAuthors[1]);


            var allAuthorsExceptFullnamesakesContainer = new Dictionary <IAuthorFullNameNaturalKey, PluralsightAuthor>(
                FullNameNaturalKeyEqualityComparer <IAuthorFullNameNaturalKey> .Instance);

            allAuthorsExceptFullnamesakesContainer.Add(coAuthors[0], coAuthors[0]);
            allAuthorsExceptFullnamesakesContainer.Add(coAuthors[2], coAuthors[2]);
            allAuthorsExceptFullnamesakesContainer.Add(author, author);

            var allAuthorsExceptWhoseUrlNullContainer = new Dictionary <IAuthorUrlNameNaturalKey, PluralsightAuthor>(
                UrlNameNaturalKeyEqualityComparer <IAuthorUrlNameNaturalKey> .Instance);

            allAuthorsExceptWhoseUrlNullContainer.Add(author, author);

            var authorsParseResult = new PluralsightCatalogParser.AuthorsParseResult
            {
                FullnamesakesAuthorsContainer = fullnamesakesAuthorsContainer,
                AllAuthorsByFullNameExceptFullnamesakesContainer = allAuthorsExceptFullnamesakesContainer,
                AllAuthorsExceptWhoseUrlNullContainer            = allAuthorsExceptWhoseUrlNullContainer
            };


            var nodeSelector = Mock.Of <INodeSelector>();

            var nodeParser = Mock.Of <INodeParser>(x =>
                                                   x.IsCoAuthorNode(coAuthorNode) == true &&
                                                   x.ParseCoAuthors(coAuthorNode) == coAuthors &&

                                                   x.IsCoAuthorNode(authorNode) == false &&
                                                   x.ParseAuthor(authorNode) == author);

            var sut = new PluralsightCatalogParser(nodeSelector, nodeParser);

            // Act
            var result = sut.GetCourseAuthors(new[] { authorNode, coAuthorNode }, course, authorsParseResult);

            // Assert
            Assert.NotNull(result);
            Assert.Equal(4, result.Count);

            foreach (var courseAuthor in result)
            {
                Assert.Same(course, courseAuthor.Course);
            }

            Assert.Equal(coAuthors.OrderBy(x => x.FullName),
                         result.Where(x => x.IsAuthorCoAuthor).Select(x => x.Author).OrderBy(x => x.FullName),
                         ReferenceEqualityComparer.Instance);

            Assert.Same(author, result.Single(x => x.IsAuthorCoAuthor == false).Author);

            Assert.Same(coAuthors[1], result.Single(x => x.HasFullnamesake).Author);
        }
      public void Should_ReturnCourseAuthors()
      {
         // Arrange
         var coAuthors = new[] { "Eric Burke", "Steve Evans", "Rob Windsor" }
            .Select(x => new PluralsightAuthor { FullName = x }).ToList();

         var author = new PluralsightAuthor { FullName = "John Smith", UrlName = "john-smith"};

         var coAuthorNode = Mock.Of<INode>();
         var authorNode = Mock.Of<INode>();

         var course = new PluralsightCourse();

         var fullnamesakesAuthorsContainer = new Dictionary<IAuthorFullNameNaturalKey, PluralsightAuthor>(
            FullNameNaturalKeyEqualityComparer<IAuthorFullNameNaturalKey>.Instance);

         fullnamesakesAuthorsContainer.Add(coAuthors[1], coAuthors[1]);


         var allAuthorsExceptFullnamesakesContainer = new Dictionary<IAuthorFullNameNaturalKey, PluralsightAuthor>(
            FullNameNaturalKeyEqualityComparer<IAuthorFullNameNaturalKey>.Instance);

         allAuthorsExceptFullnamesakesContainer.Add(coAuthors[0], coAuthors[0]);
         allAuthorsExceptFullnamesakesContainer.Add(coAuthors[2], coAuthors[2]);
         allAuthorsExceptFullnamesakesContainer.Add(author, author);

         var allAuthorsExceptWhoseUrlNullContainer = new Dictionary<IAuthorUrlNameNaturalKey, PluralsightAuthor>(
            UrlNameNaturalKeyEqualityComparer<IAuthorUrlNameNaturalKey>.Instance);
         allAuthorsExceptWhoseUrlNullContainer.Add(author, author);

         var authorsParseResult = new PluralsightCatalogParser.AuthorsParseResult
         {
            FullnamesakesAuthorsContainer = fullnamesakesAuthorsContainer,
            AllAuthorsByFullNameExceptFullnamesakesContainer = allAuthorsExceptFullnamesakesContainer,
            AllAuthorsExceptWhoseUrlNullContainer = allAuthorsExceptWhoseUrlNullContainer
         };


         var nodeSelector = Mock.Of<INodeSelector>();

         var nodeParser = Mock.Of<INodeParser>(x =>
            x.IsCoAuthorNode(coAuthorNode) == true &&
            x.ParseCoAuthors(coAuthorNode) == coAuthors &&

            x.IsCoAuthorNode(authorNode) == false &&
            x.ParseAuthor(authorNode) == author);

         var sut = new PluralsightCatalogParser(nodeSelector, nodeParser);

         // Act
         var result = sut.GetCourseAuthors(new[] { authorNode, coAuthorNode }, course, authorsParseResult);

         // Assert
         Assert.NotNull(result);
         Assert.Equal(4, result.Count);

         foreach (var courseAuthor in result)
         {
            Assert.Same(course, courseAuthor.Course);
         }
         
         Assert.Equal(coAuthors.OrderBy(x => x.FullName),
            result.Where(x => x.IsAuthorCoAuthor).Select(x => x.Author).OrderBy(x => x.FullName),
            ReferenceEqualityComparer.Instance);

         Assert.Same(author, result.Single(x => x.IsAuthorCoAuthor == false).Author);

         Assert.Same(coAuthors[1], result.Single(x => x.HasFullnamesake).Author);
      }
      public void Should_ReturnCourseCoAuthorWithoutFullnamesakeMark_WhenAuthorNotInFullnamesakeContainer()
      {
         // Arrange
         var author = new PluralsightAuthor
         {
            FullName = "John Smith"
         };

         var course = new PluralsightCourse();

         var fullnamesakesAuthorsContainer =
            new Dictionary<IAuthorFullNameNaturalKey, PluralsightAuthor>(
               FullNameNaturalKeyEqualityComparer<IAuthorFullNameNaturalKey>.Instance);

         var allAuthorsExceptFullnamesakesContainer =
            new Dictionary<IAuthorFullNameNaturalKey, PluralsightAuthor>(FullNameNaturalKeyEqualityComparer<IAuthorFullNameNaturalKey>.Instance)
            {
               {author, author}
            };


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

         var sut = new PluralsightCatalogParser(nodeSelector, nodeParser);

         // Act
         var result = sut.GetCourseCoAuthor(course, author, allAuthorsExceptFullnamesakesContainer, fullnamesakesAuthorsContainer);

         // Assert
         Assert.NotNull(result);
         Assert.Same(course, result.Course);
         Assert.Same(author, result.Author);

         Assert.Equal(false, result.HasFullnamesake);
      }
Beispiel #8
0
        public HomePage()
        {
            Padding = new Thickness(10, 20, 10, 0);
            Title   = "Pages";

            var button1 = new Button {
                Text = "Simple Page"
            };

            button1.Clicked += (o, e) =>
            {
                Navigation.PushAsync(new CoursePage(PluralsightCourse.GetCourseList().First()));
            };

            var button2 = new Button {
                Text = "Master/Detail"
            };

            button2.Clicked += (o, e) =>
            { Navigation.PushAsync(new CourseMasterDetail()); };

            var button3 = new Button {
                Text = "Master/Detail (binding)"
            };

            button3.Clicked += (o, e) =>
            { Navigation.PushAsync(new CourseMasterDetailDB()); };

            var button4 = new Button {
                Text = "Tabbed"
            };

            button4.Clicked += (o, e) =>
            {
                var page = new TabbedPage
                {
                    Title = "Courses"
                };

                foreach (var course in PluralsightCourse.GetCourseList())
                {
                    var coursePage = new CoursePageDB {
                        BindingContext = course
                    };
                    page.Children.Add(coursePage);
                }

                Navigation.PushAsync(page);
            };

            var button5 = new Button {
                Text = "Carousel"
            };

            button5.Clicked += (o, e) =>
            {
                var page = new CarouselPage
                {
                    Title = "Courses"
                };

                foreach (var course in PluralsightCourse.GetCourseList())
                {
                    var coursePage = new CoursePageDB
                    {
                        BindingContext = course
                    };
                    page.Children.Add(coursePage);
                }

                Navigation.PushAsync(page);
            };

            Content = new StackLayout
            {
                Spacing  = 10,
                Children = { button1, button2, button3, button4, button5 }
            };
        }