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) }); }
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); }