public async Task Handler_WithValidRequestUrl_AndMatchingBrowserProfile_ShouldBeSelectMode_AndUseThatBrowserProfile() { // Arrange var requestUrl = new Faker().Internet.Url(); var host = new Uri(requestUrl).Host; var command = new ApplicationInitializeCommand(new[] { requestUrl }); var browserFaker = new AutoFaker <Browser>() .UsePrivateConstructor(); var profileFaker = new AutoFaker <Profile>() .UsePrivateConstructor(); //.RuleFor(p => p.Websites, new AutoFaker<Website>() // .RuleFor(w => w.Domain, host) // .Generate(1)); var browserProfiles = new AutoFaker <BrowserProfile>() .CustomInstantiator(f => new BrowserProfile(browserFaker.Generate(), profileFaker.Generate(), f.Random.String())) .Generate(1); _browserService .Setup(x => x.GetBrowserProfilesAsync()) .ReturnsAsync(browserProfiles); // Act var result = await _handler.Handle(command, CancellationToken.None); // Assert _applicationStore.VerifySet(x => x.ApplicationMode = ApplicationMode.Select, Times.Once); _browserService.Verify(x => x.UseBrowserProfileAsync(browserProfiles.First(), requestUrl, false), Times.Once); result.Should().BeOfType <Unit>(); }
public async Task Handler_WithInvalidRequestUrl_ShouldBeSettingMode() { // Arrange var command = new ApplicationInitializeCommand(new[] { "asdfasdf" }); // Act var result = await _handler.Handle(command, CancellationToken.None); // Assert _applicationStore.VerifySet(x => x.ApplicationMode = ApplicationMode.Settings, Times.Once); result.Should().BeOfType <Unit>(); }
public async Task Handler_WithValidRequestUrl_AndNoMatchingBrowserProfile_ShouldBeSelectMode() { // Arrange var requestUrl = new Faker().Internet.Url(); var command = new ApplicationInitializeCommand(new[] { requestUrl }); var browserProfiles = new List <BrowserProfile>(); _browserService .Setup(x => x.GetBrowserProfilesAsync()) .ReturnsAsync(browserProfiles); // Act var result = await _handler.Handle(command, CancellationToken.None); // Assert _applicationStore.VerifySet(x => x.ApplicationMode = ApplicationMode.Select, Times.Once); _browserService.Verify(x => x.UseBrowserProfileAsync(It.IsAny <BrowserProfile>(), It.IsAny <string>(), It.IsAny <bool>()), Times.Never); result.Should().BeOfType <Unit>(); }