コード例 #1
0
        public void TestIsInUse()
        {
            Mock<ISummitGroupDao> summitGroupDaoMock = new Mock<ISummitGroupDao>();
            summitGroupDaoMock.Setup(x => x.IsInUse(It.IsAny<SummitGroup>())).Returns(true);

            SummitGroup summitGroup = new SummitGroup();

            ISummitGroupService summitGroupService = new SummitGroupService(summitGroupDaoMock.Object);
            bool isInUse = summitGroupService.IsInUse(summitGroup);

            Assert.IsTrue(isInUse);
            summitGroupDaoMock.Verify(x=>x.IsInUse(summitGroup), Times.Once);
        }
コード例 #2
0
        public void TestGetAll()
        {
            Mock<ISummitGroupDao> summitGroupDaoMock = new Mock<ISummitGroupDao>();
            summitGroupDaoMock.Setup(x => x.GetAllIn(It.IsAny<Area>())).Returns(new List<SummitGroup> {new SummitGroup{Name = "Gruppe 1"}});

            Area fakeArea = new Area() {Name = "Gebiet 1"};

            ISummitGroupService summitGroupService = new SummitGroupService(summitGroupDaoMock.Object);
            IList<SummitGroup> groupsInArea = summitGroupService.GetAllIn(fakeArea);
            Assert.AreEqual(1, groupsInArea.Count);

            summitGroupDaoMock.Verify(x=>x.GetAllIn(It.Is<Area>(y=>y.Name == fakeArea.Name)));
        }
コード例 #3
0
        public void TestCreate()
        {
            Mock<ISummitGroupDao> summitGroupDaoMock = new Mock<ISummitGroupDao>();
            summitGroupDaoMock.Setup(x => x.Create(It.IsAny<Area>(), It.IsAny<SummitGroup>()));

            string areaName = "Gebiet 1";
            string groupName = "Gruppe 1";
            Area fakeArea = new Area() { Name = areaName };

            ISummitGroupService summitGroupService = new SummitGroupService(summitGroupDaoMock.Object);
            summitGroupService.Create(fakeArea, groupName);

            summitGroupDaoMock.Verify(x=>x.Create(It.Is<Area>(y=>y.Name == areaName), It.Is<SummitGroup>(y=>y.Name == groupName)), Times.Once);
        }
コード例 #4
0
        public void TestDelete(bool isInUse)
        {
            Mock<ISummitGroupDao> summitGroupDaoMock = new Mock<ISummitGroupDao>();
            summitGroupDaoMock.Setup(x => x.IsInUse(It.IsAny<SummitGroup>())).Returns(isInUse);
            summitGroupDaoMock.Setup(x => x.Delete(It.IsAny<SummitGroup>()));

            SummitGroup summitGroup = new SummitGroup();

            ISummitGroupService summitGroupService = new SummitGroupService(summitGroupDaoMock.Object);
            summitGroupService.Delete(summitGroup);

            summitGroupDaoMock.Verify(x => x.IsInUse(summitGroup), Times.Once);
            summitGroupDaoMock.Verify(x => x.Delete(summitGroup), Times.Once);
        }
コード例 #5
0
 public void TestSaveNull()
 {
     ISummitGroupService summitGroupService = new SummitGroupService(null);
     Assert.Throws<ArgumentNullException>(() => summitGroupService.Save(null));
 }
コード例 #6
0
        public void TestSave()
        {
            Mock<ISummitGroupDao> summitGroupDaoMock = new Mock<ISummitGroupDao>();
            summitGroupDaoMock.Setup(x => x.Save(It.IsAny<SummitGroup>()));

            SummitGroup summitGroup = new SummitGroup();

            ISummitGroupService summitGroupService = new SummitGroupService(summitGroupDaoMock.Object);
            summitGroupService.Save(summitGroup);

            summitGroupDaoMock.Verify(x=>x.Save(summitGroup), Times.Once);
        }