public void TestDelete(bool isInUse)
        {
            Mock<IVariationDao> variationDaoMock = new Mock<IVariationDao>();
            variationDaoMock.Setup(x => x.IsInUse(It.IsAny<Variation>())).Returns(isInUse);
            variationDaoMock.Setup(x => x.Delete(It.IsAny<Variation>()));

            Variation variation = new Variation();

            IVariationService service = new VariationService(variationDaoMock.Object);
            service.Delete(variation);

            variationDaoMock.Verify(x => x.IsInUse(variation), Times.Once);
            variationDaoMock.Verify(x => x.Delete(variation), Times.Once);
        }
        public void TestCreate()
        {
            Mock<IVariationDao> variationDaoMock = new Mock<IVariationDao>();
            variationDaoMock.Setup(x => x.Create(It.IsAny<Variation>(), It.IsAny<Route>(), It.IsAny<DifficultyLevel>()));

            Route fakeRoute = new Route();
            DifficultyLevel fakeLevel = new DifficultyLevel();

            IVariationService variationService = new VariationService(variationDaoMock.Object);
            variationService.Create(fakeRoute, fakeLevel, "Variation 1");

            variationDaoMock.Verify(
                x => x.Create(It.Is<Variation>(y => y.Name == "Variation 1"), fakeRoute, fakeLevel), Times.Once);
        }
        public void TestChangeDifficultyLevel()
        {
            Mock<IVariationDao> variationDaoMock = new Mock<IVariationDao>();
            variationDaoMock.Setup(x => x.ChangeDifficultyLevel(It.IsAny<Variation>(), It.IsAny<DifficultyLevel>()));

            Variation variation = new Variation();
            DifficultyLevel newLevel = new DifficultyLevel();

            IVariationService variationService = new VariationService(variationDaoMock.Object);
            variationService.ChangeDifficultyLevel(variation, newLevel);

            variationDaoMock.Verify(x => x.ChangeDifficultyLevel(variation, newLevel), Times.Once);
        }
        public void TestSave()
        {
            Mock<IVariationDao> variationDaoMock = new Mock<IVariationDao>();
            variationDaoMock.Setup(x => x.Save(It.IsAny<Variation>()));

            Variation variation = new Variation();

            IVariationService variationService = new VariationService(variationDaoMock.Object);
            variationService.Save(variation);

            variationDaoMock.Verify(x => x.Save(variation), Times.Once);
        }
        public void TestIsInUse()
        {
            Mock<IVariationDao> variationDaoMock = new Mock<IVariationDao>();
            variationDaoMock.Setup(x => x.IsInUse(It.IsAny<Variation>())).Returns(true);

            Variation variation = new Variation();

            IVariationService service = new VariationService(variationDaoMock.Object);
            bool isInUse = service.IsInUse(variation);

            Assert.IsTrue(isInUse);
            variationDaoMock.Verify(x => x.IsInUse(variation), Times.Once);
        }
        public void TestGetAllOnRoute()
        {
            Mock<IVariationDao> variationDaoMock = new Mock<IVariationDao>();
            variationDaoMock.Setup(x => x.GetAllOn(It.IsAny<Route>()))
                .Returns(new List<Variation> {new Variation {Name = "Gebiet 1"}});

            Route fakeRoute = new Route {Name = "D"};

            IVariationService variationService = new VariationService(variationDaoMock.Object);
            IList<Variation> variationsOnRoute = variationService.GetAllOn(fakeRoute);
            Assert.AreEqual(1, variationsOnRoute.Count);

            variationDaoMock.Verify(x => x.GetAllOn(fakeRoute), Times.Once);
        }