public void TestGetAll()
        {
            Mock<ICountryDao> countryDaoMock = new Mock<ICountryDao>();
            countryDaoMock.Setup(x => x.GetAll()).Returns(new List<Country> {new Country {Name = "D"}});

            ICountryService countryService = new CountryService(countryDaoMock.Object);
            IList<Country> result = countryService.GetAll();
            Assert.AreEqual(1, result.Count);
            countryDaoMock.Verify(x=>x.GetAll(), Times.Once);
        }
        public void TestCreate()
        {
            Mock<ICountryDao> countryDaoMock = new Mock<ICountryDao>();
            countryDaoMock.Setup(x => x.Create(It.IsAny<Country>()));

            string countryName = "D";

            ICountryService countryService = new CountryService(countryDaoMock.Object);
            countryService.Create(countryName);

            countryDaoMock.Verify(x=>x.Create(It.Is<Country>(y=>y.Name == countryName)));
        }
        public void TestIsInUse()
        {
            Mock<ICountryDao> countryDaoMock = new Mock<ICountryDao>();
            countryDaoMock.Setup(x => x.IsInUse(It.IsAny<Country>())).Returns(true);

            Country country = new Country();

            ICountryService countryService = new CountryService(countryDaoMock.Object);
            bool isInUse = countryService.IsInUse(country);

            Assert.IsTrue(isInUse);
            countryDaoMock.Verify(x=>x.IsInUse(country), Times.Once);
        }
        public void TestDelete(bool isInUse)
        {
            Mock<ICountryDao> countryDaoMock = new Mock<ICountryDao>();
            countryDaoMock.Setup(x => x.IsInUse(It.IsAny<Country>())).Returns(isInUse);
            countryDaoMock.Setup(x => x.Delete(It.IsAny<Country>()));

            Country country = new Country();

            ICountryService countryService = new CountryService(countryDaoMock.Object);
            countryService.Delete(country);

            countryDaoMock.Verify(x => x.IsInUse(country), Times.Once);
            countryDaoMock.Verify(x => x.Delete(country), Times.Once);
        }
        public void TestSave()
        {
            Mock<ICountryDao> countryDaoMock = new Mock<ICountryDao>();
            countryDaoMock.Setup(x => x.Save(It.IsAny<Country>()));

            Country country = new Country();

            ICountryService countryService = new CountryService(countryDaoMock.Object);
            countryService.Save(country);

            countryDaoMock.Verify(x=>x.Save(country), Times.Once);

        }
 public void TestSaveNull()
 {
     ICountryService countryService = new CountryService(null);
     NUnit.Framework.Assert.Throws<ArgumentNullException>(()=>countryService.Save(null));
 }