Beispiel #1
0
        public void SetValues()
        {
            var construction = ObjectMother.GetConstruction();
            var method       = ObjectMother.GetMethodInfo();
            var pointcut     = ObjectMother.GetPointcut();

            var builder = new AdviceBuilder()
                          .SetConstruction(construction)
                          .SetMethod(method)
                          .SetName("name")
                          .SetRole("role")
                          .SetExecution(AdviceExecution.Around)
                          .SetScope(AdviceScope.Static)
                          .SetPriority(1)
                          .AddPointcut(pointcut);

            var result = builder.Build();

            Assert.That(result.Construction, Is.SameAs(construction));
            Assert.That(result.Method, Is.SameAs(method));
            Assert.That(result.Name, Is.EqualTo("name"));
            Assert.That(result.Role, Is.EqualTo("role"));
            Assert.That(result.Execution, Is.EqualTo(AdviceExecution.Around));
            Assert.That(result.Scope, Is.EqualTo(AdviceScope.Static));
            Assert.That(result.Priority, Is.EqualTo(1));
            Assert.That(result.Pointcuts, Has.Member(pointcut));
        }
Beispiel #2
0
        private void CheckThrowForMissing(
            string missingMember,
            IAspectConstruction construction = null,
            MethodInfo method         = null,
            AdviceExecution execution = AdviceExecution.Undefined,
            AdviceScope scope         = AdviceScope.Undefined)
        {
            var builder = new AdviceBuilder()
                          .SetConstruction(construction)
                          .SetMethod(method)
                          .SetExecution(execution)
                          .SetScope(scope);
            var message = string.Format("Cannot build advice without having set its {0}.", missingMember);

            Assert.That(() => builder.Build(), Throws.InvalidOperationException.With.Message.EqualTo(message));
        }
Beispiel #3
0
        public void Copy()
        {
            var builder = new AdviceBuilder()
                          .SetConstruction(ObjectMother.GetConstruction())
                          .SetMethod(ObjectMother.GetMethodInfo())
                          .SetName("name")
                          .SetRole("name")
                          .SetExecution(AdviceExecution.Around)
                          .SetScope(AdviceScope.Static)
                          .SetPriority(1)
                          .AddPointcut(ObjectMother.GetPointcut());

            var copiedAdvice   = builder.Copy().Build();
            var originalAdvice = builder.Build();

            Assert.That(copiedAdvice.Construction, Is.SameAs(originalAdvice.Construction));
            Assert.That(copiedAdvice.Method, Is.SameAs(originalAdvice.Method));
            Assert.That(copiedAdvice.Name, Is.EqualTo(originalAdvice.Name));
            Assert.That(copiedAdvice.Role, Is.EqualTo(originalAdvice.Role));
            Assert.That(copiedAdvice.Execution, Is.EqualTo(originalAdvice.Execution));
            Assert.That(copiedAdvice.Scope, Is.EqualTo(originalAdvice.Scope));
            Assert.That(copiedAdvice.Priority, Is.EqualTo(originalAdvice.Priority));
            Assert.That(copiedAdvice.Pointcuts, Is.EquivalentTo(originalAdvice.Pointcuts));
        }