More logging and fixed default Azure Devops configuration#114
Merged
coenm merged 2 commits intocoenm:mainfrom Apr 25, 2024
Merged
More logging and fixed default Azure Devops configuration#114coenm merged 2 commits intocoenm:mainfrom
coenm merged 2 commits intocoenm:mainfrom
Conversation
Owner
|
Replace namespace RepoM.Plugin.WebBrowser.Tests;
using System.Collections.Generic;
using System.Threading.Tasks;
using FakeItEasy;
using Microsoft.Extensions.Logging;
using RepoM.Core.Plugin;
using RepoM.Plugin.WebBrowser;
using RepoM.Plugin.WebBrowser.PersistentConfiguration;
using SimpleInjector;
using Xunit;
public class WebBrowserPackageTest
{
private readonly Container _container;
private readonly IPackageConfiguration _packageConfiguration;
public WebBrowserPackageTest()
{
_packageConfiguration = A.Fake<IPackageConfiguration>();
_container = new Container();
var webBrowserConfigV1 = new WebBrowserConfigV1
{
Browsers = new Dictionary<string, string>
{
{ "Edge", "msedge.exe" },
},
Profiles = new Dictionary<string, ProfileConfig>
{
{
"incognito",
new ProfileConfig { BrowserName = "Edge", CommandLineArguments = "--incognito", }
},
},
};
A.CallTo(() => _packageConfiguration.GetConfigurationVersionAsync()).Returns(Task.FromResult(1 as int?));
A.CallTo(() => _packageConfiguration.LoadConfigurationAsync<WebBrowserConfigV1>()).ReturnsLazily(() => webBrowserConfigV1);
A.CallTo(() => _packageConfiguration.PersistConfigurationAsync(A<WebBrowserConfigV1>._, 1)).Returns(Task.CompletedTask);
}
[Fact]
public async Task RegisterServices_ShouldBeSuccessful_WhenExternalDependenciesAreRegistered()
{
// arrange
RegisterExternals(_container);
var sut = new WebBrowserPackage();
// act
await sut.RegisterServicesAsync(_container, _packageConfiguration);
// assert
// implicit, Verify throws when container is not valid.
_container.Verify(VerificationOption.VerifyAndDiagnose);
}
[Theory]
[InlineData(null)]
[InlineData(2)]
[InlineData(10)]
public async Task RegisterServices_ShouldPersistNewConfig_WhenVersionIsNotCorrect(int? version)
{
// arrange
RegisterExternals(_container);
A.CallTo(() => _packageConfiguration.GetConfigurationVersionAsync()).Returns(Task.FromResult(version));
var sut = new WebBrowserPackage();
// act
await sut.RegisterServicesAsync(_container, _packageConfiguration);
// assert
A.CallTo(() => _packageConfiguration.PersistConfigurationAsync(A<WebBrowserConfigV1>._, 1)).MustHaveHappenedOnceExactly();
// implicit, Verify throws when container is not valid.
_container.Verify(VerificationOption.VerifyAndDiagnose);
}
private static void RegisterExternals(Container container)
{
container.RegisterSingleton(A.Dummy<ILogger>);
}
} |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.