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

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

            var helper = new UnserializableTypeHelper(mock.Object);

            helper.AddUnserializableType(typeof(double));

            mock.Verify(x => x.Create <UnserializableType>(It.IsAny <UnserializableType>()), Times.Once);
        }
示例#2
0
        public void DAL_Helper_Test_IsUnserializable_Returns_False_When_Not_In_DB()
        {
            var mock = new Mock <IDAL>();

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

            var helper = new UnserializableTypeHelper(mock.Object);

            var result = helper.IsUnserializable(typeof(double));

            Assert.IsTrue(result == false);
        }
示例#3
0
        public void DAL_Helper_Adding_Type_Commits_Changes()
        {
            var mock = new Mock <IDAL>();

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


            var helper = new UnserializableTypeHelper(mock.Object);

            helper.AddUnserializableType(typeof(double));

            mock.Verify(x => x.CommitChanges(), Times.AtLeastOnce);
        }
示例#4
0
        public void DAL_Helper_Test_Adding_Type_Does_Not_Add_To_DB_When_Already_Exists()
        {
            var mock = new Mock <IDAL>();

            mock.Setup(x => x.Fetch <UnserializableType>(It.IsAny <Func <UnserializableType, bool> >()))
            .Returns(new List <UnserializableType>()
            {
                new UnserializableType(typeof(double))
            });


            var helper = new UnserializableTypeHelper(mock.Object);

            helper.AddUnserializableType(typeof(double));

            mock.Verify(x => x.Create <UnserializableType>(It.IsAny <UnserializableType>()), Times.Never);
        }