Beispiel #1
0
        public async Task Exists_ShouldThrowArgumentNullException_WhenIdIsInvalid(string id)
        {
            TokenUser expectedTokenUser = new TokenUser()
            {
                Id = "TestId"
            };

            Mock <ILogger <TokenUserData> > mockLogger = new Mock <ILogger <TokenUserData> >();
            Mock <ITokenUserRepository>     mockTokenUserRepository = new Mock <ITokenUserRepository>();

            mockTokenUserRepository.Setup(x => x.Load(It.IsAny <string>())).Returns(Task.FromResult(expectedTokenUser));

            TokenUserData sut = new TokenUserData(mockLogger.Object, mockTokenUserRepository.Object);

            await Assert.ThrowsAsync <ArgumentNullException>(() => sut.Exists(id));
        }
Beispiel #2
0
        public async Task Exists_ShouldReturnTrue_WhenTokenUserIsFoundAndIdsMatch()
        {
            TokenUser expectedTokenUser = new TokenUser()
            {
                Id = "TestId"
            };

            Mock <ILogger <TokenUserData> > mockLogger = new Mock <ILogger <TokenUserData> >();
            Mock <ITokenUserRepository>     mockTokenUserRepository = new Mock <ITokenUserRepository>();

            mockTokenUserRepository.Setup(x => x.Load(It.IsAny <string>())).Returns(Task.FromResult(expectedTokenUser));

            TokenUserData sut = new TokenUserData(mockLogger.Object, mockTokenUserRepository.Object);

            bool exists = await sut.Exists(expectedTokenUser.Id);

            mockTokenUserRepository.Verify(x => x.Load(expectedTokenUser.Id), Times.Once());
            Assert.True(exists);
        }