예제 #1
0
        public async void detail_id_is_lesser_than_one_should_redirect_to_home_index()
        {
            //arrange
            var appService = new Mock <IAppService>();

            //act
            var sut = new AppControllerBuilder().WithAppService(appService.Object)
                      .Build();

            var view = await sut.Detail(0) as RedirectResult;

            //assert
            Assert.NotNull(view);
            Assert.AreEqual(view.Url, "/");

            sut.AssertGetAttribute(ActionNameDetail, new[] { typeof(int) });
        }
예제 #2
0
        public async void detail_id_is_greater_than_zero_should_return_app_model()
        {
            //arrange
            var appService = new Mock <IAppService>();

            appService.Setup(x => x.Get(1)).Returns(() => Task.FromResult(new App {
                Id = 1, Tokens = new List <Token>(), Url = "url"
            }));

            //act
            var sut = new AppControllerBuilder().WithAppService(appService.Object)
                      .Build();

            var view = await sut.Detail(1) as ViewResult;

            //assert
            Assert.NotNull(view);
            Assert.NotNull(view.Model);

            sut.AssertGetAttribute(ActionNameDetail, new[] { typeof(int) });
            appService.Verify(x => x.Get(1), Times.Once);
        }