Exemple #1
0
 public App()
 {
     Component1 c1 = new Component1();
     Component2 c2 = new Component2();
     Component3 c3 = new Component3();
     Component4 c4 = new Component4();
 }
Exemple #2
0
        public static void TestBridgeFields()
        {
            var c = new Component();

            Assert.NotNull(c.InstanceField);
            Assert.NotNull(c.InstanceProperty);
            Assert.NotNull(Component.StaticField);
            Assert.NotNull(Component.StaticProperty);

            c.ctor       = 6;
            c.config     = 1;
            c.events     = 2;
            c.inherits   = 3;
            c.properties = 4;
            c.statics    = 5;

            Assert.AreEqual(6, c.ctor);
            Assert.AreEqual(1, c.config);
            Assert.AreEqual(2, c.events);
            Assert.AreEqual(3, c.inherits);
            Assert.AreEqual(4, c.properties);
            Assert.AreEqual(5, c.statics);

            Assert.AreEqual(1, c.InstanceEventResult);
            Assert.AreEqual(2, Component.StaticEventResult);

            var c1 = new Component1();

            Assert.NotNull(c1.any);

            var c3 = new Component3();

            Assert.NotNull(c3.any);
        }
Exemple #3
0
 public Aggregate(
     Component1 c1,
     Component2 c2)
 {
     C1 = c1;
     C2 = c2;
 }
        public void ContainsTag()
        {
            string tag1 = "Component1";
            string tag2 = "NotComponent1";

            // Create and add a component
            var component = new Component1();

            _componentCollection.Add(component, tag1);

            // Component1 qualifies as both of these types, so both should be true when we're not looking for tags.
            Assert.True(_componentCollection.Contains <Component1>());
            Assert.True(_componentCollection.Contains <ComponentBase>());

            // Component1 is NOT this type, so this is false
            Assert.False(_componentCollection.Contains <Component2>());

            // Should be true because the component has the tag we're looking for
            Assert.True(_componentCollection.Contains <Component1>(tag1));
            Assert.True(_componentCollection.Contains <ComponentBase>(tag1));

            // False because the object with the tag doesn't match the type requirement
            Assert.False(_componentCollection.Contains <Component2>(tag1));

            // False because the object with the correct type doesn't have the tag
            Assert.False(_componentCollection.Contains <Component1>(tag2));

            // Create and add a component of a different type, with no tag
            var component2 = new Component2();

            _componentCollection.Add(component2);

            // False because the object we added has no tag
            Assert.False(_componentCollection.Contains <Component2>(tag2));
        }
        public void GetFirstOrDefaultTag()
        {
            string tag1 = "Component1";
            string tag2 = "NotComponent1";

            // Create and add a component
            var component = new Component1();

            _componentCollection.Add(component, tag1);

            // Component1 qualifies as both of these types, so both should return the component we added when we're not looking for tags.
            Assert.Same(component, _componentCollection.GetFirstOrDefault <Component1>());
            Assert.Same(component, _componentCollection.GetFirstOrDefault <ComponentBase>());

            // Component1 is NOT this type, so this is null
            Assert.Null(_componentCollection.GetFirstOrDefault <Component2>());

            // Should return the component because the component has the tag we're looking for
            Assert.Same(component, _componentCollection.GetFirstOrDefault <Component1>(tag1));
            Assert.Same(component, _componentCollection.GetFirstOrDefault <ComponentBase>(tag1));

            // Null because the object with the tag doesn't match the type requirement
            Assert.Null(_componentCollection.GetFirstOrDefault <Component2>(tag1));

            // False because the object with the correct type doesn't have the tag
            Assert.Null(_componentCollection.GetFirstOrDefault <Component1>(tag2));

            // Create and add a component of a different type, with no tag
            var component2 = new Component2();

            _componentCollection.Add(component2);

            // Null because the object we added has no tag
            Assert.Null(_componentCollection.GetFirstOrDefault <Component2>(tag2));
        }
        public void ContainsBasic()
        {
            // Create and add a component
            var component = new Component1();

            _componentCollection.Add(component);

            // Component1 qualifies as both of these types, so both should be true.
            Assert.True(_componentCollection.Contains <Component1>());
            Assert.True(_componentCollection.Contains <ComponentBase>());

            // Component1 is NOT this type, so this is false
            Assert.False(_componentCollection.Contains <Component2>());

            // Create and add a component of a different type
            var component2 = new Component2();

            _componentCollection.Add(component2);

            // Now all 3 should be true
            Assert.True(_componentCollection.Contains <Component1>());
            Assert.True(_componentCollection.Contains <ComponentBase>());
            Assert.True(_componentCollection.Contains <Component2>());

            _componentCollection.Remove(component);

            Assert.False(_componentCollection.Contains <Component1>());
            Assert.True(_componentCollection.Contains <ComponentBase>()); // Component2 qualifies
            Assert.True(_componentCollection.Contains <Component2>());
        }
Exemple #7
0
 public Mediator(Component1 component1, Component2 component2)
 {
     _component1 = component1;
     _component1.SetMediator(this);
     _component2 = component2;
     _component2.SetMediator(this);
 }
Exemple #8
0
 public ConcreteMediator(Component1 component1, Component2 component2)
 {
     this._component1 = component1;
     this._component1.SetMediator(this);
     this._component2 = component2;
     this._component2.SetMediator(this);
 }
        public void RemoveEntity()
        {
            var                component1Type = ComponentType.Create <Component1>();
            var                component2Type = ComponentType.Create <Component2>();
            EntityTypeChunk    chunk          = new EntityTypeChunk(null, EntityTypes.Type1);
            ArrayList <Entity> entities       = new ArrayList <Entity>(5);
            ArrayList <int>    values         = new ArrayList <int>(5);

            for (int k = 0; k < 5; k++)
            {
                entities.Add(chunk.AddEntity(new Entity(), null));
                var component1Data = Data <Component1>(chunk.ComponentDatas[component1Type.TypeIndex]);
                var component2Data = Data <Component2>(chunk.ComponentDatas[component2Type.TypeIndex]);
                component1Data[k]       = new Component1();
                component1Data[k].Value = k;
                component2Data[k].Value = k;
                values.Add(k);
            }
            chunk.RemoveEntity(entities[0], null);
            entities.UnorderedRemoveAt(0);
            values.UnorderedRemoveAt(0);
            Assert.AreEqual(4, chunk.EntityCount);
            for (int k = 0; k < chunk.EntityCount; k++)
            {
                Assert.AreEqual(entities[k], chunk.EntityData[k]);
                Assert.AreEqual(k, entities[k].IndexInChunk);
                ref var component1 = ref Data <Component1>(chunk.ComponentDatas[component1Type.TypeIndex])[k];
                Assert.AreEqual(values[k], component1.Value);
                ref var component2 = ref Data <Component2>(chunk.ComponentDatas[component2Type.TypeIndex])[k];
        public void RemoveTag()
        {
            var component  = new Component1();
            var component2 = new Component2();
            var component3 = new Component2();

            // Ensure _addedCount increments so we're actually testing on decrement
            _componentCollection.Add(component, "tag1");
            _componentCollection.Add(component2);
            _componentCollection.Add(component3, "tag3");
            Assert.Equal(3, _addedCount);


            // Remove should remove component
            _componentCollection.Remove("tag1");
            Assert.Equal(2, _addedCount);
            Assert.Null(_componentCollection.GetFirstOrDefault <Component1>());

            // Should throw because no such tag exists after the previous remove
            Assert.Throws <ArgumentException>(() => _componentCollection.Remove("tag1"));

            // Tag exists so we just leave the one without tag
            _componentCollection.Remove("tag3");
            Assert.Equal(1, _addedCount);
        }
        public override int GetHashCode()
        {
            var h1 = Component1 == null ? 0 : Component1.GetHashCode();
            var h2 = Component2 == null ? 0 : Component2.GetHashCode();
            var h3 = Component3 == null ? 0 : Component3.GetHashCode();

            return(Id ^ h1 ^ h2 ^ h3);
        }
        public void ScreenObject_SaveLoad()
        {
            new SadConsole.Tests.BasicGameHost();
            ScreenObject obj = new ScreenObject();

            obj.Position    = (10, 10);
            obj.IsEnabled   = false;
            obj.IsVisible   = false;
            obj.UseKeyboard = true;
            obj.UseMouse    = false;

            ScreenObject obj2 = new ScreenObject();

            obj2.Position    = (15, 2);
            obj2.IsEnabled   = true;
            obj2.IsVisible   = false;
            obj2.UseKeyboard = false;
            obj2.UseMouse    = true;

            obj.Children.Add(obj2);

            Component1 comp1 = new Component1()
            {
                Name = "component 1"
            };
            Component1 comp2 = new Component1()
            {
                Name = "component 2"
            };

            obj.SadComponents.Add(comp1);
            obj2.SadComponents.Add(comp2);

            SadConsole.Serializer.Save(obj, "test.file", false);
            var newObj = SadConsole.Serializer.Load <ScreenObject>("test.file", false);

            Assert.AreEqual(obj.Position, newObj.Position);
            Assert.AreEqual(obj.IsEnabled, newObj.IsEnabled);
            Assert.AreEqual(obj.IsVisible, newObj.IsVisible);
            Assert.AreEqual(obj.UseKeyboard, newObj.UseKeyboard);
            Assert.AreEqual(obj.UseMouse, newObj.UseMouse);
            Assert.AreEqual(obj.AbsolutePosition, newObj.AbsolutePosition);

            Assert.AreEqual(obj2.Position, newObj.Children[0].Position);
            Assert.AreEqual(obj2.IsEnabled, newObj.Children[0].IsEnabled);
            Assert.AreEqual(obj2.IsVisible, newObj.Children[0].IsVisible);
            Assert.AreEqual(obj2.UseKeyboard, newObj.Children[0].UseKeyboard);
            Assert.AreEqual(obj2.UseMouse, newObj.Children[0].UseMouse);
            Assert.AreEqual(obj2.AbsolutePosition, newObj.Children[0].AbsolutePosition);

            Assert.IsInstanceOfType(newObj.Children[0], typeof(ScreenObject));

            Assert.AreEqual(obj.SadComponents.Count, newObj.SadComponents.Count);
            Assert.AreEqual(obj2.SadComponents.Count, newObj.Children[0].SadComponents.Count);

            Assert.AreEqual(comp1.Name, ((Component1)newObj.SadComponents[0]).Name);
            Assert.AreEqual(comp2.Name, ((Component1)newObj.Children[0].SadComponents[0]).Name);
        }
Exemple #13
0
        public void VerifyCollectionOfEmbeddableWithNullValue()
        {
            var componentV1 = new Component1 {
                Str1 = "string1", Str2 = null
            };
            var entityV1 = AuditReader().Find <ComponentSetTestEntity>(id2, 1);

            entityV1.Comps.Should().Have.SameSequenceAs(componentV1);
        }
Exemple #14
0
        public void TestMethodTest()
        {
            Parameters params1 = new Parameters();

            params1.prop1 = "Jee this is the unit test!";
            var result = Component1.TestMethod(params1);

            Assert.AreSame("Jee this is the unit test!", result);
        }
        public void MediatorTest()
        {
            // The client code.
            var component1 = new Component1();
            var component2 = new Component2();

            new ConcreteMediator(component1, component2);
            component1.DoA().Should().Be("A");
            component2.DoD().Should().Be("D");;
        }
Exemple #16
0
        private void btnComponent_Click(object sender, EventArgs e)
        {
            Component1 cd;
            int        i;

            for (i = 0; i < 1000; i++)
            {
                cd = new Component1();
            }
        }
Exemple #17
0
        public static void Run()
        {
            Component1 component1 = new Component1();
            Component2 component2 = new Component2();

            Mediator mediator = new Mediator(component1, component2);

            System.Console.WriteLine("Client triggers component 1 to do A");
            component1.OperateA();
        }
Exemple #18
0
        public App()
        {
            Component1 c1 = new Component1();
            Component2 c2 = new Component2();
            Component3 c3 = new Component3();

            Window.Require("comp4", delegate() {
                Component4 c4 = new Component4();
            });
        }
Exemple #19
0
        public void DynamicStateMachine_Type()
        {
            // Arrange
            var entity = new Entity();
            var component1_at_arrange = new Component1();

            entity.Add(component1_at_arrange);
            var machine = new DynamicStateMachine <Entity, IComponent>(entity, s => entity.Add(s), s => entity.Remove(s));

            machine
            .CreateState("A")
            .Add(typeof(Component2));
            machine
            .CreateState("B")
            .Add(typeof(Component3))
            .Add <Component4>();
            machine
            .CreateState("C")
            .Add(typeof(Component3));

            // Act & Assert
            Assert.AreEqual(entity.components.Count, 1);
            Assert.AreEqual(entity.Get <Component1>(), component1_at_arrange);

            machine.ChangeState("A");
            Assert.AreEqual(entity.components.Count, 2);
            Assert.AreEqual(entity.Get <Component1>(), component1_at_arrange);
            var component2_at_first = entity.Get <Component2>();

            Assert.AreEqual(component2_at_first.GetType(), typeof(Component2));

            machine.ChangeState("B");
            Assert.AreEqual(entity.components.Count, 3);
            Assert.AreEqual(entity.Get <Component1>(), component1_at_arrange);
            var component3_at_first = entity.Get <Component3>();

            Assert.AreEqual(component3_at_first.GetType(), typeof(Component3));
            Assert.AreEqual(entity.Get <Component4>().GetType(), typeof(Component4));

            machine.ChangeState("C");
            Assert.AreEqual(entity.components.Count, 2);
            Assert.AreEqual(entity.Get <Component1>(), component1_at_arrange);
            var component3_at_second = entity.Get <Component3>();

            Assert.AreEqual(component3_at_second.GetType(), typeof(Component3));
            Assert.AreEqual(component3_at_first, component3_at_second);

            machine.ChangeState("A");
            Assert.AreEqual(entity.components.Count, 2);
            Assert.AreEqual(entity.Get <Component1>(), component1_at_arrange);
            var component2_at_second = entity.Get <Component2>();

            Assert.AreEqual(component2_at_second.GetType(), typeof(Component2));
            Assert.AreNotEqual(component2_at_first, component2_at_second);
        }
Exemple #20
0
        public App()
        {
            Component1 c1 = new Component1();
            Component2 c2 = new Component2();
            Component3 c3 = new Component3();

            Window.Require("comp4", delegate() {
                Component4 c4 = new Component4();
            });

            Window.Alert(Templates.DataTemplate);
        }
Exemple #21
0
    private static void Main()
    {
        var watcher   = new ClipboardWatcher(OnChange);
        var component = new Component1();

        component.mOnExit += () =>
        {
            watcher.End();
            Application.Exit();
        };

        Application.Run();
    }
        public static void ClientCode()
        {
            Component1 component1 = new Component1();
            Component2 component2 = new Component2();
            Mediator   mediator   = new ConcreteMediator(component1, component2);

            Console.Write("Client triggets operation A.\n");
            component1.doA();

            Console.WriteLine();

            Console.Write("Client triggers operation D.\n");
            component2.doD();
        }
Exemple #23
0
        public void Run()
        {
            Component1 component1 = new Component1();
            Component2 component2 = new Component2();

            new ConcreteMediator(component1, component2);

            Console.WriteLine("Client triggets operation A.");
            component1.DoA();

            Console.WriteLine();

            Console.WriteLine("Client triggers operation D.");
            component2.DoD();
        }
        public override bool Equals(object obj)
        {
            var casted = obj as VersionsJoinTableRangeComponentTestEntity;

            if (casted == null)
            {
                return(false);
            }
            if (Id != casted.Id)
            {
                return(false);
            }
            if (Component1 == null)
            {
                if (casted.Component1 != null)
                {
                    return(false);
                }
            }
            else if (!Component1.Equals(casted.Component1))
            {
                return(false);
            }
            if (Component2 == null)
            {
                if (casted.Component2 != null)
                {
                    return(false);
                }
            }
            else if (!Component2.Equals(casted.Component1))
            {
                return(false);
            }
            if (Component3 == null)
            {
                if (casted.Component3 != null)
                {
                    return(false);
                }
            }
            else if (!Component3.Equals(casted.Component1))
            {
                return(false);
            }

            return(true);
        }
Exemple #25
0
        public void Ex1()
        {
            // The client code.
            Component1 component1 = new Component1();
            Component2 component2 = new Component2();

            new ConcreteMediator(component1, component2);

            Console.WriteLine("Client triggers operation A.");
            component1.DoA(); // Triggar även C

            Console.WriteLine();

            Console.WriteLine("Client triggers operation D.");
            component2.DoD(); // Triggar även B och C
        }
Exemple #26
0
        static void Main(string[] args)
        {
            // The client code.
            Component1 component1 = new Component1();
            Component2 component2 = new Component2();

            new ConcreteMediator(component1, component2);

            Console.WriteLine("Client triggets operation A.");
            component1.DoA();

            Console.WriteLine();

            Console.WriteLine("Client triggers operation D.");
            component2.DoD();
        }
        public void AddBasic()
        {
            var component  = new Component1();
            var component2 = new Component1();

            // Should not throw
            _componentCollection.Add(component);
            Assert.Equal(1, _addedCount);

            // Should throw exception because it's a duplicate object
            Assert.Throws <ArgumentException>(() => _componentCollection.Add(component));
            Assert.Equal(1, _addedCount);

            // Multiple objects of same type, however, are allowed
            _componentCollection.Add(component2);
            Assert.Equal(2, _addedCount);
        }
        public void GetFirstOrDefaultPriority()
        {
            var component  = new SortedComponent(1);
            var component2 = new SortedComponent(2);
            var component3 = new SortedComponent(4);

            var component4 = new Component1(); // Not a sorted component

            // Ensure to add out of order
            _componentCollection.Add(component2);
            _componentCollection.Add(component);
            _componentCollection.Add(component4);
            _componentCollection.Add(component3);

            // Lowest priority of all the components of a type is always returned here
            Assert.Same(component, _componentCollection.GetFirstOrDefault <ComponentBase>());
            Assert.Same(component, _componentCollection.GetFirstOrDefault <Component1>());
            Assert.Same(component, _componentCollection.GetFirstOrDefault <SortedComponent>());
        }
        public void RemoveBasic()
        {
            var component  = new Component1();
            var component2 = new Component2();

            // Ensure _addedCount increments so we're actually testing on decrement
            _componentCollection.Add(component);
            _componentCollection.Add(component2);
            Assert.Equal(2, _addedCount);

            _componentCollection.Remove(component);
            Assert.Equal(1, _addedCount);

            // Should throw because object isn't in the component list
            Assert.Throws <ArgumentException>(() => _componentCollection.Remove(component));
            Assert.Equal(1, _addedCount);

            _componentCollection.Remove(component2);
            Assert.Equal(0, _addedCount);
        }
        public void AddTag()
        {
            var component  = new Component1();
            var component2 = new Component1();

            // Should not throw
            _componentCollection.Add(component, "Tag1");
            Assert.Equal(1, _addedCount);

            // Should throw exception because it's a duplicate object
            Assert.Throws <ArgumentException>(() => _componentCollection.Add(component, "Tag10"));
            Assert.Equal(1, _addedCount);

            // Should throw exception because it's a duplicate tag
            Assert.Throws <ArgumentException>(() => _componentCollection.Add(component2, "Tag1"));
            Assert.Equal(1, _addedCount);

            // Duplicate types are still allowed, however
            _componentCollection.Add(component2, "Tag2");
            Assert.Equal(2, _addedCount);
        }
		public Component1 componentOf;					//0..1

		public KnowledgeRequestNotification() {
			classCode="ACT";
			moodCode="DEF";
			IdList=new List<Id>();
			effectiveTime=DateTime.Now;
			subject1=new Subject();
			subject2=new Subject1();
			subject3=new Subject2();
			subject4List=new List<Subject3>();
			componentOf=new Component1();
		}
Exemple #32
0
        private static void MakeComponentOfNode(ClinicalDocument ccda)
        {
            AssignedEntity ae = MakeAssignedEntity("ComponentOf");

            EncompassingEncounter ee = new EncompassingEncounter();
            ee.Id = new SET<II>(new II(new Guid()));
            ee.EffectiveTime = new IVL<TS>(new TS(DateTime.Now), new TS(DateTime.Now));

            ee.ResponsibleParty = new ResponsibleParty();

            ee.ResponsibleParty.AssignedEntity = ae;

            Location loc = new Location();
            loc.HealthCareFacility = MakeHealthCareFacility();

            ee.Location = new Location();
            ee.Location = loc;

            Component1 componentOf = new Component1();
            componentOf.EncompassingEncounter = new EncompassingEncounter();
            componentOf.EncompassingEncounter = ee;

            ccda.ComponentOf = new Component1();
            ccda.ComponentOf = componentOf;
        }
 public IntermediateService(Component1 component1)
 {
     this.component1 = component1;
     LogBuilder.Append("IntermediateService.ctor ");
 }