public void ReturnsNoNameProvidedGivenNullOrEmptyNames(string?firstName, string?lastName)
    {
        var member = MemberHelpers.CreateWithDefaultConstructor();

        member.UpdateName(firstName, lastName);

        Assert.Equal("[No Name Provided]", member.UserFullName());
    }
    public void ReturnsFirstNameSpaceLastNameWhenBothHaveValues()
    {
        var member = MemberHelpers.CreateWithDefaultConstructor();

        member.UpdateName(TEST_FIRST_NAME, TEST_LAST_NAME);

        Assert.Equal(TEST_FIRST_NAME + " " + TEST_LAST_NAME, member.UserFullName());
    }
    public void ShouldAddBookGivenBook()
    {
        Member member = MemberHelpers.CreateWithDefaultConstructor();
        Book   book   = BookHelpers.GetDefaultTestBook();

        member.AddBookRead(book);

        Assert.Contains(book, member.BooksRead);
    }
Esempio n. 4
0
    public void ShouldDoNothingGivenBookNotInBooksRead()
    {
        Member member = MemberHelpers.CreateWithDefaultConstructor();
        Book   book   = BookHelpers.GetDefaultTestBook();

        member.RemoveBookRead(book);

        // if we get this far, no error was thrown
        Assert.Empty(member.BooksRead);
    }
Esempio n. 5
0
    public void ReturnsDaysSubscribedToDate()
    {
        var member = MemberHelpers.CreateWithDefaultConstructor();
        MemberSubscription subscription = SubscriptionHelpers.GetSubscriptionWithGivenSubscribedDaysToDateAndTotalSubscribedDays(50);

        member.AddSubscription(subscription.Dates, 1);
        int days = member.TotalSubscribedDays();

        Assert.Equal(50, days);
    }
    public void AddsSubscriptionWithGivenDateTimeRange()
    {
        Member             member       = MemberHelpers.CreateWithDefaultConstructor();
        MemberSubscription subscription = SubscriptionHelpers.GetDefaultTestSubscription();

        member.AddSubscription(subscription.Dates, 1);

        var subscriptionAdded = member.MemberSubscriptions.Any(s => s.Dates.Equals(subscription.Dates));

        Assert.True(subscriptionAdded);
    }
Esempio n. 7
0
    private Member GetMemberWithDefaultAddress()
    {
        _initialAddress = Guid.NewGuid().ToString();

        var member = MemberHelpers.CreateWithDefaultConstructor();

        member.UpdateAddress(_initialAddress);
        member.Events.Clear();

        return(member);
    }
    private Member GetMemberWithDefaultAboutInfo()
    {
        _initialAboutInfo = Guid.NewGuid().ToString();

        Member?member = MemberHelpers.CreateWithDefaultConstructor();

        member.UpdateAboutInfo(_initialAboutInfo);
        member.Events.Clear();

        return(member);
    }
Esempio n. 9
0
    private Member GetMemberWithDefaultName()
    {
        _initialFirstName = Guid.NewGuid().ToString();
        _initialLastName  = Guid.NewGuid().ToString();

        var member = MemberHelpers.CreateWithDefaultConstructor();

        member.UpdateName(_initialFirstName, _initialLastName);
        member.Events.Clear();

        return(member);
    }
    public void ShouldDoNothingGivenDuplicateBook()
    {
        Member member = MemberHelpers.CreateWithDefaultConstructor();
        Book   book   = BookHelpers.GetDefaultTestBook();

        member.AddBookRead(book);
        member.AddBookRead(book);

        // if we get to this point no error was thrown.
        Assert.Contains(book, member.BooksRead);
        Assert.Single(member.BooksRead !);
    }
        public void Returns100GivenPercentageOver100()
        {
            var member       = MemberHelpers.CreateWithDefaultConstructor();
            var subscription = SubscriptionHelpers.GetSubscriptionWithGivenSubscribedDaysToDateAndTotalSubscribedDays(731);

            member.AddSubscription(subscription.Dates);

            var expectedPercentage = 100;

            var percentage = _memberSubscriptionPeriodCalculationsService.GetPercentageProgressToAlumniStatus(member);

            Assert.Equal(expectedPercentage, percentage);
        }
        public void CalculatesCorrectPercentageGivenPercentageBelow100(int days)
        {
            var member       = MemberHelpers.CreateWithDefaultConstructor();
            var subscription = SubscriptionHelpers.GetSubscriptionWithGivenSubscribedDaysToDateAndTotalSubscribedDays(days);

            member.AddSubscription(subscription.Dates);

            var expectedPercentage = (int)(100 * ((double)days / (double)730));

            var percentage = _memberSubscriptionPeriodCalculationsService.GetPercentageProgressToAlumniStatus(member);

            Assert.Equal(expectedPercentage, percentage);
        }
    public void ReturnsInputYouTubeUrlIfContainsQuestionMark()
    {
        var member = MemberHelpers.CreateWithDefaultConstructor();

        string youtubeInput = "https://www.youtube.com/ardalis?";

        member.UpdateLinks(null, null, null, null, null, null, youtubeInput, null);

        MemberLinksDTO dto = MemberLinksDTO.FromMemberEntity(member);

        var result = dto.YouTubeUrl;

        Assert.Equal(youtubeInput, result);
    }
    public void DoesNothingGivenNoCurrentSubscription()
    {
        Member             member = MemberHelpers.CreateWithDefaultConstructor();
        MemberSubscription starterSubscription = SubscriptionHelpers.GetSubscriptionWithPastEndDate();
        DateTime           newEndDate          = DateTime.Now.AddDays(30);
        var originalEndDate = starterSubscription.Dates.EndDate;

        member.AddSubscription(starterSubscription.Dates, 1);

        member.ExtendCurrentSubscription(newEndDate);

        Assert.Equal(originalEndDate, member.MemberSubscriptions[0].Dates.EndDate);

        Assert.Single(member.MemberSubscriptions);
    }
    public void ExtendsSubscription()
    {
        Member             member = MemberHelpers.CreateWithDefaultConstructor();
        MemberSubscription starterSubscription = SubscriptionHelpers.GetDefaultTestSubscription();
        DateTime           newEndDate          = DateTime.Now.AddDays(30);
        DateTime           originalStartDate   = starterSubscription.Dates.StartDate;

        member.AddSubscription(starterSubscription.Dates, 1);

        member.ExtendCurrentSubscription(newEndDate);

        Assert.Equal(newEndDate, member.MemberSubscriptions[0].Dates.EndDate);
        Assert.Equal(originalStartDate, member.MemberSubscriptions[0].Dates.StartDate);

        Assert.Single(member.MemberSubscriptions);
    }
Esempio n. 16
0
    private Member GetMemberWithDefaultLinks()
    {
        _initialBlogUrl = Guid.NewGuid().ToString();

        var member = MemberHelpers.CreateWithDefaultConstructor();

        member.UpdateLinks(_initialBlogUrl,
                           _initialCodinGameUrl,
                           _initialGitHubUrl,
                           _initialLinkedInUrl,
                           _initialOtherUrl,
                           _initialTwitchUrl,
                           _initialYouTubeUrl,
                           _initialTwitterUrl);
        member.Events.Clear();

        return(member);
    }
    public void AddsBillingActivityGivenMessageAndAmount()
    {
        Member  member = MemberHelpers.CreateWithDefaultConstructor();
        var     subscriptionPlanName = Guid.NewGuid().ToString();
        var     actionVerb           = BillingActivityVerb.None;
        var     random        = new Random();
        decimal amount        = random.Next() / 100;
        var     billingPeriod = BillingPeriod.Year;

        member.AddBillingActivity(subscriptionPlanName, actionVerb, billingPeriod, amount);

        var billingActivity = member.BillingActivities[0];

        using (new AssertionScope())
        {
            billingActivity.Details.BillingPeriod.Should().Be(billingPeriod);
            billingActivity.Details.Amount.Should().Be(amount);
        }
    }
    public void AddsBillingActivityGivenRequiredParameters()
    {
        Member member = MemberHelpers.CreateWithDefaultConstructor();
        var    subscriptionPlanName = Guid.NewGuid().ToString();
        var    actionVerb           = BillingActivityVerb.None;
        var    billingPeriod        = BillingPeriod.Month;

        member.AddBillingActivity(subscriptionPlanName, actionVerb, billingPeriod);

        var billingActivity = member.BillingActivities[0];

        using (new AssertionScope())
        {
            billingActivity.Details.SubscriptionPlanName.Should().Be(subscriptionPlanName);
            billingActivity.Details.ActionVerbPastTense.Should().Be(actionVerb);
            billingActivity.Details.BillingPeriod.Should().Be(billingPeriod);
            billingActivity.Details.MemberName.Should().Be(member.UserFullName());
        }
    }
Esempio n. 19
0
    public void IsPrivateForDefaultConstructor()
    {
        var member = MemberHelpers.CreateWithDefaultConstructor();

        Assert.NotNull(member);
    }
Esempio n. 20
0
    public void CreatesNoEventsWithDefaultConstructor()
    {
        var member = MemberHelpers.CreateWithDefaultConstructor();

        Assert.Empty(member.Events);
    }