示例#1
0
        public void DAL_Helper_Test_Adding_Method_Adds_To_DB()
        {
            var mock = new Mock <IDAL>();

            mock.Setup(x => x.Fetch <RecordedMethod>(It.IsAny <Func <RecordedMethod, bool> >())).Returns(new List <RecordedMethod>());
            var helper = new RecordedMethodHelper(mock.Object);

            helper.AddRecordedMethod(new RecordedMethod(Guid.NewGuid()));
            mock.Verify(x => x.Create <RecordedMethod>(It.IsAny <RecordedMethod>()), Times.Once);
        }
示例#2
0
        public void DAL_Helper_Add_Method_Commits_Changes()
        {
            var mock    = new Mock <IDAL>();
            var queryId = Guid.NewGuid();
            var methods = new List <RecordedMethod>();

            mock.Setup(x => x.Fetch <RecordedMethod>(It.IsAny <Func <RecordedMethod, bool> >()))
            .Returns(methods);

            var helper = new RecordedMethodHelper(mock.Object);

            helper.AddRecordedMethod(new RecordedMethod(queryId));

            mock.Verify(x => x.CommitChanges(), Times.AtLeastOnce);
        }
示例#3
0
        public void DAL_Helper_Test_No_Duplicate_Id()
        {
            var mock    = new Mock <IDAL>();
            var queryId = Guid.NewGuid();
            var methods = new List <RecordedMethod>()
            {
                new RecordedMethod(queryId), new RecordedMethod(Guid.NewGuid())
            };

            mock.Setup(x => x.Fetch <RecordedMethod>(It.IsAny <Func <RecordedMethod, bool> >()))
            .Callback((Func <RecordedMethod, bool> func) =>
                      methods = methods.Where(func).ToList())
            .Returns(methods);

            var helper = new RecordedMethodHelper(mock.Object);

            helper.AddRecordedMethod(new RecordedMethod(queryId));

            mock.Verify(x => x.Remove <RecordedMethod>(It.IsAny <RecordedMethod>()), Times.Once);
        }