Skip to content
This repository has been archived by the owner on Dec 6, 2019. It is now read-only.

Commit

Permalink
Updated theme
Browse files Browse the repository at this point in the history
Fixed unit tests
  • Loading branch information
Eldblom-zz committed Jun 1, 2017
1 parent 0e61410 commit 5cd2afe
Show file tree
Hide file tree
Showing 734 changed files with 93,845 additions and 69,917 deletions.
33 changes: 24 additions & 9 deletions src/Feature/Demo/code/Repositories/ReferralRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,33 @@ public ReferralRepository() : this(new CampaignRepository())
public Referral Get()
{
var campaigns = this.CreateCampaigns().ToArray();
var referringSite = Tracker.Current.Interaction.ReferringSite;
if (referringSite.Equals(HttpContext.Current.Request.Url.Host, StringComparison.InvariantCultureIgnoreCase))

return new Referral {
Campaigns = campaigns,
TotalNoOfCampaigns = campaigns.Length,
ReferringSite = this.GetReferringSite(),
Keywords = GetKeywords()
};
}

private static string GetKeywords()
{
string keywords = null;
if (Tracker.Current != null)
{
referringSite = null;
keywords = Tracker.Current.Interaction.Keywords;
}
return new Referral
return keywords;
}

private string GetReferringSite()
{
if (Tracker.Current == null || HttpContext.Current == null)
{
Campaigns = campaigns,
TotalNoOfCampaigns = campaigns.Length,
ReferringSite = referringSite,
Keywords = Tracker.Current.Interaction.Keywords
};
return null;
}
var referringSite = Tracker.Current.Interaction.ReferringSite;
return referringSite != null && referringSite.Equals(HttpContext.Current.Request.Url.Host, StringComparison.InvariantCultureIgnoreCase) ? null : referringSite;
}

private IEnumerable<Campaign> CreateCampaigns()
Expand Down
95 changes: 49 additions & 46 deletions src/Feature/Demo/tests/Repositories/ReferralRepositoryTests.cs
Original file line number Diff line number Diff line change
@@ -1,55 +1,58 @@
namespace Sitecore.Feature.Demo.Tests.Repositories
{
using System.Linq;
using FluentAssertions;
using NSubstitute;
using Ploeh.AutoFixture.Xunit2;
using Sitecore.Analytics;
using Sitecore.Analytics.Tracking;
using Sitecore.Feature.Demo.Models;
using Sitecore.Feature.Demo.Repositories;
using Sitecore.Foundation.Testing.Attributes;
using Xunit;
using System;
using System.Linq;
using System.Web;
using FluentAssertions;
using NSubstitute;
using Ploeh.AutoFixture.Xunit2;
using Sitecore.Analytics;
using Sitecore.Analytics.Tracking;
using Sitecore.Feature.Demo.Models;
using Sitecore.Feature.Demo.Repositories;
using Sitecore.Foundation.Testing.Attributes;
using Xunit;

public class ReferralRepositoryTests
{
[Theory]
[AutoDbData]
public void Get_Call_ShouldReturnReferringSite(string site,CurrentInteraction currentInteraction, ITracker tracker, ICampaignRepository campaignRepository, [Greedy]ReferralRepository referralRepository )
public class ReferralRepositoryTests
{
//Arrange
tracker.Interaction.Returns(currentInteraction);
tracker.Interaction.ReferringSite.Returns(site);
[Theory]
[AutoDbData]
public void Get_Call_ShouldReturnReferringSite(string site, CurrentInteraction currentInteraction, ITracker tracker, ICampaignRepository campaignRepository, [Greedy] ReferralRepository referralRepository, HttpContext httpContext)
{
//Arrange
HttpContext.Current = httpContext;
tracker.Interaction.Returns(currentInteraction);
tracker.Interaction.ReferringSite.Returns(site);

using (new TrackerSwitcher(tracker))
{
//Act
var referral = referralRepository.Get();
//Assert
referral.ReferringSite.Should().Be(site);
}
}
using (new TrackerSwitcher(tracker))
{
//Act
var referral = referralRepository.Get();
//Assert
referral.ReferringSite.Should().Be(site);
}
}

[Theory]
[AutoDbData]
public void Get_Call_ShouldCombineActiveAndHistoricCampaigns(string site, CurrentInteraction currentInteraction, ITracker tracker, [Frozen]ICampaignRepository campaignRepository, [Greedy]ReferralRepository referralRepository)
{
//Arrange
tracker.Interaction.Returns(currentInteraction);
tracker.Interaction.ReferringSite.Returns(site);
[Theory]
[AutoDbData]
public void Get_Call_ShouldCombineActiveAndHistoricCampaigns(string site, CurrentInteraction currentInteraction, ITracker tracker, [Frozen] ICampaignRepository campaignRepository, [Greedy] ReferralRepository referralRepository, HttpContext httpContext)
{
//Arrange
HttpContext.Current = httpContext;
tracker.Interaction.Returns(currentInteraction);
tracker.Interaction.ReferringSite.Returns(site);

campaignRepository.GetCurrent().Returns(new Campaign() {Title = "camp1"});
campaignRepository.GetHistoric().Returns(new[] {new Campaign() {Title = "camp2"}, new Campaign() {Title = "camp3"}});
campaignRepository.GetCurrent().Returns(new Campaign() {Title = "camp1"});
campaignRepository.GetHistoric().Returns(new[] {new Campaign() {Title = "camp2"}, new Campaign() {Title = "camp3"}});

using (new TrackerSwitcher(tracker))
{
//Act
var referral = referralRepository.Get();
//Assert
referral.TotalNoOfCampaigns.Should().Be(3);
referral.Campaigns.Select(x => x.Title).Should().Contain(new[] {"camp1", "camp2", "camp3",});
}
using (new TrackerSwitcher(tracker))
{
//Act
var referral = referralRepository.Get();
//Assert
referral.TotalNoOfCampaigns.Should().Be(3);
referral.Campaigns.Select(x => x.Title).Should().Contain(new[] {"camp1", "camp2", "camp3",});
}
}
}

}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ace-builds",
"version": "1.2.5",
"version": "1.2.6",
"description": "Ace (Ajax.org Cloud9 Editor)",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
Expand All @@ -18,11 +18,11 @@
"url": "https://github.com/ajaxorg/ace-builds/issues"
},
"homepage": "https://github.com/ajaxorg/ace-builds",
"_release": "1.2.5",
"_release": "1.2.6",
"_resolution": {
"type": "version",
"tag": "v1.2.5",
"commit": "21f7fa46ece12f8c425a5563784b3bf3fe84117d"
"tag": "v1.2.6",
"commit": "2268d21c5893320330c9daf10b70b1973ca45eba"
},
"_source": "https://github.com/ajaxorg/ace-builds.git",
"_target": "~1.2.3",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2016.12.03 Version 1.2.6

* Fixed IME handling on new Chrome
* Support for php 7 in the syntax checker

2016.08.16 Version 1.2.5

* Fixed regression in noconflict mode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<meta name="author" content="Fabian Jakobs">
<!--
Ace
version 1.2.5
version 1.2.6
commit
-->

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ace-builds",
"version": "1.2.5",
"version": "1.2.6",
"description": "Ace (Ajax.org Cloud9 Editor)",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 5cd2afe

Please sign in to comment.