2006-01-31 Gonzalo Paniagua Javier <gonzalo@ximian.com>
[mono.git] / mcs / class / System / Test / System.ComponentModel / ContainerTest.cs
1 //
2 // System.ComponentModel.Container test cases
3 //
4 // Authors:
5 //      Gonzalo Paniagua Javier (gonzalo@ximian.com)
6 //
7 // Copyright (c) 2006 Novell, Inc. (http://www.novell.com)
8 //
9
10 using NUnit.Framework;
11 using System;
12 using System.ComponentModel;
13 using System.ComponentModel.Design;
14
15 namespace MonoTests.System.ComponentModel
16 {
17         class TestService {
18         }
19         
20         class TestContainer : Container {
21                 ServiceContainer _services = new ServiceContainer();
22                 
23                 public TestContainer() {
24                         _services.AddService( typeof(TestService), new TestService() );
25                 }
26                 
27                 protected override object GetService( Type serviceType ) {
28                         return _services.GetService( serviceType );
29                 }
30         }
31         
32         class TestComponent : Component {
33                 public override ISite Site {
34                         get {
35                                 return base.Site;
36                         }
37                         set {
38                                 base.Site = value;
39                                 if (value != null) {
40                                         Assert.IsNotNull (value.GetService (typeof (ISite)));
41                                         Assert.IsNotNull (value.GetService (typeof (TestService)));
42                                 }
43                         }
44                 }
45         }
46
47         [TestFixture]
48         public class ContainerTest {
49                 [Test]
50                 public void GetService1 ()
51                 {
52                         TestContainer container = new TestContainer ();
53                         container.Add (new TestComponent ());
54                 }
55         }
56 }
57