Esempio n. 1
0
        public async void should_Tag_check_word_for_null()
        {
            //arrange
            var wordRepository = new Mock<IRepository<Word>>();
            wordRepository.Setup(x => x.FindOne(It.IsAny<Expression<Func<Word, bool>>>())).Returns((Word)null);

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

            var resultKey = await sut.Tag("key", "tagName");

            //assert
            Assert.AreEqual(false, resultKey);
        }
Esempio n. 2
0
        public async void should_Tag_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.Tag("key", "tagName");

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

            wordRepository.Verify(x => x.Update(It.IsAny<Word>()), Times.Once);
            wordRepository.Verify(x => x.SaveChanges(), Times.Once);
        }
Esempio n. 3
0
        public async void should_Tag_check_stringIsNullOrEmpty()
        {
            //arrange
            var wordRepository = new Mock<IRepository<Word>>();
            
            //act
            var sut = new WordServiceBuilder().WithWordRepository(wordRepository.Object).Build();

            var resultKey = await sut.Tag(string.Empty, "tagName");
            var resulttagName = await sut.Tag("key", string.Empty);

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