public void AutoMapperConversionTest()
        {
            var config = AutoMapperExtensions.CreateConfig();
            var mapper = config.CreateMapper();

            var entityA = new TestEntityA {
                Id = 7, Name = "Testing...", ComplexProp = new TestEntityC {
                    Code = Guid.NewGuid(), Item = "Something", Value = 54.36m
                }
            };
            var entityB = mapper.Map <TestEntityB>(entityA);

            Assert.IsTrue(entityA?.Id == entityB?.Number);
            Assert.IsTrue(entityA?.Name == entityB?.Username);
            Assert.IsTrue(entityA?.ComplexProp.Code == entityB?.Code);
            Assert.IsTrue(entityA?.ComplexProp.Value == (decimal)entityB?.CodePrice);

            entityB = new TestEntityB {
                Number = 15, Username = "******", Code = Guid.NewGuid(), CodePrice = 45.66f
            };
            entityA = mapper.Map <TestEntityA>(entityB);

            Assert.IsTrue(entityA?.Id == entityB?.Number);
            Assert.IsTrue(entityA?.Name == entityB?.Username);
            Assert.IsTrue(entityA?.ComplexProp.Code == entityB?.Code);
            Assert.IsTrue(entityA?.ComplexProp.Value == (decimal)entityB?.CodePrice);
        }
Exemplo n.º 2
0
        public void TestLazyEntityIdReference()
        {
            EntityIdRegistry <TestEntityA> testEntityARegistry = new EntityIdRegistry <TestEntityA>();
            EntityIdRegistry <TestEntityB> testEntityBRegistry = new EntityIdRegistry <TestEntityB>();

            TestEntityA testEntityA0 = new TestEntityA("TestEntityA0");
            TestEntityA testEntityA1 = new TestEntityA("TestEntityA1");
            TestEntityA testEntityA2 = new TestEntityA("TestEntityA2");

            int testEntityA0Id = testEntityARegistry.Add(testEntityA0);
            int testEntityA1Id = testEntityARegistry.Add(testEntityA1);
            int testEntityA2Id = testEntityARegistry.Add(testEntityA2);

            TestEntityB testEntityB0 = new TestEntityB("TestEntityB0", testEntityARegistry, testEntityARegistry.ToId(testEntityA1), testEntityARegistry.ToId(testEntityA2));
            TestEntityB testEntityB1 = new TestEntityB("TestEntityB1", testEntityARegistry, testEntityARegistry.ToId(testEntityA2), testEntityARegistry.ToId(testEntityA2));
            TestEntityB testEntityB2 = new TestEntityB("TestEntityB2", testEntityARegistry, 0, 0);

            int testEntityB0Id = testEntityBRegistry.Add(testEntityB0);
            int testEntityB1Id = testEntityBRegistry.Add(testEntityB1);
            int testEntityB2Id = testEntityBRegistry.Add(testEntityB2);

            Assert.AreEqual("TestEntityB0", testEntityB0.Name);
            Assert.IsNotNull(testEntityB0.RelatedReadOnlyEntity);
            Assert.AreEqual("TestEntityA1", testEntityB0.RelatedReadOnlyEntity.Name);
            Assert.IsNotNull(testEntityB0.RelatedChangableEntity);
            Assert.AreEqual("TestEntityA2", testEntityB0.RelatedChangableEntity.Name);
            Assert.AreEqual("TestEntityB2", testEntityB2.Name);
            Assert.IsNull(testEntityB2.RelatedReadOnlyEntity);

            testEntityB0.RelatedChangableEntity = testEntityA0;
            Assert.AreEqual("TestEntityA0", testEntityB0.RelatedChangableEntity.Name);
        }
Exemplo n.º 3
0
        private void Dispatcher_Test_NoResult()
        {
            var business = new TestMethodBussiness();

            m_wxDispatcher.RegisterHandlersByAttribute(business, typeof(TestMethodAttribute));
            var a = new TestEntityA();

            m_wxDispatcher.Dispatch(a, false);
            Assert.Equal(a, business.ResultA);
            var b = new TestEntityB();

            m_wxDispatcher.Dispatch(b);
            Thread.Sleep(100);
            Assert.Equal(b, business.ResultB);
        }
Exemplo n.º 4
0
 public void TestMethodA(TestEntityA A)
 {
     ResultA = A;
     WxLog.Debug($"TestMethodBussiness.TestMethodA{A.GetType().FullName}");
 }