Beispiel #1
0
        public void GameComponent()
        {
            MyComponent c = new MyComponent(new TestGame());
            GameComponentCollectionEventArgs args = new GameComponentCollectionEventArgs(c);

            Assert.AreSame(c, args.GameComponent);
        }
Beispiel #2
0
	static void Main ()
	{
		ComponentResourceManager crm = new ComponentResourceManager (
			typeof (MyComponent));

		Thread.CurrentThread.CurrentUICulture = new CultureInfo ("en-GB");
		Thread.CurrentThread.CurrentCulture = new CultureInfo ("ja-JP");

		MyComponent comp = new MyComponent ("Welcome", "System");
		crm.ApplyResources (comp, "$this", new CultureInfo ("fr-FR"));

		Assert.IsNotNull (comp.BackgroundImage, "#1");
#if NET_2_0
		Assert.IsNull (comp.Company, "#2");
#else
		Assert.IsNotNull (comp.Company, "#2");
		Assert.AreEqual ("Company (fr-FR)", comp.Company, "#3");
#endif
		Assert.AreEqual (0, comp.Interval, "#4");
		Assert.IsTrue (comp.Localizable, "#5");
		Assert.IsNotNull (comp.Name, "#6");
		Assert.AreEqual ("Component (fr)", comp.Name, "#7");
		Assert.IsNotNull (comp.Text, "#8");
		Assert.AreEqual ("Mono", comp.Text, "#9");
		Assert.IsNotNull (comp.Title, "#10");
		Assert.AreEqual ("Welcome", comp.Title, "#11");
		Assert.IsNotNull (comp.Zone, "#D12");
		Assert.AreEqual ("Zone (fr)", comp.Zone, "#D13");
	}
Beispiel #3
0
        public void Contains()
        {
            MyComponent c = new MyComponent(game);

            components.Add(c);
            Assert.IsTrue(components.Contains(c), "Failed to find MyComponent");
        }
 // Start is called before the first frame update
 void Start()
 {
     index    = 0;
     currentC = overall.components[0];
     //currentShape = Leaf.Shape.Square;
     //currentColor = Color.red;
 }
Beispiel #5
0
    public override void OnInspectorGUI()
    {
        // Automatic management
        serializedObject.Update();

        EditorGUILayout.PropertyField(intVariable, new GUIContent("Var1"));
        EditorGUILayout.PropertyField(floatVariable, new GUIContent("Var2"));
        EditorGUILayout.PropertyField(gameObjectList, new GUIContent("List"), true);

        serializedObject.ApplyModifiedProperties();


        // Manual management
        MyComponent myComponent = (MyComponent)target;

        int a = EditorGUILayout.IntField("Int Var", myComponent.IntVar);

        if (a != myComponent.IntVar)
        {
            myComponent.IntVar = a;
            EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
        }

        if (GUILayout.Button("Do something") == true)
        {
            myComponent.DoSomething();
            EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
        }
    }
Beispiel #6
0
        public void Add()
        {
            MyComponent c = new MyComponent(game);

            components.Add(c);
            Assert.AreSame(c, components[0]);
        }
                public SomeMessageHandler(Context context, MyComponent component, IServiceProvider serviceProvider)
                {
                    testContext = context;
                    myComponent = component;

                    testContext.CustomService   = component;
                    testContext.ServiceProvider = serviceProvider;
                }
Beispiel #8
0
        [Test]         // bug #522474
        public void Dispose_Recursive()
        {
            MyComponent comp      = new MyComponent();
            Container   container = comp.CreateContainer();

            comp.Dispose();
            Assert.AreEqual(0, container.Components.Count);
        }
Beispiel #9
0
        public void CanDefineConfigurationWithMaps()
        {
            MyComponent component = _container.Resolve <MyComponent>();

            Assert.AreEqual(2, component.SomeMapping.Count);
            Assert.AreEqual("value1", component.SomeMapping["key1"]);
            Assert.AreEqual("value2", component.SomeMapping["key2"]);
        }
Beispiel #10
0
        public void Clear()
        {
            MyComponent c = new MyComponent(game);

            components.Add(c);
            Assert.AreEqual(1, components.Count, "Should contain 1 component");
            components.Clear();
            Assert.AreEqual(0, components.Count);
        }
    public override void OnInspectorGUI()
    {
        // Automatic management
        serializedObject.Update();

        EditorGUILayout.PropertyField(intVariable, new GUIContent("Var1"));
        EditorGUILayout.PropertyField(floatVariable, new GUIContent("Var2"));
        EditorGUILayout.PropertyField(gameObjectList, new GUIContent("List"), true);

        serializedObject.ApplyModifiedProperties();


        // Manual management
        MyComponent myComponent = (MyComponent)target;

        int a = EditorGUILayout.IntField("Int Var", myComponent.IntVar);

        if (a != myComponent.IntVar)
        {
            myComponent.IntVar = a;
            EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
        }

        if (GUILayout.Button("Do something") == true)
        {
            myComponent.DoSomething();
            EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
        }


        GUILayout.Box(myComponent.image, GUILayout.Width(100), GUILayout.Height(100));

        Event currentEvent = Event.current;
        Rect  rect         = GUILayoutUtility.GetLastRect();

        if (rect.Contains(currentEvent.mousePosition))
        {
            switch (currentEvent.type)
            {
            case EventType.DragUpdated:
                DragAndDrop.visualMode = IsDragValid() ? DragAndDropVisualMode.Link : DragAndDropVisualMode.Rejected;
                currentEvent.Use();
                break;

            case EventType.DragPerform:
                DragAndDrop.AcceptDrag();

                for (int i = 0; i < DragAndDrop.objectReferences.Length; i++)
                {
                    myComponent.image = DragAndDrop.objectReferences[i] as Texture2D;
                }
                currentEvent.Use();
                break;
            }
        }
    }
		public void DisposeWith_Component()
		{
			var disposable = new MyDisposable();
			var component = new MyComponent();
			disposable.DisposeWith(component);

			Assert.IsFalse(disposable.IsDisposed);
			component.Dispose();
			Assert.IsTrue(disposable.IsDisposed);
		}
Beispiel #13
0
 static void Main(string[] args)
 {
     Console.WriteLine("Calling TestComponent.MyComponent from UNSIGNED app:");
     Console.WriteLine("----------------------------------------------------");
     MyComponent.Feature1();
     MyComponent.Feature2();
     Console.WriteLine();
     Console.WriteLine("Press any key to exit...");
     Console.ReadKey();
 }
Beispiel #14
0
        public void ComponentAddedEventTest()
        {
            bool fired = false;

            components.ComponentAdded += delegate(object sender, GameComponentCollectionEventArgs args) { fired = true; };
            MyComponent c = new MyComponent(game);

            components.Add(c);
            Assert.IsTrue(fired, "ComponentAdded event did not fire.");
        }
Beispiel #15
0
        public void ExplicitCollectionRegistrationsMadeInParentArePreservedInChildScope()
        {
            var obs = new MyComponent[5];
            var cb  = new ContainerBuilder();

            cb.RegisterInstance(obs).As <IEnumerable <MyComponent> >();
            var container = cb.Build();
            var ls        = container.BeginLifetimeScope(b => b.RegisterType <MyComponent>());

            Assert.Same(obs, ls.Resolve <IEnumerable <MyComponent> >());
        }
        public void TestSitedComponent()
        {
            ServiceContainer c = new ServiceContainer();

            c.AddService(typeof(HelloWorldService), new HelloWorldService());

            c.Add(new MyComponent(), "MyTest");
            MyComponent mc = c.Components["MyTest"] as MyComponent;

            Assert.IsTrue(mc.Run());
        }
Beispiel #17
0
        public void LocalRegistrationCanPreserveParentAsDefault()
        {
            var o  = new MyComponent();
            var cb = new ContainerBuilder();

            cb.RegisterType <MyComponent>();
            var container = cb.Build();
            var ls        = container.BeginLifetimeScope(b => b.Register(c => o).PreserveExistingDefaults());

            Assert.NotSame(o, ls.Resolve <MyComponent>());
        }
Beispiel #18
0
        public void ComponentAddedEventArgsEventTest()
        {
            MyComponent c = new MyComponent(game);

            components.ComponentAdded += delegate(object sender, GameComponentCollectionEventArgs args)
            {
                Assert.AreSame(c, args.GameComponent, "Unexpected component in args");
            };
            components.Add(c);
            Assert.AreEqual(1, components.Count, "Component was not added to collection");
        }
Beispiel #19
0
 static void Test1()
 {
     try
     {
         MyComponent c = new MyComponent();
         c.Init();
     }
     catch (Exception exc)
     {
         Console.WriteLine(exc.GetType());
     }
 }
        static void Main(string[] args)
        {
            // pizza example
            var pizza = new PizzaExample.Pizza("Peperoni");

            pizza.Make();

            // simulate react component lifecycle with template method
            var component = new MyComponent();

            component.Update();
        }
Beispiel #21
0
        public void MostLocalRegistrationIsDefault()
        {
            var cb = new ContainerBuilder();

            cb.RegisterType <MyComponent>();
            var container = cb.Build();
            var ls1       = container.BeginLifetimeScope(b => b.RegisterType <MyComponent>());
            var o         = new MyComponent();
            var ls2       = ls1.BeginLifetimeScope(b => b.RegisterInstance(o));

            Assert.Same(o, ls2.Resolve <MyComponent>());
        }
Beispiel #22
0
	static void Main ()
	{
		ComponentResourceManager crm = new ComponentResourceManager (
			typeof (MyComponent));

		MyComponent comp = new MyComponent ("Welcome", "System");

		try {
			crm.ApplyResources (comp, "$this", CultureInfo.InvariantCulture);
			Assert.Fail ("#A1");
		} catch (MissingManifestResourceException ex) {
			// Could not find any resources appropriate for the
			// specified culture or the neutral culture.  Make sure
			// "Mono.Tests.MyComponent.resources" was correctly
			// embedded or linked into assembly "test2" at compile
			// time, or that all the satellite assemblies required
			// are loadable and fully signed
			Assert.AreEqual (typeof (MissingManifestResourceException), ex.GetType (), "#A2");
			Assert.IsNull (ex.InnerException, "#A3");
			Assert.IsNotNull (ex.Message, "#A4");
#if NET_2_0
			Assert.IsTrue (ex.Message.IndexOf ("\"Mono.Tests.MyComponent.resources\"") != -1, "#A5");
#else
			Assert.IsTrue (ex.Message.IndexOf ("MyComponent.resources") != -1, "#A5");
#endif
			Assert.IsTrue (ex.Message.IndexOf ("\"test2\"") != -1, "#A6");
		}

		comp = new MyComponent ("Welcome", "System");
		crm.IgnoreCase = false;

		try {
			crm.ApplyResources (comp, "$this", new CultureInfo ("nl-BE"));
			Assert.Fail ("#B1");
		} catch (MissingManifestResourceException ex) {
			// Could not find any resources appropriate for the
			// specified culture or the neutral culture.  Make sure
			// "Mono.Tests.MyComponent.resources" was correctly
			// embedded or linked into assembly "test2" at compile
			// time, or that all the satellite assemblies required
			// are loadable and fully signed
			Assert.AreEqual (typeof (MissingManifestResourceException), ex.GetType (), "#B2");
			Assert.IsNull (ex.InnerException, "#B3");
			Assert.IsNotNull (ex.Message, "#B4");
#if NET_2_0
			Assert.IsTrue (ex.Message.IndexOf ("\"Mono.Tests.MyComponent.resources\"") != -1, "#B5");
#else
			Assert.IsTrue (ex.Message.IndexOf ("MyComponent.resources") != -1, "#B5");
#endif
			Assert.IsTrue (ex.Message.IndexOf ("\"test2\"") != -1, "#B6");
		}
	}
Beispiel #23
0
        /// <summary>
        /// When you resolve your component, Autofac will see that you
        /// have an ILogger registered, but you don’t have an IConfigReader
        /// registered. In that case, the second constructor will be chosen
        /// since that’s the one with the most parameters that can be found in the container.
        /// </summary>
        private static void RegisterComponents()
        {
            ContainerBuilder builder = new ContainerBuilder();

            builder.RegisterType <MyComponent>();
            builder.RegisterType <ConsoleLogger>().As <ILogger>();
            IContainer container = builder.Build();

            using (ILifetimeScope scope = container.BeginLifetimeScope())
            {
                MyComponent component = scope.Resolve <MyComponent>();
            }
        }
Beispiel #24
0
        protected override void OnStart()
        {
            scene     = new Scene();
            layer     = new Layer2D();
            component = new MyComponent();

            layer.AddComponent(component, "LifeCycle");

            Assert.AreEqual(false, component.IsAdded);
            scene.AddLayer(layer);

            Engine.ChangeScene(scene);
        }
Beispiel #25
0
    public override void OnInspectorGUI()
    {
        MyComponent targetComponent = (MyComponent)target;

        // draws the default Inspector items
        DrawDefaultInspector();

        if (GUILayout.Button("Test"))
        {
            //targetComponent.MyMethod(); // call a "MyMethod()" from targetComponent
            Debug.Log("Button Clicked...");
        }
    }
Beispiel #26
0
        private Tuple<TextureObject2D, MyComponent> GetObject( float x )
        {
            var obj = new TextureObject2D()
            {
                Position = new Vector2DF( x, 240 ),
                Texture = Engine.Graphics.CreateTexture2D( CloudTexturePath )
            };

            var component = new MyComponent();

            obj.AddComponent( component, "Rotation" );

            return Tuple.Create( obj, component );
        }
Beispiel #27
0
        public void IntermediateRegistrationOverridesParentAsDefault()
        {
            var o1 = new MyComponent();
            var o2 = new MyComponent();

            var builder = new ContainerBuilder();

            builder.Register(c => o1);
            var scope1 = builder.Build();
            var scope2 = scope1.BeginLifetimeScope(b => b.Register(c => o2));
            var scope3 = scope2.BeginLifetimeScope(b => { });

            Assert.Same(o2, scope3.Resolve <MyComponent>());
        }
Beispiel #28
0
 static void Test1()
 {
     try
     {
         MyComponent c = new MyComponent();
         c.Print();      //with default values
         c.Print("aaa"); //with default second argument
         c.Print("bbb", 20);
     }
     catch (Exception exc)
     {
         Console.WriteLine(exc.GetType());
     }
 }
Beispiel #29
0
        private Tuple <TextureObject2D, MyComponent> GetObject(float x)
        {
            var obj = new TextureObject2D()
            {
                Position = new Vector2DF(x, 240),
                Texture  = Engine.Graphics.CreateTexture2D(CloudTexturePath)
            };

            var component = new MyComponent();

            obj.AddComponent(component, "Rotation");

            return(Tuple.Create(obj, component));
        }
Beispiel #30
0
        public void TestCurrentYear()
        {
            int fixedYear = 2000;

            using (ShimsContext.Create())
            {
                System.Fakes.ShimDateTime.NowGet = () => new DateTime(fixedYear, 1, 1);

                var componentUnderTest = new MyComponent();

                int year = componentUnderTest.GetTheCurrentYear();

                Assert.AreEqual(fixedYear, year);
            }
        }
        private Tuple <Layer2D, MyComponent> CreateSampleLayer(float x)
        {
            var layer = new Layer2D();
            var obj   = new TextureObject2D
            {
                Position = new Vector2DF(x, 240),
                Texture  = Engine.Graphics.CreateTexture2D(CloudTexturePath),
            };
            var component = new MyComponent();

            layer.AddObject(obj);
            layer.AddComponent(component, "Black");

            return(Tuple.Create(layer, component));
        }
Beispiel #32
0
        private Tuple<Layer2D, MyComponent> CreateSampleLayer( float x )
        {
            var layer = new Layer2D();
            var obj = new TextureObject2D
            {
                Position = new Vector2DF( x, 240 ),
                Texture = Engine.Graphics.CreateTexture2D( CloudTexturePath ),
            };
            var component = new MyComponent();

            layer.AddObject( obj );
            layer.AddComponent( component, "Black" );

            return Tuple.Create( layer, component );
        }
Beispiel #33
0
    private void IterateWithIEnumerator(IEnumerable <MyComponent> components)
    {
        //Get the Enumerator
        IEnumerator <MyComponent> enumerator = components.GetEnumerator();

        //Enumerator starts at index -1
        //while there's still a next item, go to the next position
        while (enumerator.MoveNext())
        {
            //get the current componenet the enumerator is pointing to
            MyComponent component = enumerator.Current;

            //call print on that component
            component.Rotate();
        }
    }
Beispiel #34
0
        public Intro()
        {
            ContainerBuilder builder = new ContainerBuilder();

            builder.RegisterType <ConsoleLogger>().As <ILogger>();
            builder.Register(c => new ConfigReader("mysection")).As <IConfigReader>();
            builder.RegisterType <MyComponent>()
            .UsingConstructor(typeof(ILogger), typeof(IConfigReader));
            IContainer container = builder.Build();

            using (ILifetimeScope scope = container.BeginLifetimeScope())
            {
                MyComponent myComponent = scope.Resolve <MyComponent>();
                TestUtilities.WriteLine(myComponent);
            }
        }
Beispiel #35
0
        /// <summary>
        /// http://autofac.readthedocs.io/en/latest/register/registration.html#specifying-a-constructor
        /// </summary>
        private static void SpecifyingaConstructor()
        {
            Console.WriteLine("\nSpecifyingaConstructor:\n");
            ContainerBuilder builder = new ContainerBuilder();

            builder.RegisterType <ConsoleLogger>().As <ILogger>();
            builder.Register(c => new ConfigReader("mysection")).As <IConfigReader>();
            builder.RegisterType <MyComponent>()
            .UsingConstructor(typeof(ILogger), typeof(IConfigReader));
            IContainer container = builder.Build();

            using (ILifetimeScope scope = container.BeginLifetimeScope())
            {
                MyComponent component = scope.Resolve <MyComponent>();
            }
        }
Beispiel #36
0
	static void Main ()
	{
		ComponentResourceManager crm = new ComponentResourceManager (
			typeof (MyComponent));

		MyComponent comp = new MyComponent ("Welcome", "System");
		crm.ApplyResources (comp, "$this", new CultureInfo ("nl-BE"));

		Assert.IsNotNull (comp.BackgroundImage, "#A1");
#if NET_2_0
		Assert.IsNull (comp.Company, "#A2");
#else
		Assert.IsNotNull (comp.Company, "#A2");
		Assert.AreEqual ("Company (NL-BE)", comp.Company, "#A3");
#endif
		Assert.AreEqual (0, comp.Interval, "#A4");
		Assert.IsTrue (comp.Localizable, "#A5");
		Assert.IsNull (comp.Name, "#A6");
		Assert.IsNotNull (comp.Text, "#A8");
		Assert.AreEqual ("Mono", comp.Text, "#A9");
		Assert.IsNotNull (comp.Title, "#A10");
		Assert.AreEqual ("Welcome", comp.Title, "#A11");
		Assert.IsNotNull (comp.Zone, "#A12");
		Assert.AreEqual ("Zone (NL-BE)", comp.Zone, "#A13");

		comp = new MyComponent ("Welcome", "System");
		crm = new ComponentResourceManager (typeof (MyComponent));
		crm.ApplyResources (comp, "$this", new CultureInfo ("ja-JP"));

		Assert.IsNotNull (comp.BackgroundImage, "#B1");
		Assert.IsNotNull (comp.Company, "#B2");
		Assert.AreEqual ("OSF", comp.Company, "#B3");
		Assert.AreEqual (0, comp.Interval, "#B4");
		Assert.IsTrue (comp.Localizable, "#B5");
		Assert.IsNull (comp.Name, "#B6");
		Assert.IsNotNull (comp.Text, "#B7");
		Assert.AreEqual ("Mono", comp.Text, "#B8");
		Assert.IsNotNull (comp.Title, "#B9");
		Assert.AreEqual ("Welcome", comp.Title, "#B10");
#if NET_2_0
		Assert.IsNull (comp.Zone, "#B11");
#else
		Assert.IsNotNull (comp.Zone, "#B11");
		Assert.AreEqual (string.Empty, comp.Zone, "#B12");
#endif
	}
Beispiel #37
0
        public void Test_Animate()
        {
            var wld = new World ();
            var nod = new Node ();
            wld.AddChild (nod);

            var cmp1 = new MyComponent ();
            var cmp2 = new MyComponent ();
            wld.Attach (cmp1);
            nod.Attach (cmp2);

            wld.Animate (0, 0);

            Assert.AreEqual (1, cmp1.Animated);
            Assert.AreEqual (1, cmp2.Animated);

            nod.Animatable = false;
            wld.Animate (0, 0);

            Assert.AreEqual (2, cmp1.Animated);
            Assert.AreEqual (1, cmp2.Animated);
        }
        public void Test_OnColisionEnter()
        {
            var node1 = new Node ("Node1");
            var cmp1 = new MyComponent ();
            var col1 = new CollisionObject ();
            col1.Shape = new BoxShape (1, 1, 1);
            node1.Attach (cmp1);
            node1.Attach (col1);

            var node2 = new Node ("Node2");
            var cmp2 = new MyComponent ();
            var col2 = new CollisionObject ();
            col2.Shape = new BoxShape (1, 1, 1);
            node2.Attach (cmp2);
            node2.Attach (col2);

            var wld = new World ();
            wld.AddChild (node1);
            wld.AddChild (node2);

            node1.Translate (1, 0, 0);

            // ここでコリジョン発生
            wld.CollisionUpdate ();

            Assert.AreEqual (true, cmp1.IsCollisionEnterCalled);
            Assert.AreEqual (true, cmp2.IsCollisionEnterCalled);

            // 離れる
            node2.Translate (10, 0, 0);

            // ここでコリジョン消失
            wld.CollisionUpdate ();

            Assert.AreEqual (true, cmp1.IsCollisionExitCalled);
            Assert.AreEqual (true, cmp2.IsCollisionExitCalled);
        }
Beispiel #39
0
        public void Test_FinalizeNode()
        {
            var node = new MyNode ();
            var cmp = new MyComponent ();
            node.Attach (cmp);

            // ここでは即時ファイナライズ(World=null)のみをテストし、
            // 遅延ファイナライズは TestGraveYard で行う
            node.FinalizeNode();

            Assert.AreEqual (true, node.IsFinalized);
            Assert.AreEqual (true, cmp.IsDisposed);
            Assert.AreEqual (true, node.IsDisposed);
            Assert.AreEqual (0, node.ComponentCount);
        }
Beispiel #40
0
	static void Main ()
	{
		ComponentResourceManager crm = new ComponentResourceManager (
			typeof (MyComponent));

		Thread.CurrentThread.CurrentUICulture = new CultureInfo ("en-GB");
		Thread.CurrentThread.CurrentCulture = new CultureInfo ("nl-BE");

		MyComponent comp = new MyComponent ("Welcome", "System");
		crm.ApplyResources (comp, "$this", CultureInfo.InvariantCulture);

		Assert.IsNotNull (comp.BackgroundImage, "#A1");
		Assert.IsNotNull (comp.Company, "#A2");
		Assert.AreEqual ("OSF", comp.Company, "#A3");
		Assert.AreEqual (0, comp.Interval, "#A4");
		Assert.IsTrue (comp.Localizable, "#A5");
		Assert.IsNull (comp.Name, "#A6");
		Assert.IsNotNull (comp.Text, "#A7");
		Assert.AreEqual ("Mono", comp.Text, "#A8");
		Assert.IsNotNull (comp.Title, "#A9");
		Assert.AreEqual ("Welcome", comp.Title, "#A10");
#if NET_2_0
		Assert.IsNull (comp.Zone, "#A11");
#else
		Assert.IsNotNull (comp.Zone, "#A11");
		Assert.AreEqual (string.Empty, comp.Zone, "#A12");
#endif

		comp = new MyComponent ("Welcome", "System");
		crm.IgnoreCase = true;
		crm.ApplyResources (comp, "$this", CultureInfo.InvariantCulture);

		Assert.IsNotNull (comp.BackgroundImage, "#B1");
		Assert.IsNotNull (comp.Company, "#B2");
		Assert.AreEqual ("OSF", comp.Company, "#B3");
		Assert.AreEqual (0, comp.Interval, "#B4");
		Assert.IsTrue (comp.Localizable, "#B5");
		Assert.IsNotNull (comp.Name, "#B6");
		Assert.AreEqual ("Mono Component", comp.Name, "#B7");
		Assert.IsNotNull (comp.Text, "#B8");
		Assert.AreEqual ("Mono", comp.Text, "#B9");
		Assert.IsNotNull (comp.Title, "#B10");
		Assert.AreEqual ("Welcome", comp.Title, "#B11");
#if NET_2_0
		Assert.IsNull (comp.Zone, "#B12");
#else
		Assert.IsNotNull (comp.Zone, "#B12");
		Assert.AreEqual (string.Empty, comp.Zone, "#B13");
#endif

		comp = new MyComponent ("Welcome", "System");
		crm.ApplyResources (comp, string.Empty, CultureInfo.InvariantCulture);
		Assert.IsNull (comp.Name, "#C");

		comp = new MyComponent ("Welcome", "System");
		crm.IgnoreCase = false;
		crm.ApplyResources (comp, "$this", new CultureInfo ("nl-BE"));

		Assert.IsNotNull (comp.BackgroundImage, "#D1");
#if NET_2_0
		Assert.IsNull (comp.Company, "#D2");
#else
		Assert.IsNotNull (comp.Company, "#D2");
		Assert.AreEqual ("Company (NL-BE)", comp.Company, "#D3");
#endif
		Assert.AreEqual (0, comp.Interval, "#D4");
		Assert.IsTrue (comp.Localizable, "#D5");
		Assert.IsNull (comp.Name, "#D6");
		Assert.IsNotNull (comp.Text, "#D7");
		Assert.AreEqual ("Mono", comp.Text, "#D8");
		Assert.IsNotNull (comp.Title, "#D9");
		Assert.AreEqual ("Welcome", comp.Title, "#D10");
		Assert.IsNotNull (comp.Zone, "#D11");
		Assert.AreEqual ("Zone (NL-BE)", comp.Zone, "#D12");

		comp = new MyComponent ("Welcome", "System");
		crm.IgnoreCase = false;
		crm.ApplyResources (comp, "$this", new CultureInfo ("nl-NL"));

		Assert.IsNotNull (comp.BackgroundImage, "#E1");
		Assert.IsNotNull (comp.Company, "#E2");
		Assert.AreEqual ("OSF", comp.Company, "#E3");
		Assert.AreEqual (0, comp.Interval, "#E4");
		Assert.IsTrue (comp.Localizable, "#E5");
		Assert.IsNull (comp.Name, "#E6");
		Assert.IsNotNull (comp.Text, "#E7");
		Assert.AreEqual ("Mono", comp.Text, "#E8");
		Assert.IsNotNull (comp.Title, "#E9");
		Assert.AreEqual ("Welcome", comp.Title, "#E10");
#if NET_2_0
		Assert.IsNull (comp.Zone, "#E11");
#else
		Assert.IsNotNull (comp.Zone, "#E11");
		Assert.AreEqual (string.Empty, comp.Zone, "#E12");
#endif

		comp = new MyComponent ("Welcome", "System");
		crm.IgnoreCase = true;
		crm.ApplyResources (comp, "$this", new CultureInfo ("fr-FR"));

		Assert.IsNotNull (comp.BackgroundImage, "#F1");
#if NET_2_0
		Assert.IsNull (comp.Company, "#F2");
#else
		Assert.IsNotNull (comp.Company, "#F2");
		Assert.AreEqual ("Company (fr-FR)", comp.Company, "#F3");
#endif
		Assert.AreEqual (0, comp.Interval, "#F4");
		Assert.IsTrue (comp.Localizable, "#F5");
		Assert.IsNotNull (comp.Name, "#F6");
		Assert.AreEqual ("Component (fr-FR)", comp.Name, "#F7");
		Assert.IsNotNull (comp.Text, "#F8");
		Assert.AreEqual ("Mono", comp.Text, "#F9");
		Assert.IsNotNull (comp.Title, "#F10");
		Assert.AreEqual ("Welcome", comp.Title, "#F11");
		Assert.IsNotNull (comp.Zone, "#F12");
		Assert.AreEqual ("Zone (fr)", comp.Zone, "#F13");

		comp = new MyComponent ("Welcome", "System");
		crm.ApplyResources (comp, "$this", null);

		Assert.IsNotNull (comp.BackgroundImage, "#G1");
		Assert.IsNotNull (comp.Company, "#G2");
		Assert.AreEqual ("Company (en-GB)", comp.Company, "#G3");
		Assert.AreEqual (0, comp.Interval, "#G4");
		Assert.IsTrue (comp.Localizable, "#G5");
		Assert.IsNotNull (comp.Name, "#G6");
		Assert.AreEqual ("Component (en-GB)", comp.Name, "#G7");
		Assert.IsNotNull (comp.Text, "#G8");
		Assert.AreEqual ("Mono", comp.Text, "#G9");
		Assert.IsNotNull (comp.Title, "#G10");
		Assert.AreEqual ("Welcome", comp.Title, "#G11");
		Assert.IsNotNull (comp.Zone, "#G12");
		Assert.AreEqual ("Zone (en-GB)", comp.Zone, "#G13");

		comp = new MyComponent ("Welcome", "System");
		crm.ApplyResources (comp, "$this");

		Assert.IsNotNull (comp.BackgroundImage, "#H1");
		Assert.IsNotNull (comp.Company, "#H2");
		Assert.AreEqual ("Company (en-GB)", comp.Company, "#H3");
		Assert.AreEqual (0, comp.Interval, "#H4");
		Assert.IsTrue (comp.Localizable, "#H5");
		Assert.IsNotNull (comp.Name, "#H6");
		Assert.AreEqual ("Component (en-GB)", comp.Name, "#H7");
		Assert.IsNotNull (comp.Text, "#H8");
		Assert.AreEqual ("Mono", comp.Text, "#H9");
		Assert.IsNotNull (comp.Title, "#H10");
		Assert.AreEqual ("Welcome", comp.Title, "#H11");
		Assert.IsNotNull (comp.Zone, "#H12");
		Assert.AreEqual ("Zone (en-GB)", comp.Zone, "#H13");
	}
 public void Contains()
 {
     MyComponent c = new MyComponent(game);
     components.Add(c);
     Assert.IsTrue(components.Contains(c), "Failed to find MyComponent");
 }
 public void ComponentRemovedEventTest()
 {
     bool fired = false;
     components.ComponentRemoved += delegate(object sender, GameComponentCollectionEventArgs args) { fired = true; };
     MyComponent c = new MyComponent(game);
     components.Add(c);
     components.Remove(c);
     Assert.IsTrue(fired, "ComponentRemoved event did not fire.");
 }
Beispiel #43
0
 public void Dispose_Recursive()
 {
     MyComponent comp = new MyComponent();
     Container container = comp.CreateContainer();
     comp.Dispose();
     Assert.Equal(0, container.Components.Count);
 }
 public void GameComponent()
 {
     MyComponent c = new MyComponent(new TestGame());
     GameComponentCollectionEventArgs args = new GameComponentCollectionEventArgs(c);
     Assert.AreSame(c, args.GameComponent);
 }
 public void ComponentRemovedEventArgsEventTest()
 {
     MyComponent c = new MyComponent(game);
     
     components.ComponentAdded += delegate(object sender, GameComponentCollectionEventArgs args)
                                      {
                                          Assert.AreSame(c, args.GameComponent, "Unexpected component in args");
                                      };
     components.Add(c);
     Assert.AreEqual(1, components.Count, "Component was not added to collection");
     components.Remove(c);
     Assert.AreEqual(0, components.Count, "Component was not removed from collection");
 }
 public void Add()
 {
     MyComponent c = new MyComponent(game);
     components.Add(c);
     Assert.AreSame(c, components[0]);
 }
 public void Clear()
 {
     MyComponent c = new MyComponent(game);
     components.Add(c);
     Assert.AreEqual(1, components.Count, "Should contain 1 component");
     components.Clear();
     Assert.AreEqual(0, components.Count);
 }
Beispiel #48
0
	static void Main ()
	{
		ComponentResourceManager crm = new ComponentResourceManager (
			typeof (MyComponent));

		MyComponent comp = new MyComponent ("Welcome", "System");
		crm.IgnoreCase = true;
		crm.ApplyResources (comp, "$this", new CultureInfo ("nl-BE"));

		Assert.IsNotNull (comp.BackgroundImage, "#A1");
#if NET_2_0
		Assert.IsNull (comp.Company, "#A2");
#else
		Assert.IsNotNull (comp.Company, "#A2");
		Assert.AreEqual ("Company (NL-NL)", comp.Company, "#A3");
#endif
		Assert.AreEqual (0, comp.Interval, "#A4");
		Assert.IsTrue (comp.Localizable, "#A5");
		Assert.IsNotNull (comp.Name, "#A6");
		Assert.AreEqual ("Component (NL-NL)", comp.Name, "#A7");
		Assert.IsNotNull (comp.Text, "#A8");
		Assert.AreEqual ("Mono", comp.Text, "#A9");
		Assert.IsNotNull (comp.Title, "#A10");
		Assert.AreEqual ("Welcome", comp.Title, "#A11");
		Assert.IsNotNull (comp.Zone, "#A12");
		Assert.AreEqual ("Zone (NL-NL)", comp.Zone, "#A13");

		comp = new OURComponent ("Welcome", "System");
		crm = new ComponentResourceManager (typeof (OURComponent));
		crm.ApplyResources (comp, "$this", new CultureInfo ("nl-BE"));

		Assert.IsNotNull (comp.BackgroundImage, "#B1");
#if NET_2_0
		Assert.IsNull (comp.Company, "#B2");
#else
		Assert.IsNotNull (comp.Company, "#B2");
		Assert.AreEqual ("Company (nl-BE)", comp.Company, "#B3");
#endif
		Assert.AreEqual (0, comp.Interval, "#B4");
		Assert.IsTrue (comp.Localizable, "#B5");
		Assert.IsNull (comp.Name, "#B6");
		Assert.IsNotNull (comp.Text, "#B7");
		Assert.AreEqual ("Mono", comp.Text, "#B8");
		Assert.IsNotNull (comp.Title, "#B9");
		Assert.AreEqual ("Welcome", comp.Title, "#B10");
		Assert.IsNotNull (comp.Zone, "#B11");
		Assert.AreEqual ("Zone (nl-BE)", comp.Zone, "#B12");

		comp = new OURComponent ("Welcome", "System");
		crm = new ComponentResourceManager (typeof (OURComponent));
		crm.ApplyResources (comp, "$this", CultureInfo.InvariantCulture);

		Assert.IsNotNull (comp.BackgroundImage, "#C1");
		Assert.IsNotNull (comp.Company, "#C2");
		Assert.AreEqual ("OSF", comp.Company, "#C3");
		Assert.AreEqual (0, comp.Interval, "#C4");
		Assert.IsTrue (comp.Localizable, "#C5");
		Assert.IsNull (comp.Name, "#C6");
		Assert.IsNotNull (comp.Text, "#C7");
		Assert.AreEqual ("Mono", comp.Text, "#C8");
		Assert.IsNotNull (comp.Title, "#C9");
		Assert.AreEqual ("Welcome", comp.Title, "#C10");
#if NET_2_0
		Assert.IsNull (comp.Zone, "#C11");
#else
		Assert.IsNotNull (comp.Zone, "#C11");
		Assert.AreEqual (string.Empty, comp.Zone, "#C12");
#endif

		ResourceManager rm = new ResourceManager ("MonO.TestS.MYcomPonenT",
			Assembly.GetExecutingAssembly ());
		Assert.IsNotNull (rm.GetString ("$this.Company", new CultureInfo ("fr-FR")), "#D1");
#if NET_2_0
		Assert.AreEqual ("OSF", rm.GetString ("$this.Company", new CultureInfo ("fr-FR")), "#D2");
#else
		Assert.AreEqual ("Company (fr-FR)", rm.GetString ("$this.Company", new CultureInfo ("fr-FR")), "#D2");
#endif

		rm = new ResourceManager ("MonO.TestS.MYcomPonenT",
			Assembly.GetExecutingAssembly ());
		Assert.IsNotNull (rm.GetString ("$this.Company", CultureInfo.InvariantCulture), "#E1");
		Assert.AreEqual ("OSF", rm.GetString ("$this.Company", CultureInfo.InvariantCulture), "#E2");

		rm = new ResourceManager ("OurcomPonenT", Assembly.GetExecutingAssembly ());
		Assert.IsNotNull (rm.GetString ("$this.Company", new CultureInfo ("nl-BE")), "#F1");
#if NET_2_0
		Assert.AreEqual ("OSF", rm.GetString ("$this.Company", new CultureInfo ("nl-BE")), "#F2");
#else
		Assert.AreEqual ("Company (nl-BE)", rm.GetString ("$this.Company", new CultureInfo ("nl-BE")), "#F2");
#endif

		rm = new ResourceManager ("OurcomPonenT", Assembly.GetExecutingAssembly ());
		Assert.IsNotNull (rm.GetString ("$this.Company", CultureInfo.InvariantCulture), "#G1");
		Assert.AreEqual ("OSF", rm.GetString ("$this.Company", CultureInfo.InvariantCulture), "#G2");
	}
Beispiel #49
0
        public void Test_UpdateInit()
        {
            var wld = new World ();
            var nod = new Node ();
            wld.AddChild (nod);

            var cmp1 = new MyComponent ();
            var cmp2 = new MyComponent ();
            wld.Attach (cmp1);
            nod.Attach (cmp2);

            wld.Update (0);
            Assert.AreEqual (1, cmp1.OnUpdateInited);
            Assert.AreEqual (1, cmp2.OnUpdateInited);

            wld.Update (0);
            Assert.AreEqual (1, cmp1.OnUpdateInited);
            Assert.AreEqual (1, cmp2.OnUpdateInited);
        }