public async Task Add_RuturnsNegativeOne_IfWordExists_WS() { //Arrange string value = "value"; int Id = 8; int expected = -1; IQueryable <Word> words = new List <Word> { new Word { Id = Id, Value = value, LanguageId = Id } }.AsQueryable <Word>(); WordModel word = new WordModel { Value = value, LanguageId = Id }; var mockSet = GenerateMockDbSet <Word>(words); _words.Setup(w => w.GetAll()).Returns(mockSet.Object); //Act int actual = await _service.AddAsync(word); //Assert _factory.Verify(f => f.GetUnitOfWork(), Times.Exactly(2)); _uow.Verify(u => u.WordRepository, Times.Once); _words.Verify(w => w.GetAll(), Times.Once); Assert.AreEqual(actual, expected); }