public async void create_token_should_return_true_if_app_is_exist()
        {
            //arrange
            var validModel = new TokenModel {
                AppId = 1, Token = "token"
            };

            var appRepository   = new Mock <IRepository <App> >();
            var tokenRepository = new Mock <IRepository <Token> >();

            appRepository.Setup(x => x.Any(It.IsAny <Expression <Func <App, bool> > >())).Returns(true);

            tokenRepository.Setup(x => x.Create(It.IsAny <Token>())).Returns(new Token {
                Id = 1
            });
            tokenRepository.Setup(x => x.SaveChanges()).Returns(true);

            //act
            var sut = new AppServiceBuilder().WithAppRepository(appRepository.Object)
                      .WithTokenRepository(tokenRepository.Object)
                      .Build();
            var result = await sut.CreateToken(validModel);

            //assert
            Assert.IsTrue(result);
            Assert.IsAssignableFrom <bool>(result);
            Assert.IsInstanceOf <IAppService>(sut);

            appRepository.Verify(x => x.Any(It.IsAny <Expression <Func <App, bool> > >()), Times.Once);
            tokenRepository.Verify(x => x.Create(It.IsAny <Token>()), Times.Once);
            tokenRepository.Verify(x => x.SaveChanges(), Times.AtLeastOnce);
        }
        public async void create_token_should_return_true_if_token_model_is_valid()
        {
            //arrange
            var validModel = new TokenModel {
                AppId = 1, Token = "token"
            };
            var appEntity = new App {
                Id = 1, Name = "testApp", Url = "test.com", UserEmail = "*****@*****.**"
            };

            var appRepository   = new Mock <IRepository <App> >();
            var tokenRepository = new Mock <IRepository <Token> >();

            appRepository.Setup(x => x.Any(It.IsAny <Expression <Func <App, bool> > >())).Returns(true);

            tokenRepository.Setup(x => x.Create(It.IsAny <Token>())).Returns(new Token {
                Id = 1
            });
            tokenRepository.Setup(x => x.SaveChanges()).Returns(true);

            //act
            var sut = new AppServiceBuilder().WithAppRepository(appRepository.Object)
                      .WithTokenRepository(tokenRepository.Object)
                      .Build();
            var result = await sut.CreateToken(validModel);

            //assert
            Assert.IsTrue(result);
            Assert.IsInstanceOf <IAppService>(sut);
        }
        public async void create_token_should_return_false_if_token_model_is_invalid()
        {
            //arrange
            var invalidModel = new TokenModel();

            //act
            var sut    = new AppServiceBuilder().Build();
            var result = await sut.CreateToken(invalidModel);

            //assert
            Assert.IsFalse(result);
            Assert.IsInstanceOf <IAppService>(sut);
        }