示例#1
0
        public async void detail_id_is_null_or_empty_should_return_key_model()
        {
            //arrange

            //act
            var sut = new WordControllerBuilder().Build();
            var view = await sut.Detail("") as RedirectResult;

            //assert
            Assert.NotNull(view);
            Assert.AreEqual(view.Url, "/");
            sut.AssertGetAttribute(ActionNameDetail, new[] { typeof(string) });

        }
示例#2
0
        public async void detail_id_is_not_null_should_return_key_model()
        {
            //arrange
            var wordService = new Mock<IWordService>();
            wordService.Setup(x => x.GetByKey("key")).Returns(() => Task.FromResult(new Word()));

            //act
            var sut = new WordControllerBuilder().WithWordService(wordService.Object)
                                                 .Build();

            var view = await sut.Detail("key") as ViewResult;
            var model = view.Model as WordModel;

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

            sut.AssertGetAttribute(ActionNameDetail, new[] { typeof(string) });
            wordService.Verify(x => x.GetByKey("key"), Times.Once);
        }