public void ParameterMustBeInteger()
        {
            var mockProperty = new Mock<IPropertyInfo>();
            mockProperty.Setup(mp => mp.Type).Returns(typeof(string));
            mockProperty.Setup(mp => mp.Name).Returns("Name");
            var mockIdProperty = new Mock<IPropertyInfo>();
            mockIdProperty.Setup(mp => mp.Type).Returns(typeof(string));
            mockIdProperty.Setup(mp => mp.Name).Returns("Id");

            var newRule = new NoDuplicates(mockProperty.Object, mockIdProperty.Object, MockFoundNone);
            Assert.Fail();
        }
        public void MustHaveFactory()
        {
            var mockProperty = new Mock<IPropertyInfo>();
            mockProperty.Setup(mp => mp.Type).Returns(typeof(string));
            mockProperty.Setup(mp => mp.Name).Returns("Name");
            var mockIdProperty = new Mock<IPropertyInfo>();
            mockIdProperty.Setup(mp => mp.Type).Returns(typeof(int));
            mockIdProperty.Setup(mp => mp.Name).Returns("Id");

            var newRule = new NoDuplicates(mockProperty.Object, mockIdProperty.Object, null);
            Assert.Fail();
        }
        public void AcceptsValidParameters()
        {
            var mockProperty = new Mock<IPropertyInfo>();
            mockProperty.Setup(mp => mp.Type).Returns(typeof(string));
            mockProperty.Setup(mp => mp.Name).Returns("Name");
            var mockIdProperty = new Mock<IPropertyInfo>();
            mockIdProperty.Setup(mp => mp.Type).Returns(typeof(int));
            mockIdProperty.Setup(mp => mp.Name).Returns("Id");

            var newRule = new NoDuplicates(mockProperty.Object, mockIdProperty.Object, MockFoundNone);

            Assert.IsNotNull(newRule);
        }
        public void NoErrorIfNotFound()
        {
            var mockProperty = new Mock<IPropertyInfo>();
            mockProperty.Setup(mp => mp.Type).Returns(typeof(string));
            mockProperty.Setup(mp => mp.Name).Returns("Name");
            var mockIdProperty = new Mock<IPropertyInfo>();
            mockIdProperty.Setup(mp => mp.Type).Returns(typeof(int));
            mockIdProperty.Setup(mp => mp.Name).Returns("Id");

            var newRule = new NoDuplicates(mockProperty.Object, mockIdProperty.Object, MockFoundNone);

            var targetObject = new Mock<IActivityEdit>();
            targetObject.Setup(a => a.IsNew).Returns(true);
            var ruleContext = new RuleContext(null, newRule, targetObject.Object, new Dictionary<IPropertyInfo, object> { { mockProperty.Object, "FoundString" }, {mockIdProperty.Object, 1} });

            var ruleInterface = (IBusinessRule) newRule;

            ruleInterface.Execute(ruleContext);

            Assert.AreEqual(0, ruleContext.Results.Count);
        }