コード例 #1
0
        public void DeleteShoulCallSave()
        {
            var savechangesCounter = 0;
            var areasRepositoryFake = new Mock<IRepository<Area>>();

            var dataFake = new Mock<IQmsData>();
            dataFake.Setup(x => x.Areas).Returns(areasRepositoryFake.Object);
            dataFake.Setup(x => x.SaveChanges()).Callback(() => savechangesCounter++);
            var service = new AreasServices(dataFake.Object);

            service.Delete(1);

            dataFake.Verify(x => x.SaveChanges());
        }
コード例 #2
0
        public void DeleteShoulCallDelete()
        {
            var areasRepositoryFake = new Mock<IRepository<Area>>();

            var dataFake = new Mock<IQmsData>();
            dataFake.Setup(x => x.Areas).Returns(areasRepositoryFake.Object);
            var service = new AreasServices(dataFake.Object);

            service.Delete(1);

            areasRepositoryFake.Verify(x => x.Delete(1));
        }