-
Notifications
You must be signed in to change notification settings - Fork 641
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add banner to all pages #8579
Add banner to all pages #8579
Changes from all commits
6546ecb
547d80e
6961f9d
69b16eb
ce42d2c
848199a
ccfc30c
173953c
311fa69
29625a5
41f450a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,7 +71,9 @@ public void SetViewBagGivenHttpContextItemsWithCanWriteAnalyticsCookies(bool can | |
{ | ||
// Arrange | ||
var cookieExpirationService = GetMock<ICookieExpirationService>(); | ||
var featureFlagsService = GetMock<IFeatureFlagService>(); | ||
cookieExpirationService.Setup(e => e.ExpireAnalyticsCookies(It.IsAny<HttpContextBase>())); | ||
featureFlagsService.Setup(e => e.IsDisplayBannerEnabled()).Returns(false); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is no need to verify the banner flag in these two tests for cookies, if we have another test to cover it. |
||
|
||
var httpContext = new Mock<HttpContextBase>(); | ||
var items = new Dictionary<string, bool> | ||
|
@@ -82,12 +84,14 @@ public void SetViewBagGivenHttpContextItemsWithCanWriteAnalyticsCookies(bool can | |
|
||
var controller = GetController<TestableAppController>(); | ||
controller.SetCookieExpirationService(cookieExpirationService.Object); | ||
controller.SetFeatureFlagsService(featureFlagsService.Object); | ||
|
||
// Act | ||
InvokeOnActionExecutedMethod(controller.ControllerContext, httpContext.Object, controller); | ||
|
||
// Assert | ||
Assert.Equal(canWriteAnalyticsCookies, controller.ViewBag.CanWriteAnalyticsCookies); | ||
Assert.Equal(false, controller.ViewBag.DisplayBanner); | ||
if (canWriteAnalyticsCookies) | ||
{ | ||
cookieExpirationService.Verify(e => e.ExpireAnalyticsCookies(It.IsAny<HttpContextBase>()), Times.Never); | ||
|
@@ -103,14 +107,17 @@ public void SetViewBagGivenHttpContextItemsWithNullCanWriteAnalyticsCookies() | |
{ | ||
// Arrange | ||
var cookieExpirationService = GetMock<ICookieExpirationService>(); | ||
var featureFlagsService = GetMock<IFeatureFlagService>(); | ||
cookieExpirationService.Setup(e => e.ExpireAnalyticsCookies(It.IsAny<HttpContextBase>())); | ||
featureFlagsService.Setup(e => e.IsDisplayBannerEnabled()).Returns(false); | ||
|
||
var httpContext = new Mock<HttpContextBase>(); | ||
var items = new Dictionary<string, bool>(); | ||
httpContext.Setup(c => c.Items).Returns(items); | ||
|
||
var controller = GetController<TestableAppController>(); | ||
controller.SetCookieExpirationService(cookieExpirationService.Object); | ||
controller.SetFeatureFlagsService(featureFlagsService.Object); | ||
|
||
// Act | ||
InvokeOnActionExecutedMethod(controller.ControllerContext, httpContext.Object, controller); | ||
|
@@ -120,6 +127,31 @@ public void SetViewBagGivenHttpContextItemsWithNullCanWriteAnalyticsCookies() | |
cookieExpirationService.Verify(e => e.ExpireAnalyticsCookies(It.IsAny<HttpContextBase>()), Times.Once); | ||
} | ||
|
||
[Theory] | ||
[InlineData(true)] | ||
[InlineData(false)] | ||
public void SetViewBagWithBannerWhenIsDisplayBannerEnabled(bool isDisplayBannerEnabled) { | ||
// Arrange | ||
var cookieExpirationService = GetMock<ICookieExpirationService>(); | ||
var featureFlagsService = GetMock<IFeatureFlagService>(); | ||
cookieExpirationService.Setup(e => e.ExpireAnalyticsCookies(It.IsAny<HttpContextBase>())); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can also remove this setup and verification because we test the banner flag here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's private method. I don't think we could remove the set up. let me know if I am wrong. |
||
featureFlagsService.Setup(e => e.IsDisplayBannerEnabled()).Returns(isDisplayBannerEnabled); | ||
|
||
var httpContext = new Mock<HttpContextBase>(); | ||
var items = new Dictionary<string, bool>(); | ||
httpContext.Setup(c => c.Items).Returns(items); | ||
|
||
var controller = GetController<TestableAppController>(); | ||
controller.SetCookieExpirationService(cookieExpirationService.Object); | ||
controller.SetFeatureFlagsService(featureFlagsService.Object); | ||
|
||
// Act | ||
InvokeOnActionExecutedMethod(controller.ControllerContext, httpContext.Object, controller); | ||
|
||
// Assert | ||
Assert.Equal(isDisplayBannerEnabled, controller.ViewBag.DisplayBanner); | ||
} | ||
|
||
private void InvokeOnActionExecutedMethod(ControllerContext controllerContext, HttpContextBase httpContext, AppController controller) | ||
{ | ||
var actionExecutedContext = new ActionExecutedContext(controllerContext, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's better to have a separate test for the banner flag.