예제 #1
0
        public void MatchingRuleHasTransientLifetime()
        {
            TagAttributeMatchingRuleData ruleData     = new TagAttributeMatchingRuleData("RuleName", "TAg");
            TypeRegistration             registration = ruleData.GetRegistrations("").First();

            Assert.AreEqual(TypeRegistrationLifetime.Transient, registration.Lifetime);
        }
예제 #2
0
        /// <summary>
        /// Returs the represented <see cref="TagAttributeMatchingRuleData"/> instance.
        /// </summary>
        /// <returns>A newly created <see cref="TagAttributeMatchingRuleData"/> instance.</returns>
        public override MatchingRuleData GetConfigurationData()
        {
            TagAttributeMatchingRuleData ruleData = new TagAttributeMatchingRuleData(Name, Match);

            ruleData.IgnoreCase = IgnoreCase;

            return(ruleData);
        }
예제 #3
0
        public void CanSerializeTypeMatchingRule()
        {
            TagAttributeMatchingRuleData tagAttributeMatchingRule = new TagAttributeMatchingRuleData("RuleName", "Tag");

            tagAttributeMatchingRule.IgnoreCase = true;

            TagAttributeMatchingRuleData deserializedRule = SerializeAndDeserializeMatchingRule(tagAttributeMatchingRule) as TagAttributeMatchingRuleData;

            Assert.IsNotNull(deserializedRule);
            Assert.AreEqual(tagAttributeMatchingRule.Name, deserializedRule.Name);
            Assert.AreEqual(tagAttributeMatchingRule.IgnoreCase, deserializedRule.IgnoreCase);
            Assert.AreEqual(tagAttributeMatchingRule.Match, deserializedRule.Match);
        }
        public void MatchingRuleHasTransientLifetime()
        {
            TagAttributeMatchingRuleData ruleData = new TagAttributeMatchingRuleData("RuleName", "TAg");

            using (var container = new UnityContainer())
            {
                ruleData.ConfigureContainer(container, "-test");
                var registration = container.Registrations.Single(r => r.Name == "RuleName-test");
                Assert.AreSame(typeof(IMatchingRule), registration.RegisteredType);
                Assert.AreSame(typeof(TagAttributeMatchingRule), registration.MappedToType);
                Assert.AreSame(typeof(TransientLifetimeManager), registration.LifetimeManagerType);
            }
        }
예제 #5
0
        public void CanCreateTagAttributeMatchingRuleNodeFromData()
        {
            TagAttributeMatchingRuleData ruleData = new TagAttributeMatchingRuleData();

            ruleData.Name       = "matching rule name";
            ruleData.Match      = "TagToMatch";
            ruleData.IgnoreCase = false;

            TagAttributeMatchingRuleNode ruleNode = new TagAttributeMatchingRuleNode(ruleData);

            Assert.AreEqual(ruleData.Name, ruleNode.Name);
            Assert.AreEqual(ruleData.Match, ruleNode.Match);
            Assert.AreEqual(ruleData.IgnoreCase, ruleNode.IgnoreCase);
        }
예제 #6
0
        public void CanCreateRuleDataFromTagAttributeMatchingRuleNode()
        {
            TagAttributeMatchingRuleNode ruleNode = new TagAttributeMatchingRuleNode();

            ruleNode.Name       = "matching rule name";
            ruleNode.Match      = "TagToMatch";
            ruleNode.IgnoreCase = false;

            TagAttributeMatchingRuleData ruleData = ruleNode.GetConfigurationData() as TagAttributeMatchingRuleData;

            Assert.IsNotNull(ruleData);
            Assert.AreEqual(ruleNode.Name, ruleData.Name);
            Assert.AreEqual(ruleNode.Match, ruleData.Match);
            Assert.AreEqual(ruleNode.IgnoreCase, ruleData.IgnoreCase);
        }
예제 #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TagAttributeMatchingRuleNode"/> class for representing a <see cref="TagAttributeMatchingRuleData"/> instance.
 /// </summary>
 /// <param name="ruleData">The <see cref="TagAttributeMatchingRuleData"/> to represent.</param>
 public TagAttributeMatchingRuleNode(TagAttributeMatchingRuleData ruleData)
     : base(ruleData)
 {
     tagToMatch = ruleData.Match;
     ignoreCase = ruleData.IgnoreCase;
 }