Esempio n. 1
0
        public void AddRemoveTest()
        {
            var ch      = new Character();
            var complex = AspectFactory.Complex();

            complex.Host = ch;
            var test = AspectFactory.Complex();

            complex.test = test;
            Assert.IsNotNull(complex.test);
            Assert.IsNotNull(complex["test"]);

            Assert.IsNull(complex["notExists"]);

            Assert.AreEqual(complex.test, test);
            Assert.AreEqual(complex["test"], test);

            Assert.AreEqual(test._host, ch);

            complex.Remove("test");
            Assert.IsNull(complex["test"]);

            test._host = null;

            complex["test"] = test;
            Assert.IsNotNull(complex.test);
            Assert.IsNotNull(complex["test"]);

            Assert.IsNull(complex["notExists"]);

            Assert.AreEqual(complex.test, test);
            Assert.AreEqual(complex["test"], test);

            Assert.AreEqual(test._host, ch);
        }
Esempio n. 2
0
        public void CloneTest()
        {
            var mockDestCombat = new Mock <IAspect>();
            var mockSrcCombat  = new Mock <IAspect>();

            mockSrcCombat.Setup(srcCombat => srcCombat.Clone())
            .Returns(mockDestCombat.Object);

            var mockDestStats = new Mock <IAspect>();
            var mockSrcStats  = new Mock <IAspect>();

            mockSrcStats.Setup(srcStats => srcStats.Clone())
            .Returns(mockDestStats.Object);

            var complex = AspectFactory.Complex();

            complex.combat = mockSrcCombat.Object;
            complex.stats  = mockSrcStats.Object;

            var clone = complex.Clone();

            Assert.IsNotNull(clone);
            mockSrcCombat.VerifyAll();
            mockDestCombat.VerifyAll();
        }
Esempio n. 3
0
        public Entity()
        {
            World = World.Instance;
            names = new List <string>();

            Aspects      = AspectFactory.Complex();
            Aspects.Host = this;
        }
Esempio n. 4
0
        public void DeserializeTest()
        {
            var complex = AspectFactory.Complex();

            complex.stats = AspectFactory.Stats();
            var data = JsonConvert.DeserializeObject("{ 'stats': {} }");

            complex.Deserialize(data);

            Assert.IsNotNull(complex.stats);
        }
Esempio n. 5
0
        public void SerializeTest()
        {
            var complex = AspectFactory.Complex();

            complex.stats  = AspectFactory.Stats();
            complex.health = AspectFactory.Health();

            var data = complex.Serialize();

            Assert.IsNotNull(data["stats"]);
            Assert.IsNotNull(data["health"]);
        }
Esempio n. 6
0
        public void ReceiveEventTest()
        {
            var ch      = new Character();
            var complex = AspectFactory.Complex();

            complex.Host = ch;
            var test = AspectFactory.Complex();

            complex.Add("test", test);

            var e = Event.Create("test_completed", EventReturnMethod.And);

            complex.ReceiveEvent(e);
            Assert.IsTrue(e.ReturnValue);
        }
Esempio n. 7
0
        public void SetHostTest()
        {
            var ch = new Character()
            {
                ShortDescr = "test"
            };
            var complex = AspectFactory.Complex();
            var test    = AspectFactory.Complex();

            complex.Add("test", test);

            complex.Host = ch;
            Assert.AreEqual(ch, complex.Host);
            Assert.AreEqual(ch, test.Host);
        }
Esempio n. 8
0
 public void ComplexTest()
 {
     Assert.IsNotNull(AspectFactory.Complex());
 }