-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from marcduiker/develop
Added logic to MessageBuilder to handle messages with length > 255
- Loading branch information
Showing
3 changed files
with
112 additions
and
11 deletions.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
src/AzureFunctionsUpdates.UnitTests/Builders/MessageBuilderTests.cs
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,57 @@ | ||
using AzureFunctionsUpdates.Builders; | ||
using AzureFunctionsUpdates.UnitTests.TestObjectBuilders; | ||
using FluentAssertions; | ||
using Xunit; | ||
|
||
namespace AzureFunctionsUpdates.UnitTests.Builders | ||
{ | ||
public class MessageBuilderTests | ||
{ | ||
[Fact] | ||
public void GivenMessageContentIsTooLong_WhenUpdateMessageIsCreated_ThenTheMessageIsShortened() | ||
{ | ||
// Arrange | ||
var release = RepositoryReleaseBuilder.BuildOneWithLongRepoAndReleaseName(); | ||
|
||
// Act | ||
var message = MessageBuilder.BuildForRelease(release); | ||
|
||
// Assert | ||
var messageLengthWithoutUrlPlusFixedShortenedUrl = | ||
message.Content.Length - release.HtmlUrl.Length + MessageBuilder.TwitterShortenedUrlCharacterCount; | ||
messageLengthWithoutUrlPlusFixedShortenedUrl.Should().BeLessOrEqualTo(MessageBuilder.MaxTwitterCharacterCount); | ||
} | ||
|
||
[Fact] | ||
public void GivenMessageContentIsNotTooLong_WhenUpdateMessageIsCreated_ThenTheMessageIsNotShortened() | ||
{ | ||
// Arrange | ||
var release = RepositoryReleaseBuilder.BuildOneWithShortRepoAndReleaseNameOnAspecificDate(); | ||
|
||
// Act | ||
var message = MessageBuilder.BuildForRelease(release); | ||
|
||
// Assert | ||
var messageLengthWithoutUrlPlusFixedShortenedUrl = | ||
message.Content.Length - release.HtmlUrl.Length + MessageBuilder.TwitterShortenedUrlCharacterCount; | ||
messageLengthWithoutUrlPlusFixedShortenedUrl.Should().BeLessOrEqualTo(MessageBuilder.MaxTwitterCharacterCount); | ||
} | ||
|
||
[Fact] | ||
public void GivenARepositoryRelease_WhenUpdateMessageIsCreated_ThenTheMessageContainsTheCorrespondingReleaseInfo() | ||
{ | ||
// Arrange | ||
var release = RepositoryReleaseBuilder.BuildOneWithShortRepoAndReleaseNameOnAspecificDate(); | ||
|
||
// Act | ||
var message = MessageBuilder.BuildForRelease(release); | ||
|
||
// Assert | ||
message.Content.Should().Be(@"A new azure-functions-host release, Azure Functions Runtime 2.0.12477 (tagged v2.0.12477), is available on GitHub since Monday, January 1, 2018. | ||
See https://github.com/Azure/azure-functions-host/releases/tag/v2.0.12477 for more information. | ||
#AzureFunctions #Serverless"); | ||
} | ||
} | ||
} |
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
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