public void TestIsInUse()
        {
            Mock<ISummitDao> summitDaoMock = new Mock<ISummitDao>();
            summitDaoMock.Setup(x => x.IsInUse(It.IsAny<Summit>())).Returns(true);

            Summit summit = new Summit();

            ISummitService summitService = new SummitService(summitDaoMock.Object);
            bool isInUse = summitService.IsInUse(summit);

            Assert.IsTrue(isInUse);
            summitDaoMock.Verify(x=>x.IsInUse(summit), Times.Once);
        }
        public void TestGetAll()
        {
            Mock<ISummitDao> summitDaoMock = new Mock<ISummitDao>();
            summitDaoMock.Setup(x => x.GetAllIn(It.IsAny<SummitGroup>())).Returns(new List<Summit> {new Summit{Name = "Gipfel 1"}});

            SummitGroup fakeGroup = new SummitGroup {Name = "Gruppe 1"};

            ISummitService summitService = new SummitService(summitDaoMock.Object);
            IList<Summit> summitsInGroup = summitService.GetAllIn(fakeGroup);
            Assert.AreEqual(1, summitsInGroup.Count);

            summitDaoMock.Verify(x=>x.GetAllIn(It.Is<SummitGroup>(y=>y.Name == fakeGroup.Name)));
        }
        public void TestCreate()
        {
            Mock<ISummitDao> summitDaoMock = new Mock<ISummitDao>();
            summitDaoMock.Setup(x => x.Create(It.IsAny<SummitGroup>(), It.IsAny<Summit>()));

            string groupName = "Gruppe 1";
            string summitName = "Gipfel 1";
            SummitGroup fakeGroup = new SummitGroup { Name = groupName };

            ISummitService summitService = new SummitService(summitDaoMock.Object);
            summitService.Create(fakeGroup, summitName);

            summitDaoMock.Verify(x=>x.Create(It.Is<SummitGroup>(y=>y.Name == groupName), It.Is<Summit>(y=>y.Name == summitName)), Times.Once);
        }
        public void TestDelete(bool isInUse)
        {
            Mock<ISummitDao> summitDaoMock = new Mock<ISummitDao>();
            summitDaoMock.Setup(x => x.IsInUse(It.IsAny<Summit>())).Returns(isInUse);
            summitDaoMock.Setup(x => x.Delete(It.IsAny<Summit>()));

            Summit summit = new Summit();

            ISummitService summitService = new SummitService(summitDaoMock.Object);
            summitService.Delete(summit);

            summitDaoMock.Verify(x => x.IsInUse(summit), Times.Once);
            summitDaoMock.Verify(x => x.Delete(summit), Times.Once);
        }
 public void TestSaveNull()
 {
     ISummitService summitService = new SummitService(null);
     Assert.Throws<ArgumentNullException>(() => summitService.Save(null));
 }
        public void TestSave()
        {
            Mock<ISummitDao> summitDaoMock = new Mock<ISummitDao>();
            summitDaoMock.Setup(x => x.Save(It.IsAny<Summit>()));

            Summit summit = new Summit();

            ISummitService summitService = new SummitService(summitDaoMock.Object);
            summitService.Save(summit);

            summitDaoMock.Verify(x=>x.Save(summit),Times.Once);
        }