public async void add_keys_should_create_new_word_and_return_bool() { //arrange var validModel = new WordModel { Key = "key", Tag = "tag", Description = "desc" }; var wordService = new Mock<IWordService>(); wordService.Setup(x => x.Create(validModel)).Returns(Task.FromResult(validModel.Key)); //act var sut = new ApiControllerBuilder().WithWordService(wordService.Object) .Build(); var result = await sut.AddKeys(validModel.Key, validModel.Tag); //assert Assert.NotNull(result); Assert.NotNull(result.Data); Assert.IsAssignableFrom(typeof(bool), result.Data); sut.AssertPostAttribute(ActionNameAddKeys, new[] { typeof(string), typeof(string) }); wordService.Verify(x => x.Create(It.IsAny<WordModel>()), Times.AtLeastOnce); }
public async void add_keys_should_create_new_word_and_return_bool() { //arrange var validModel = new WordModel { Key = "key", Tag = "tag", Description = "desc" }; var wordService = new Mock <IWordService>(); wordService.Setup(x => x.Create(validModel)).Returns(Task.FromResult(validModel.Key)); //act var sut = new ApiControllerBuilder().WithWordService(wordService.Object) .Build(); var result = await sut.AddKeys(validModel.Key, validModel.Tag); //assert Assert.NotNull(result); Assert.NotNull(result.Data); Assert.IsAssignableFrom(typeof(bool), result.Data); sut.AssertPostAttribute(ActionNameAddKeys, new[] { typeof(string), typeof(string) }); wordService.Verify(x => x.Create(It.IsAny <WordModel>()), Times.AtLeastOnce); }
public async void locales_should_return_name_value_model() { //arrange var validModel = new WordModel { Key = "key", Tag = "tag", Languages = new List <LanguageModel> { new LanguageModel { Key = "tr" } }, Description = "desc" }; var list = new List <Word> { new Word { Id = 1 }, new Word { Id = 2 } }; var tagService = new Mock <ITagService>(); tagService.Setup(x => x.GetWords(validModel.Tag, 1)) .Returns(Task.FromResult(new PagedList <Word>(1, 2, 3, list))); var wordService = new Mock <IWordService>(); wordService.Setup(x => x.GetWords(1)) .Returns(Task.FromResult(new PagedList <Word>(1, 2, 3, list))); //act var sut = new ApiControllerBuilder().WithWordService(wordService.Object) .WithTagService(tagService.Object) .Build(); var result = await sut.Locales(validModel.Tag, "tr", 1); //assert Assert.NotNull(result); Assert.NotNull(result.Data); Assert.IsAssignableFrom(typeof(List <NameValueModel>), result.Data); sut.AssertGetAttribute(ActionNameLocales, new[] { typeof(string), typeof(string), typeof(int) }); wordService.Verify(x => x.GetWords(1), Times.AtMostOnce); tagService.Verify(x => x.GetWords(validModel.Tag, 1), Times.AtMostOnce); }
public async void locale_should_return_locale_model() { //arrange var wordService = new Mock <IWordService>(); wordService.Setup(x => x.GetByKey("key")) .Returns(Task.FromResult(new Word())); //act var sut = new ApiControllerBuilder().WithWordService(wordService.Object) .Build(); var result = await sut.Locale("tr", "key"); //assert Assert.NotNull(result); Assert.NotNull(result.Data); Assert.IsAssignableFrom(typeof(LocaleModel), result.Data); sut.AssertGetAttribute(ActionNameLocale, new[] { typeof(string), typeof(string) }); wordService.Verify(x => x.GetByKey("key"), Times.Once); }
public async void locale_should_return_locale_model() { //arrange var wordService = new Mock<IWordService>(); wordService.Setup(x => x.GetByKey("key")) .Returns(Task.FromResult(new Word())); //act var sut = new ApiControllerBuilder().WithWordService(wordService.Object) .Build(); var result = await sut.Locale("tr", "key"); //assert Assert.NotNull(result); Assert.NotNull(result.Data); Assert.IsAssignableFrom(typeof(LocaleModel), result.Data); sut.AssertGetAttribute(ActionNameLocale, new[] { typeof(string), typeof(string) }); wordService.Verify(x => x.GetByKey("key"), Times.Once); }
public async void locales_should_return_name_value_model() { //arrange var validModel = new WordModel { Key = "key", Tag = "tag", Languages = new List<LanguageModel> { new LanguageModel { Key="tr" } }, Description = "desc" }; var list = new List<Word> { new Word { Id = 1 }, new Word { Id = 2 } }; var tagService = new Mock<ITagService>(); tagService.Setup(x => x.GetWords(validModel.Tag, 1)) .Returns(Task.FromResult(new PagedList<Word>(1, 2, 3, list))); var wordService = new Mock<IWordService>(); wordService.Setup(x => x.GetWords(1)) .Returns(Task.FromResult(new PagedList<Word>(1, 2, 3, list))); //act var sut = new ApiControllerBuilder().WithWordService(wordService.Object) .WithTagService(tagService.Object) .Build(); var result = await sut.Locales(validModel.Tag, "tr",1); //assert Assert.NotNull(result); Assert.NotNull(result.Data); Assert.IsAssignableFrom(typeof(List<NameValueModel>), result.Data); sut.AssertGetAttribute(ActionNameLocales, new[] { typeof(string), typeof(string) ,typeof(int) }); wordService.Verify(x => x.GetWords(1), Times.AtMostOnce); tagService.Verify(x => x.GetWords(validModel.Tag,1), Times.AtMostOnce); }