public void AddingRegion() { var list = new List <Region>(); var mockRepo = new Mock <IDeletableEntityRepository <Region> >(); mockRepo.Setup(x => x.AllAsNoTracking()).Returns(list.AsQueryable()); mockRepo.Setup(x => x.AddAsync(It.IsAny <Region>())); var service = new RegionsService(mockRepo.Object); var region = new Region { Id = 1, Name = "Sofia", }; list.Add(region); var expected = new List <KeyValuePair <string, string> >() { new KeyValuePair <string, string>("1", "Sofia"), }; Assert.Equal(expected, service.GetAllAsKeyValuePairs()); }