Exemple #1
0
        public async Task Save_ShouldThrowArgumentNullException_WhenTokenUserIsNull()
        {
            TokenUser expectedTokenUser = new TokenUser()
            {
                Id = "TestId"
            };

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

            mockTokenUserRepository.Setup(x => x.Save(It.IsAny <TokenUser>())).Returns(Task.FromResult(true));

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

            await Assert.ThrowsAsync <ArgumentNullException>(() => sut.Save(null));
        }
Exemple #2
0
        public async Task Save_ShouldReturn_WhenTokenUserUsValid()
        {
            TokenUser expectedTokenUser = new TokenUser()
            {
                Id = "TestId"
            };

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

            mockTokenUserRepository.Setup(x => x.Save(It.IsAny <TokenUser>())).Returns(Task.FromResult(true));

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

            mockTokenUserRepository.Verify(x => x.Save(expectedTokenUser), Times.Once());
        }