Пример #1
0
        public async void should_translate_check_for_translationProperty_exists()
        {
            //arrange
            var wordRepository = new Mock<IRepository<Word>>();
            wordRepository.Setup(x => x.FindOne(It.IsAny<Expression<Func<Word, bool>>>())).Returns(new Word());
            //act
            var sut = new WordServiceBuilder().WithWordRepository(wordRepository.Object).Build();

            var resultKey = await sut.Translate("key", "not existing language", "translation");

            //assert
            Assert.AreEqual(false, resultKey);
        }
Пример #2
0
        public async void should_translate_call_update_and_savechanges()
        {
            //arrange
            var wordRepository = new Mock<IRepository<Word>>();
            wordRepository.Setup(x => x.FindOne(It.IsAny<Expression<Func<Word, bool>>>()))
                          .Returns(new Word());

            wordRepository.Setup(x => x.Update(It.IsAny<Word>()))
                          .Returns(new Word());

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

            //act
            var sut = new WordServiceBuilder().WithWordRepository(wordRepository.Object).Build();

            var resultKey = await sut.Translate("key", "EN", "translation");

            //assert
            Assert.AreEqual(true, resultKey);

            wordRepository.Verify(x=>x.Update(It.IsAny<Word>()), Times.Once);
            wordRepository.Verify(x=>x.SaveChanges(), Times.Once);
        }
Пример #3
0
        public async void should_translate_check_stringIsNullOrEmpty()
        {
            //arrange
            var wordRepository = new Mock<IRepository<Word>>();
            
            //act
            var sut = new WordServiceBuilder().WithWordRepository(wordRepository.Object).Build();

            var resultKey = await sut.Translate(string.Empty, "language", "translation");
            var resultLanguage = await sut.Translate("key", string.Empty, "translation");
            var resultTranslation = await sut.Translate("key", "language", string.Empty);

            //assert
            Assert.AreEqual(false, resultKey);
            Assert.AreEqual(false, resultLanguage);
            Assert.AreEqual(false, resultTranslation);
        }