Пример #1
0
        public void DAL_Helper_Test_No_Id_Found_Returns_Null()
        {
            var mock    = new Mock <IDAL>();
            var queryId = Guid.NewGuid();
            var methods = new List <RecordedMethod>()
            {
                new RecordedMethod(Guid.NewGuid()), new RecordedMethod(Guid.NewGuid())
            };

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

            var helper = new RecordedMethodHelper(mock.Object);
            var res    = helper.GetMethodWithId(queryId);

            Assert.IsTrue(res == null);
        }
Пример #2
0
        public void DAL_Helper_Test_Specific_ID_Is_Returned()
        {
            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);
            var res    = helper.GetMethodWithId(queryId);

            Assert.IsTrue(res.Identifier == queryId);
        }