Ejemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void staticFieldsAreAllowed() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void StaticFieldsAreAllowed()
        {
            // Given
            FieldInjections injections = new FieldInjections(new ComponentRegistry());

            // When
            IList <FieldInjections.FieldSetter> setters = injections.Setters(typeof(ProcedureWithStaticFields));

            // Then
            assertEquals(0, setters.Count);
        }
Ejemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotAllowClassesWithNonInjectedFields() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldNotAllowClassesWithNonInjectedFields()
        {
            // Given
            FieldInjections injections = new FieldInjections(new ComponentRegistry());

            // Expect
            Exception.expect(typeof(ProcedureException));
            Exception.expectMessage("Field `someState` on `ProcedureWithNonInjectedMemberFields` " + "is not annotated as a @Context and is not static. " + "If you want to store state along with your procedure, " + "please use a static field.");

            // When
            injections.Setters(typeof(ProcedureWithNonInjectedMemberFields));
        }
Ejemplo n.º 3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldNotAllowNonPublicFieldsForInjection() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldNotAllowNonPublicFieldsForInjection()
        {
            // Given
            FieldInjections injections = new FieldInjections(new ComponentRegistry());

            // Expect
            Exception.expect(typeof(ProcedureException));
            Exception.expectMessage("Field `someState` on `ProcedureWithPrivateMemberField` must be non-final and public.");

            // When
            injections.Setters(typeof(ProcedureWithPrivateMemberField));
        }
Ejemplo n.º 4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void syntheticsAllowed() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void SyntheticsAllowed()
        {
            // Given
            ComponentRegistry components = new ComponentRegistry();

            components.Register(typeof(int), ctx => 1337);
            FieldInjections injections = new FieldInjections(components);

            // When
            IList <FieldInjections.FieldSetter> setters = injections.Setters(typeof(Outer.ClassWithSyntheticField));

            // Then
            Outer.ClassWithSyntheticField syntheticField = (new Outer()).ClassWithSyntheticField();
            foreach (FieldInjections.FieldSetter setter in setters)
            {
                setter.Apply(null, syntheticField);
            }

            assertEquals(1337, syntheticField.InnerField);
        }
Ejemplo n.º 5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void inheritanceIsAllowed() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void InheritanceIsAllowed()
        {
            // Given
            ComponentRegistry components = new ComponentRegistry();

            components.Register(typeof(int), ctx => 1337);
            FieldInjections injections = new FieldInjections(components);

            // When
            IList <FieldInjections.FieldSetter> setters = injections.Setters(typeof(ChildProcedure));

            // Then
            ChildProcedure childProcedure = new ChildProcedure();

            foreach (FieldInjections.FieldSetter setter in setters)
            {
                setter.Apply(null, childProcedure);
            }

            assertEquals(1337, childProcedure.ChildField);
            assertEquals(1337, childProcedure.ParentField);
        }