示例#1
0
        public async void change_status_should_return_with_true_if_app_is_exist()
        {
            //arrange
            var appRepository = new Mock <IRepository <App> >();

            appRepository.Setup(x => x.FindOne(It.IsAny <Expression <Func <App, bool> > >(), It.IsAny <Expression <Func <App, object> > >()))
            .Returns(new App {
                Tokens = new List <Token>()
            });

            appRepository.Setup(x => x.Update(It.IsAny <App>()))
            .Returns(new App());

            appRepository.Setup(x => x.SaveChanges())
            .Returns(true);

            //act
            var sut = new AppServiceBuilder().WithAppRepository(appRepository.Object)
                      .Build();

            var result = await sut.ChangeStatus(1, true);

            //assert
            Assert.IsTrue(result);

            appRepository.Verify(x => x.FindOne(It.IsAny <Expression <Func <App, bool> > >(), It.IsAny <Expression <Func <App, object> > >()), Times.Once);
            appRepository.Verify(x => x.Update(It.IsAny <App>()), Times.Once);
            appRepository.Verify(x => x.SaveChanges(), Times.Once);
        }
示例#2
0
        public async void hange_status_should_return_with_false_if_app_is_not_exist()
        {
            //arrange
            //act
            var sut    = new AppServiceBuilder().Build();
            var result = await sut.ChangeStatus(0, true);

            //assert
            Assert.IsFalse(result);
        }