Beispiel #1
0
        public virtual ProcessedOrganisation Build(Organisation organisation)
        {
            var body = _markdownWrapper.ConvertToHtml(organisation.AboutUs ?? "");

            var volunteering = new Volunteering
            {
                Email              = organisation.Email,
                VolunteeringText   = organisation.VolunteeringText,
                VolunteeringNeeded = organisation.Volunteering,
                Url  = $"organisations/{organisation.Slug}",
                Type = "organisation"
            };

            var donations = new Donations()
            {
                Email        = organisation.Email,
                GetDonations = organisation.Donations,
                Url          = $"groups/{organisation.Slug}"
            };

            var groupsWithFavourites = cookiesHelper.PopulateCookies(organisation.Groups, "favourites");

            return(new ProcessedOrganisation(organisation.Title, organisation.Slug, organisation.ImageUrl, body, organisation.Phone,
                                             organisation.Email, groupsWithFavourites, volunteering, donations));
        }
        public void ShouldPopulateFavouritePropertyToCollectionWhencallingPopulateFavourites()
        {
            // Arrange
            var cookies = new FakeCookie(true);

            var groups = new List <Group>()
            {
                new GroupBuilder().Slug("test1").Build(),
                new GroupBuilder().Build()
            };

            httpContextAccessor.Setup(_ => _.HttpContext.Request.Cookies).Returns(cookies);

            // Act
            groups = cookiesHelper.PopulateCookies(groups, "favourites");

            // Assert
            groups[0].Favourite.Should().Be(true);
            groups[1].Favourite.Should().Be(false);
        }