public async Task ValidateAuthFactorAsync_ShouldBeOfTypeValidationResult() { // Arrange var userId = new UserId(); var summoner = new Summoner { ProfileIconId = 0, Name = "testName", Region = Region.Na, AccountId = "testId" }; TestMock.LeagueOfLegendsService.Setup(leagueService => leagueService.Summoner.GetSummonerByAccountIdAsync(It.IsAny <Region>(), It.IsAny <string>())) .ReturnsAsync(summoner) .Verifiable(); TestMock.GameAuthenticationRepository.Setup(repository => repository.RemoveAuthenticationAsync(It.IsAny <UserId>(), It.IsAny <Game>())) .Returns(Task.CompletedTask) .Verifiable(); var authFactorService = new LeagueOfLegendsAuthenticationValidatorAdapter( TestMock.LeagueOfLegendsService.Object, TestMock.GameAuthenticationRepository.Object); // Act var result = await authFactorService.ValidateAuthenticationAsync( userId, new GameAuthentication <LeagueOfLegendsGameAuthenticationFactor>( new PlayerId(), new LeagueOfLegendsGameAuthenticationFactor( 1, string.Empty, 2, string.Empty))); // Assert result.Should().BeOfType <DomainValidationResult <GameAuthentication> >(); TestMock.LeagueOfLegendsService.Verify( leagueService => leagueService.Summoner.GetSummonerByAccountIdAsync(It.IsAny <Region>(), It.IsAny <string>()), Times.Once); TestMock.GameAuthenticationRepository.Verify(repository => repository.RemoveAuthenticationAsync(It.IsAny <UserId>(), It.IsAny <Game>()), Times.Once); }
public async Task ValidateAuthFactorAsync() { // Arrange var authFactor = new GameAuthentication <LeagueOfLegendsGameAuthenticationFactor>( new PlayerId(), new LeagueOfLegendsGameAuthenticationFactor( 1, string.Empty, 2, string.Empty)); var summoner = new Summoner { ProfileIconId = 1 }; TestMock.LeagueOfLegendsService.Setup(x => x.Summoner.GetSummonerByAccountIdAsync(It.IsAny <Region>(), It.IsAny <string>())) .ReturnsAsync(summoner) .Verifiable(); var leagueAdapter = new LeagueOfLegendsAuthenticationValidatorAdapter( TestMock.LeagueOfLegendsService.Object, TestMock.GameAuthenticationRepository.Object); TestMock.GameAuthenticationValidatorFactory.Setup(validator => validator.CreateInstance(It.IsAny <Game>())).Returns(leagueAdapter).Verifiable(); var authFactorService = new GameAuthenticationService( TestMock.GameAuthenticationGeneratorFactory.Object, TestMock.GameAuthenticationValidatorFactory.Object, TestMock.GameAuthenticationRepository.Object); // Act await authFactorService.ValidateAuthenticationAsync(new UserId(), Game.LeagueOfLegends, authFactor); // Assert TestMock.GameAuthenticationValidatorFactory.Verify(validator => validator.CreateInstance(It.IsAny <Game>()), Times.Once); }