-
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 #11 from marcduiker/develop
Develop
- Loading branch information
Showing
36 changed files
with
648 additions
and
122 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
src/AzureFunctionsUpdates.UnitTests/Models/LatestReleasesTests.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
32 changes: 32 additions & 0 deletions
32
src/AzureFunctionsUpdates.UnitTests/Orchestrations/PublicationUpdateOrchestrationTests.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,32 @@ | ||
using AzureFunctionsUpdates.Models; | ||
using AzureFunctionsUpdates.Orchestrations; | ||
using AzureFunctionsUpdates.UnitTests.TestObjectBuilders; | ||
using Microsoft.Extensions.Logging; | ||
using Moq; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Xunit; | ||
|
||
namespace AzureFunctionsUpdates.UnitTests.Orchestrations | ||
{ | ||
public class PublicationUpdateOrchestrationTests | ||
{ | ||
[Fact] | ||
public async Task GivenHistoryIsEmptyAndNewPublicationIsAvailable_WhenOrchcestrationIsRun_ThenSaveAndUpdateShouldBeCalled() | ||
{ | ||
// Arrange | ||
Environment.SetEnvironmentVariable(Toggles.DoPostUpdateVariableName, "true"); | ||
var mockContext = PublicationUpdateOrchestrationContextBuilder.BuildWithoutHistoryAndWithNewWebPublication(); | ||
var logger = new Mock<ILogger>(); | ||
var publicationUpdateOrchestration = new PublicationUpdateOrchestration(); | ||
|
||
// Act | ||
await publicationUpdateOrchestration.Run(mockContext.Object, logger.Object); | ||
|
||
// Assert | ||
mockContext.VerifyAll(); | ||
} | ||
} | ||
} |
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
24 changes: 24 additions & 0 deletions
24
src/AzureFunctionsUpdates.UnitTests/TestObjectBuilders/PublicationBuilder.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,24 @@ | ||
using AutoFixture; | ||
using AzureFunctionsUpdates.Models.Publications; | ||
using System; | ||
|
||
namespace AzureFunctionsUpdates.UnitTests.TestObjectBuilders | ||
{ | ||
public static class PublicationBuilder | ||
{ | ||
private static Fixture _fixture = new Fixture(); | ||
|
||
public static Publication BuildNullPublication(string publicationSourceName) | ||
{ | ||
return new NullPublication(publicationSourceName); | ||
} | ||
|
||
public static Publication BuildPublicationFromWeb(string publicationSourceName) | ||
{ | ||
return _fixture.Build<Publication>() | ||
.With(p => p.PublicationSourceName, publicationSourceName) | ||
.With(p => p.PublicationDate, DateTimeOffset.Now) | ||
.Create(); | ||
} | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/AzureFunctionsUpdates.UnitTests/TestObjectBuilders/PublicationConfigurationBuilder.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,23 @@ | ||
using AutoFixture; | ||
using AzureFunctionsUpdates.Models.Publications; | ||
using System.Collections.Generic; | ||
|
||
namespace AzureFunctionsUpdates.UnitTests.TestObjectBuilders | ||
{ | ||
public static class PublicationConfigurationBuilder | ||
{ | ||
private static Fixture _fixture = new Fixture(); | ||
|
||
private static PublicationConfiguration BuildOne(string publicationSourceName) | ||
{ | ||
return _fixture.Build<PublicationConfiguration>() | ||
.With(p => p.PublicationSourceName, publicationSourceName) | ||
.Create(); | ||
} | ||
|
||
public static IReadOnlyList<PublicationConfiguration> BuildListWithOne(string publicationSourceName) | ||
{ | ||
return new List<PublicationConfiguration> { BuildOne(publicationSourceName) }; | ||
} | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
...tionsUpdates.UnitTests/TestObjectBuilders/PublicationUpdateOrchestrationContextBuilder.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.Activities; | ||
using AzureFunctionsUpdates.Activities.Publications; | ||
using AzureFunctionsUpdates.Models; | ||
using AzureFunctionsUpdates.Models.Publications; | ||
using Microsoft.Azure.WebJobs; | ||
using Moq; | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
|
||
namespace AzureFunctionsUpdates.UnitTests.TestObjectBuilders | ||
{ | ||
public static class PublicationUpdateOrchestrationContextBuilder | ||
{ | ||
public static Mock<DurableOrchestrationContextBase> BuildWithoutHistoryAndWithNewWebPublication() | ||
{ | ||
var mockContext = new Mock<DurableOrchestrationContextBase>(MockBehavior.Strict); | ||
const string publicationSourceName = "Azure Service updates"; | ||
|
||
mockContext | ||
.Setup(c => c.CallActivityWithRetryAsync<IReadOnlyList<PublicationConfiguration>>( | ||
nameof(GetPublicationConfigurations), | ||
It.IsAny<RetryOptions>(), | ||
null)) | ||
.ReturnsAsync(PublicationConfigurationBuilder.BuildListWithOne(publicationSourceName)); | ||
|
||
mockContext | ||
.Setup(c => c.CallActivityWithRetryAsync<Publication>( | ||
nameof(GetLatestPublicationFromHistory), | ||
It.IsAny<RetryOptions>(), | ||
It.IsAny<PublicationConfiguration>())) | ||
.ReturnsAsync(PublicationBuilder.BuildNullPublication(publicationSourceName)); | ||
|
||
mockContext | ||
.Setup(c => c.CallActivityWithRetryAsync<Publication>( | ||
nameof(GetLatestPublicationFromWeb), | ||
It.IsAny<RetryOptions>(), | ||
It.IsAny<PublicationConfiguration>())) | ||
.ReturnsAsync(PublicationBuilder.BuildPublicationFromWeb(publicationSourceName)); | ||
|
||
mockContext | ||
.Setup(c => c.CallActivityWithRetryAsync( | ||
nameof(SaveLatestPublication), | ||
It.IsAny<RetryOptions>(), | ||
It.IsAny<Publication>())) | ||
.Returns(Task.CompletedTask); | ||
|
||
mockContext | ||
.Setup(c => c.CallActivityWithRetryAsync( | ||
nameof(PostUpdate), | ||
It.IsAny<RetryOptions>(), | ||
It.IsAny<UpdateMessage>())) | ||
.Returns(Task.CompletedTask); | ||
|
||
return mockContext; | ||
} | ||
} | ||
} |
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
3 changes: 2 additions & 1 deletion
3
src/AzureFunctionsUpdates.UnitTests/TestObjectBuilders/RepositoryConfigurationBuilder.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
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
Oops, something went wrong.