-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
155 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
...ts/UnitTests/DailyEmailTests.CanCreateEmailWithTwoItemsDifferentEvidenceType.approved.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<div class='evidenceType'><strong>Some evidence type</strong><div class='item'>Some Title<br>Some source<br>Some speciality<br>Some short summary<br><a href='https://www.medicinesresources.nhs.uk/abc'>SPS Comment</a></div></div><div class='evidenceType'><strong>Some evidence type 2</strong><div class='item'>Some Title<br>Some source<br>Some speciality 2<br>Some short summary<br><a href='https://www.medicinesresources.nhs.uk/abc'>SPS Comment</a></div></div> |
1 change: 1 addition & 0 deletions
1
...ests/UnitTests/DailyEmailTests.CanCreateEmailWithTwoItemsSharingEvidenceType.approved.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<div class='evidenceType'><strong>Some evidence type</strong><div class='item'>Some Title<br>Some source<br>Some speciality<br>Some short summary<br><a href='https://www.medicinesresources.nhs.uk/abc'>SPS Comment</a></div><div class='item'>Some Title<br>Some source<br>Some speciality<br>Some short summary<br><a href='https://www.medicinesresources.nhs.uk/abc'>SPS Comment</a></div></div> |
1 change: 1 addition & 0 deletions
1
lambda/MAS.Tests/UnitTests/DailyEmailTests.CanCreateSingleItemEmail.approved.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<div class='evidenceType'><strong>Some evidence type</strong><div class='item'>Some Title<br>Some source<br>Some speciality<br>Some short summary<br><a href='https://www.medicinesresources.nhs.uk/abc'>SPS Comment</a></div></div> |
1 change: 1 addition & 0 deletions
1
...MAS.Tests/UnitTests/DailyEmailTests.ItemsWithManySpecialitiesRenderCorrectly.approved.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<div class='evidenceType'><strong>Some evidence type</strong><div class='item'>Some Title<br>Some source<br>Some speciality | Another speciality<br>Some short summary<br><a href='https://www.medicinesresources.nhs.uk/abc'>SPS Comment</a></div></div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
using MailChimp.Net.Core; | ||
using MailChimp.Net.Interfaces; | ||
using MailChimp.Net.Models; | ||
using MAS.Models; | ||
using MAS.Services; | ||
using MAS.Tests.Infrastructure; | ||
using Microsoft.Extensions.Logging; | ||
using Moq; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Xunit; | ||
using Source = MAS.Models.Source; | ||
|
||
namespace MAS.Tests.UnitTests | ||
{ | ||
public class DailyEmailTests : TestBase | ||
{ | ||
|
||
Mock<ILogger<MailService>> MockLogger; | ||
Mock<IMailChimpManager> MockMailChimpManager; | ||
MailService MailService; | ||
|
||
public DailyEmailTests() | ||
{ | ||
//Arrange | ||
MockLogger = new Mock<ILogger<MailService>>(); | ||
|
||
MockMailChimpManager = new Mock<IMailChimpManager>(); | ||
MockMailChimpManager.Setup(x => x.Campaigns.AddAsync(It.IsAny<Campaign>())).ReturnsAsync(new Campaign() { Id = "1234" }); | ||
MockMailChimpManager.Setup(x => x.Content.AddOrUpdateAsync(It.IsAny<string>(), It.IsAny<ContentRequest>())); | ||
MockMailChimpManager.Setup(x => x.Campaigns.SendAsync(It.IsAny<string>())); | ||
|
||
MailService = new MailService(MockMailChimpManager.Object, MockLogger.Object); | ||
} | ||
|
||
public override void Dispose() | ||
{ | ||
|
||
} | ||
|
||
Item exampleItem = new Item() | ||
{ | ||
Id = "123", | ||
Title = "Some Title", | ||
Slug = "abc", | ||
ShortSummary = "Some short summary", | ||
ResourceLinks = "", | ||
Comment = "", | ||
Speciality = new List<Speciality> | ||
{ | ||
new Speciality() | ||
{ | ||
Key = "1a", | ||
Title = "Some speciality", | ||
|
||
} | ||
}, | ||
EvidenceType = new EvidenceType() | ||
{ | ||
Key = "1b", | ||
Title = "Some evidence type" | ||
}, | ||
Source = new Source() | ||
{ | ||
Id = "1c", | ||
Title = "Some source" | ||
} | ||
}; | ||
Item exampleItem2 = new Item() | ||
{ | ||
Id = "123", | ||
Title = "Some Title", | ||
Slug = "abc", | ||
ShortSummary = "Some short summary", | ||
ResourceLinks = "", | ||
Comment = "", | ||
Speciality = new List<Speciality> | ||
{ | ||
new Speciality() | ||
{ | ||
Key = "1a", | ||
Title = "Some speciality 2", | ||
|
||
} | ||
}, | ||
EvidenceType = new EvidenceType() | ||
{ | ||
Key = "1c", | ||
Title = "Some evidence type 2" | ||
}, | ||
Source = new Source() | ||
{ | ||
Id = "1c", | ||
Title = "Some source" | ||
} | ||
}; | ||
|
||
[Fact] | ||
public void CanCreateSingleItemEmail() | ||
{ | ||
var items = new List<Item> { exampleItem }; | ||
var actualHtml = this.MailService.CreateDailyEmailBody(items); | ||
|
||
actualHtml.ShouldMatchApproved(); | ||
|
||
} | ||
|
||
[Fact] | ||
public void CanCreateEmailWithTwoItemsSharingEvidenceType() | ||
{ | ||
var items = new List<Item> { exampleItem, exampleItem }; | ||
var actualHtml = this.MailService.CreateDailyEmailBody(items); | ||
|
||
actualHtml.ShouldMatchApproved(); | ||
|
||
} | ||
|
||
[Fact] | ||
public void CanCreateEmailWithTwoItemsDifferentEvidenceType() | ||
{ | ||
var items = new List<Item> { exampleItem, exampleItem2 }; | ||
var actualHtml = this.MailService.CreateDailyEmailBody(items); | ||
|
||
actualHtml.ShouldMatchApproved(); | ||
|
||
} | ||
|
||
[Fact] | ||
public void ItemsWithManySpecialitiesRenderCorrectly() | ||
{ | ||
exampleItem.Speciality.Add(new Speciality() { Key = "abcd", Title = "Another speciality" }); | ||
var items = new List<Item> { exampleItem }; | ||
var actualHtml = this.MailService.CreateDailyEmailBody(items); | ||
|
||
actualHtml.ShouldMatchApproved(); | ||
|
||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
697face
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.
TeamCity MAS / MAS Build 1.1.0.544-MAS-129_121__112_Dai outcome was FAILURE
Summary: Artifacts size 172 KB is 95% different from 3.6 MB in build #1.1.0.543-rAF001FD (new) Build time: 00:00:38
697face
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.
TeamCity MAS / MAS Build 1.1.0.545-MAS-129_121__112_Dai outcome was FAILURE
Summary: Artifacts size 172 KB is 95% different from 3.6 MB in build #1.1.0.543-rAF001FD Build time: 00:00:37