Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 99 lines (84 sloc) 2.46 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
using System;
using System.Collections.Generic;
using NUnit.Framework;
using Spring.Context.Support;
using Spring.Objects.Factory;
using Spring.Testing.NUnit;

namespace q8981997_membership_provider_in_unit_test
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
        }
    }

    /// <summary>
    /// Example demonstrating unit testing injectieng dependencies by name into protecte fields.
    /// </summary>
    /// <remarks>
    /// Make sure you use private fields, not properties and that
    /// you set PopulateProtectedVariables = true in the test
    /// constructor.
    /// This will _not_ inject into properties.
    /// </remarks>
[TestFixture]
    public class InjectIntoProtectedFieldsByNameTests : AbstractDependencyInjectionSpringContextTests
    {
        protected IMyInterface MyObject;

        public InjectIntoProtectedFieldsByNameTests()
        {
            PopulateProtectedVariables = true;
        }

[Test]
        public void Main()
        {
            Assert.NotNull(MyObject);
            Console.WriteLine("Name: {0}", MyObject.ObjectName);
        }

        protected override string[] ConfigLocations
        {
            get { return new[] { "objects.xml" }; }
        }
    }

    /// <summary>
    /// Example demonstrating unit testing using autowire by type.
    /// </summary>
    /// <remarks>
    /// This is the default and will work for all public properties.
    /// If your property is not public, it will not be injected.
    /// </remarks>
[TestFixture]
    public class AutoWireByTypeTests : AbstractDependencyInjectionSpringContextTests
    {
        public IMyInterface Sut { get; set; }
        protected IMyInterface Sut2 { get; set; }

[Test]
        public void Main()
        {
            Assert.NotNull(Sut);
            Console.WriteLine("Name: {0}", Sut.ObjectName);
        }

[Test]
        public void Sut2IsNull()
        {
            Assert.Null(Sut2);
        }

        protected override string[] ConfigLocations
        {
            get { return new[] { "objects.xml" }; }
        }
    }

    public class MyClass : IObjectNameAware, IMyInterface
    {
        public override string ToString()
        {
            return ObjectName;
        }

        public string ObjectName { get; set; }
    }

    public interface IMyInterface
    {
        string ObjectName { get; }
    }


}
Something went wrong with that request. Please try again.