コード例 #1
0
        public void TextFileDALCommitTest()
        {
            var mock = new Mock <IRepository>();
            var dal  = new TextFileDAL(mock.Object);


            dal.CommitChanges();
            mock.Verify(x => x.CommitChanges(), Times.Exactly(1));
        }
コード例 #2
0
        public void TextFileDALQueryTest()
        {
            var mock = new Mock <IRepository>();

            mock.Setup(x => x.GetTypeRepostiory <string>()).Returns(new List <string>()
            {
                "foo", "bar"
            });
            var dal = new TextFileDAL(mock.Object);
            var res = dal.Fetch <string>(x => x.Contains("ar"));

            Assert.IsTrue(res.Count == 1 && res[0] == "bar");
        }
コード例 #3
0
        public void TextFileDALRemoveTest()
        {
            var mock = new Mock <IRepository>();

            mock.Setup(x => x.GetTypeRepostiory <string>()).Returns(new List <string>()
            {
                "foo", "bar"
            });
            var dal = new TextFileDAL(mock.Object);

            dal.Remove <string>("foo");

            var newRep = new List <string>()
            {
                "bar"
            };

            mock.Verify(x => x.SetTypeRepository <string>(newRep));
        }