Exemplo n.º 1
0
        public void InsertEntity(IDbConnection dbConnection)
        {
            QueryHelper.FlushCache();

            var keys = new
            {
                Id1 = Guid.NewGuid(),
                Id2 = Guid.NewGuid()
            };

            Model3 entity = new Model3()
            {
                Id1   = keys.Id1,
                Id2   = keys.Id2,
                Prop1 = "ENTITY 3"
            };

            using (var connection = dbConnection)
            {
                connection.Open();

                connection.Insert(entity);

                entity = connection.Get <Model3>(keys);

                Assert.NotNull(entity);
                Assert.Equal("ENTITY 3", entity.Prop1);

                connection.Close();
            }
        }
Exemplo n.º 2
0
 public Model3Form(Model3 tunnelModel) : base(tunnelModel)
 {
     InitializeComponent();
     //
     _model3 = tunnelModel;
     tunnelConstructor1.TunnelPointorChanged += TunnelConstructor1_TunnelPointorChanged;
 }
Exemplo n.º 3
0
        public void UpdateEntity(IDbConnection dbConnection)
        {
            QueryHelper.FlushCache();

            Model3 entity = null;
            bool   found  = true;

            using (var connection = dbConnection)
            {
                connection.Open();

                entity       = connection.Get <Model3>(new { Id1 = Entity2Id.Item1, Id2 = Entity2Id.Item2 });
                entity.Prop1 = "ENTITY 2 UPDATED";

                found = connection.Update(entity);

                entity = connection.Get <Model3>(new { Id1 = Entity2Id.Item1, Id2 = Entity2Id.Item2 });

                connection.Close();
            }

            Assert.True(found);
            Assert.NotNull(entity);
            Assert.Equal("ENTITY 2 UPDATED", entity.Prop1);
        }
Exemplo n.º 4
0
        public ActionResult Detail(String id)
        {
            Model3    db       = new Model3();
            List <SP> sanPhams = db.SPs.Where(sp => sp.masp.Contains(id)).ToList();

            return(View(sanPhams));
        }
Exemplo n.º 5
0
        public void DeleteEntityById(IDbConnection dbConnection)
        {
            QueryHelper.FlushCache();

            var keys = new
            {
                Id1 = Guid.NewGuid(),
                Id2 = Guid.NewGuid()
            };

            Model3 entity = new Model3()
            {
                Id1   = keys.Id1,
                Id2   = keys.Id2,
                Prop1 = "ENTITY 10"
            };

            bool found = false;

            using (var connection = dbConnection)
            {
                connection.Open();
                connection.Insert(entity);

                found  = connection.Delete(entity);
                entity = connection.Get <Model3>(keys);
                connection.Close();
            }

            Assert.True(found);
            Assert.Null(entity);
        }
Exemplo n.º 6
0
        public void FinderulesInProperty()
        {
            var model    = new Model3();
            var property = model.GetType().GetProperty(nameof(model.Text));
            var rules    = model.GetType().GetRulesForProperty(property);

            Assert.IsNotNull(rules);
            Assert.IsTrue(rules.Any());
        }
Exemplo n.º 7
0
        public void FinderulesInProperty()
        {
            var model    = new Model3();
            var property = model.GetType().GetProperty(nameof(model.Text));
            var rules    = this.sut.GetRulesForProperty(model.GetType(), property, RuleType.Default);

            Assert.IsNotNull(rules);
            Assert.IsTrue(rules.Any());
        }
Exemplo n.º 8
0
        public void AllwaysRun(Option <Model1> none1, Option <Model2> none2, Model3 _)
        {
            if (none1.HasValue || none2.HasValue)
            {
                return;
            }

            Interlocked.Increment(ref _allwaysRunCount);
        }
Exemplo n.º 9
0
        public async Task PushExceptionsWithTopic()
        {
            Registrar   registrar = new Registrar();
            TestHorseMq server    = new TestHorseMq();

            server.SendAcknowledgeFromMQ = false;
            await server.Initialize();

            int port = server.Start(300, 300);

            HmqStickyConnector producer = new HmqAbsoluteConnector(TimeSpan.FromSeconds(10));

            producer.AddHost("hmq://localhost:" + port);
            producer.Run();

            HmqStickyConnector consumer = new HmqAbsoluteConnector(TimeSpan.FromSeconds(10));

            consumer.AddHost("hmq://localhost:" + port);
            registrar.Register(consumer);
            consumer.Run();

            await Task.Delay(500);

            Assert.True(producer.IsConnected);
            Assert.True(consumer.IsConnected);

            Model3 model = new Model3();

            HorseResult push1 = await producer.Bus.Queue.PushJson(model, true);

            Assert.Equal(HorseResultCode.Failed, push1.Code);
            await Task.Delay(100);

            Assert.Equal(1, ExceptionConsumer1.Instance.Count);
            Assert.Equal(0, ExceptionConsumer2.Instance.Count);
            Assert.Equal(0, ExceptionConsumer3.Instance.Count);

            HorseResult push2 = await producer.Bus.Queue.PushJson(model, true);

            Assert.Equal(HorseResultCode.Failed, push2.Code);
            await Task.Delay(100);

            Assert.Equal(1, ExceptionConsumer1.Instance.Count);
            Assert.Equal(1, ExceptionConsumer2.Instance.Count);
            Assert.Equal(0, ExceptionConsumer3.Instance.Count);

            HorseResult push3 = await producer.Bus.Queue.PushJson(model, true);

            Assert.Equal(HorseResultCode.Failed, push3.Code);
            await Task.Delay(100);

            Assert.Equal(1, ExceptionConsumer1.Instance.Count);
            Assert.Equal(1, ExceptionConsumer2.Instance.Count);
            Assert.Equal(1, ExceptionConsumer3.Instance.Count);

            Assert.Equal(3, QueueConsumer3.Instance.Count);
        }
Exemplo n.º 10
0
        public void CanResolveOneWayEdgeConnectionBetween2DifferentModelTypes()
        {
            const string srcId   = "model2_1";
            const string destId  = "model3_1";
            int          counter = 0;

            Model2 m2_1 = null;
            Model3 m3_1 = null;

            var model2 = new Model2
            {
                Id     = srcId,
                Field1 = "f1",
                Field2 = 34,
                Edge   = new Model2ConnectionToModel3
                {
                    Field1 = "f12",
                    Id     = destId,
                    Model3 = new Model3
                    {
                        Id     = destId,
                        Field1 = "barr"
                    }
                }
            };

            var edges = _connectionFieldResolver.HandleConnectionEdges(model2, (entity) =>
            {
                if (entity is Model2 em2)
                {
                    if (em2.Id == srcId)
                    {
                        m2_1 = em2;
                    }
                }

                if (entity is Model3 em3)
                {
                    if (em3.Id == destId)
                    {
                        m3_1 = em3;
                    }
                }

                counter++;
            });

            counter.ShouldBe(2);

            edges.ShouldNotBeNull();
            edges.Count.ShouldBe(1);

            m2_1.ShouldNotBeNull();
            m3_1.ShouldNotBeNull();

            AssertEdge(edges[0], srcId, destId);
        }
Exemplo n.º 11
0
        static void Main()
        {
            var model3 = new Model3(new EasySteeringWheel(), new DefaultBreak());

            var form = new TeslaModel3_IO();

            form.Car = model3;
            form.ShowDialog();

            Console.ReadKey();
        }
Exemplo n.º 12
0
        public void ShouldMapComplexObjectWhenInnerPropIsNull()
        {
            var data = new Model3 {
                Inner = null
            };


            var target = data.Map(ObjectMapper <Model3, Dto3> .Default);

            target.Should().BeEquivalentTo(new Dto3()
            {
                Inner = null
            });
        }
Exemplo n.º 13
0
        public void TestConvertToBothForNestedLevel1()
        {
            IModel3 <IModel2> sample = new Model3 <IModel2>
            {
                Number = 123,
                Prop   = new Model2
                {
                    Id = "strstr",
                    No = 3242423
                }
            };

            TestConvertToBoth(sample);
        }
Exemplo n.º 14
0
        public void GetNonExistingEntity(IDbConnection dbConnection)
        {
            QueryHelper.FlushCache();

            Model3 entity = null;

            using (var connection = dbConnection)
            {
                connection.Open();
                entity = connection.Get <Model3>(new { Id1 = Guid.Empty, Id2 = Guid.Empty });
                connection.Close();
            }

            Assert.Null(entity);
        }
Exemplo n.º 15
0
        public void InsertSingleShot(IDbConnection dbConnection)
        {
            QueryHelper.FlushCache();

            var keys1 = new { Id1 = Guid.NewGuid(), Id2 = Guid.NewGuid() };
            var keys2 = new { Id1 = Guid.NewGuid(), Id2 = Guid.NewGuid() };

            Model3 entity1 = new Model3()
            {
                Id1 = keys1.Id1, Id2 = keys1.Id2, Prop1 = "ENTITY 10"
            };
            Model3 entity2 = new Model3()
            {
                Id1 = keys2.Id1, Id2 = keys2.Id2, Prop1 = "ENTITY 11"
            };

            var entities = new List <Model3>()
            {
                { entity1 },
                { entity2 }
            };

            using (var connection = dbConnection)
            {
                connection.Open();

                var count = connection.InsertMany <Model3>(entities, operationMode: OperationMode.SingleShot);

                Assert.Equal(keys1.Id1, entity1.Id1);
                Assert.Equal(keys1.Id2, entity1.Id2);
                Assert.Equal(keys2.Id1, entity2.Id1);
                Assert.Equal(keys2.Id2, entity2.Id2);
                Assert.Equal(2, count);

                entity1 = connection.Get <Model3>(keys1);

                Assert.NotNull(entity1);
                Assert.Equal("ENTITY 10", entity1.Prop1);

                entity2 = connection.Get <Model3>(keys2);

                Assert.NotNull(entity2);
                Assert.Equal("ENTITY 11", entity2.Prop1);

                connection.Close();
            }
        }
Exemplo n.º 16
0
        public void ShouldMapComplexObjectWhenInnerPropHasValue()
        {
            var data = new Model3 {
                Inner = new InnerModel3()
                {
                    InnerStrProp = "str"
                }
            };
            var target = data.Map(ObjectMapper <Model3, Dto3> .Default);

            target.Should().BeEquivalentTo(new Dto3()
            {
                Inner = new InnerDto3()
                {
                    InnerStrProp = "str"
                }
            });
        }
Exemplo n.º 17
0
        public void GetEntityById(IDbConnection dbConnection)
        {
            QueryHelper.FlushCache();

            Model3 entity = null;

            using (var connection = dbConnection)
            {
                connection.Open();
                entity = connection.Get <Model3>(new { Id1 = Entity1Id.Item1, Id2 = Entity1Id.Item2 });
                connection.Close();
            }

            Assert.NotNull(entity);
            Assert.Equal(Entity1Id.Item1, entity.Id1);
            Assert.Equal(Entity1Id.Item2, entity.Id2);
            Assert.Equal("ENTITY 1", entity.Prop1);
        }
Exemplo n.º 18
0
        public void NotExistsEntity(IDbConnection dbConnection)
        {
            QueryHelper.FlushCache();

            bool exists = false;
            var  key    = new Model3 {
                Id1 = Guid.NewGuid(), Id2 = Guid.NewGuid()
            };

            using (var connection = dbConnection)
            {
                connection.Open();
                exists = connection.Exists <Model3>(key);
                connection.Close();
            }

            Assert.False(exists);
        }
Exemplo n.º 19
0
        public void ExistsEntity(IDbConnection dbConnection)
        {
            QueryHelper.FlushCache();

            bool exists = false;
            var  key    = new Model3 {
                Id1 = Entity1Id.Item1, Id2 = Entity1Id.Item2
            };

            using (var connection = dbConnection)
            {
                connection.Open();
                exists = connection.Exists <Model3>(key);
                connection.Close();
            }

            Assert.True(exists);
        }
Exemplo n.º 20
0
        public void RedrawModel3()
        {
            foreach (var ser in Model3.Series)
            {
                (ser as LineSeries).Points.Clear();
            }
            var minHz  = Signals.Min(s => s.Hz0);
            var toTime = 7d / minHz;

            for (int i = 0; i < 4; i++)
            {
                var ser     = Model3.Series[i] as LineSeries;
                var sInterp = Signals[i].GetInterpSignal(0, toTime, nPoints: 1000);
                ser.Points.AddRange(sInterp.DataPoints(y => y + 4.5 - i * 1.5));
            }

            Model3.InvalidatePlot(false);
        }
Exemplo n.º 21
0
        public void Get_IValidatorExpression_Ignore()
        {
            // arrange
            var factory = new ValidationExpressionErrorMessageFactory <Model3, bool>();

            factory.SetPropName("AreYouHappy");
            Expression <Func <bool, IValidatorExpression, bool> > exp = (m, validator) => validator.Ignore();

            factory.SetupExpression(exp);

            var model = new Model3();

            // act
            Action action = () => factory.Invoke(model);

            // assert
            action.Should().NotThrow();
        }
Exemplo n.º 22
0
        public void Get_IValidatorExpression_MinLength()
        {
            // arrange
            var factory = new ValidationExpressionErrorMessageFactory <Model3, string>();

            factory.SetPropName("email");
            Expression <Func <string, IValidatorExpression, bool> > exp = (email, validator) => validator.MinLength(email, 3, null);

            factory.SetupExpression(exp);

            var model = new Model3 {
                EmailAddress = "*****@*****.**"
            };

            // act
            Action action = () => factory.Invoke(model);

            // assert
            action.Should().NotThrow();
        }
Exemplo n.º 23
0
        public void Get_IValidatorExpression_MinValue()
        {
            // arrange
            var factory = new ValidationExpressionErrorMessageFactory <Model3, int>();

            factory.SetPropName("Number");
            Expression <Func <int, IValidatorExpression, bool> > exp = (number, validator) => validator.MinValue(number, 18, null);

            factory.SetupExpression(exp);

            var model = new Model3 {
                Number = 23
            };

            // act
            Action action = () => factory.Invoke(model);

            // assert
            action.Should().NotThrow();
        }
Exemplo n.º 24
0
        public void UpdateMany(IDbConnection dbConnection)
        {
            QueryHelper.FlushCache();

            Model3 entity1 = null;
            Model3 entity2 = null;

            bool found = true;

            using (var connection = dbConnection)
            {
                connection.Open();

                entity1 = connection.Get <Model3>(Entity1Id);
                entity2 = connection.Get <Model3>(Entity2Id);

                entity1.Prop1 = "ENTITY 1 UPDATED";

                entity2.Prop1 = "ENTITY 2 UPDATED";

                var entities = new List <Model3>()
                {
                    { entity1 },
                    { entity2 }
                };

                found = connection.UpdateMany <Model3>(entities);

                entity1 = connection.Get <Model3>(Entity1Id);
                entity2 = connection.Get <Model3>(Entity2Id);

                connection.Close();
            }

            Assert.True(found);
            Assert.NotNull(entity1);
            Assert.Equal("ENTITY 1 UPDATED", entity1.Prop1);

            Assert.NotNull(entity2);
            Assert.Equal("ENTITY 2 UPDATED", entity2.Prop1);
        }
Exemplo n.º 25
0
        public void DeleteNonExistingEntity(IDbConnection dbConnection)
        {
            QueryHelper.FlushCache();

            Model3 entity = new Model3()
            {
                Id1 = Guid.Empty,
                Id2 = Guid.Empty
            };

            bool found = false;

            using (var connection = dbConnection)
            {
                connection.Open();
                found = connection.Delete(entity);
                connection.Close();
            }

            Assert.False(found);
        }
Exemplo n.º 26
0
        public void DeleteMany(IDbConnection dbConnection)
        {
            QueryHelper.FlushCache();

            var keys1 = new { Id1 = Guid.NewGuid(), Id2 = Guid.NewGuid() };
            var keys2 = new { Id1 = Guid.NewGuid(), Id2 = Guid.NewGuid() };

            Model3 entity1 = new Model3()
            {
                Id1 = keys1.Id1, Id2 = keys1.Id2, Prop1 = "ENTITY 10"
            };
            Model3 entity2 = new Model3()
            {
                Id1 = keys2.Id1, Id2 = keys2.Id2, Prop1 = "ENTITY 11"
            };

            var entities = new List <Model3>()
            {
                { entity1 },
                { entity2 }
            };

            bool found = false;

            using (var connection = dbConnection)
            {
                connection.Open();
                connection.InsertMany <Model3>(entities);
                found   = connection.DeleteMany <Model3>(entities);
                entity1 = connection.Get <Model3>(keys1);
                entity2 = connection.Get <Model3>(keys2);
                connection.Close();
            }

            Assert.True(found);
            Assert.Null(entity1);
            Assert.Null(entity2);
        }
Exemplo n.º 27
0
        public void UpdateNonExistingEntity(IDbConnection dbConnection)
        {
            QueryHelper.FlushCache();

            Model3 entity = new Model3();

            entity.Id1   = Guid.Empty;
            entity.Id2   = Guid.Empty;
            entity.Prop1 = "ENTITY 10";

            bool found = true;

            using (var connection = dbConnection)
            {
                connection.Open();

                found = connection.Update(entity);

                connection.Close();
            }

            Assert.False(found);
        }
        //public void M3() { }

        public void M5(Model3 input)
        {
        }
Exemplo n.º 29
0
        public void AttachModelList(List <Object3D> objs)
        {
            for (int i = 0; i < objs.Count; ++i)
            {
                var ob        = objs[i];
                var vertColor = new Color4((float)i / objs.Count, 0, 1 - (float)i / objs.Count, 1);
                ob.Geometry.Colors = new HelixToolkit.Wpf.SharpDX.Core.Color4Collection(Enumerable.Repeat(vertColor, ob.Geometry.Positions.Count));
                ob.Geometry.UpdateOctree();
                ob.Geometry.UpdateBounds();

                context.Post((o) =>
                {
                    var scaleTransform = new Media3D.ScaleTransform3D(15, 15, 15);
                    var s = new MeshGeometryModel3D
                    {
                        Geometry         = ob.Geometry,
                        CullMode         = SharpDX.Direct3D11.CullMode.Back,
                        IsThrowingShadow = true,
                        Transform        = scaleTransform
                    };

                    var diffuseMaterial     = new DiffuseMaterial();
                    PBRMaterial pbrMaterial = null;
                    if (ob.Material is PhongMaterialCore p)
                    {
                        var phong = p.ConvertToPhongMaterial();
                        phong.RenderEnvironmentMap   = true;
                        phong.RenderShadowMap        = true;
                        phong.RenderSpecularColorMap = false;
                        s.Material = phong;
                        diffuseMaterial.DiffuseColor = p.DiffuseColor;
                        diffuseMaterial.DiffuseMap   = p.DiffuseMap;
                        pbrMaterial = new PBRMaterial()
                        {
                            AlbedoColor          = p.DiffuseColor,
                            AlbedoMap            = p.DiffuseMap,
                            NormalMap            = p.NormalMap,
                            RMAMap               = p.SpecularColorMap,
                            RenderShadowMap      = true,
                            RenderEnvironmentMap = true,
                        };
                    }
                    //if (ob.Transform != null && ob.Transform.Count > 0)
                    //{
                    //    s.Instances = ob.Transform;
                    //}
                    this.Model1.Add(s);

                    Model2.Add(new MeshGeometryModel3D()
                    {
                        Geometry         = ob.Geometry,
                        CullMode         = SharpDX.Direct3D11.CullMode.Back,
                        IsThrowingShadow = true,
                        Material         = NormalMaterial,
                        Transform        = scaleTransform
                    });

                    ModelNormalVector.Add(new MeshGeometryModel3D()
                    {
                        Geometry         = ob.Geometry,
                        CullMode         = SharpDX.Direct3D11.CullMode.Back,
                        IsThrowingShadow = true,
                        Material         = NormalVectorMaterial,
                        Transform        = scaleTransform
                    });
                    Model3.Add(new MeshGeometryModel3D()
                    {
                        Geometry         = ob.Geometry,
                        CullMode         = SharpDX.Direct3D11.CullMode.Back,
                        IsThrowingShadow = true,
                        Material         = diffuseMaterial,
                        Transform        = scaleTransform
                    });

                    Model4.Add(new MeshGeometryModel3D()
                    {
                        Geometry         = ob.Geometry,
                        CullMode         = SharpDX.Direct3D11.CullMode.Back,
                        IsThrowingShadow = true,
                        Material         = PositionMaterial,
                        Transform        = scaleTransform
                    });

                    Model5.Add(new MeshGeometryModel3D()
                    {
                        Geometry         = ob.Geometry,
                        CullMode         = SharpDX.Direct3D11.CullMode.Back,
                        IsThrowingShadow = true,
                        Material         = VertMaterial,
                        Transform        = scaleTransform
                    });

                    Model6.Add(new MeshGeometryModel3D()
                    {
                        Geometry         = ob.Geometry,
                        CullMode         = SharpDX.Direct3D11.CullMode.Back,
                        IsThrowingShadow = true,
                        Material         = ColorStripeMaterial,
                        Transform        = scaleTransform
                    });

                    Model7.Add(new MeshGeometryModel3D
                    {
                        Geometry         = ob.Geometry,
                        CullMode         = SharpDX.Direct3D11.CullMode.Back,
                        IsThrowingShadow = true,
                        Transform        = scaleTransform,
                        Material         = pbrMaterial
                    });
                }, null);
            }
        }
Exemplo n.º 30
0
        /// <summary> 创建一个新的模型子窗口 </summary>
        /// <param name="model">如果其值为 null,则会新构造一个<see cref="ModelBase"/>对象,
        /// 如果其值不为 null,则必须确保其<see cref="ModelBase.ModelType"/>属性与<see cref="ModelBase.CalculationMethod"/>属性 必须与前两个参数相同 </param>
        private MainForm CreateModelForm(ModelType type, CalculationMethod method, ModelBase model = null)
        {
            MainForm mf = null;
            //
            const byte typeBit = 10;
            var        mIndex  = (byte)type * typeBit + (byte)method;

            switch (mIndex)
            {
            // 矩形框架
            case (byte)ModelType.Frame * typeBit + (byte)CalculationMethod.InertialForce:
            {
                Model1 sm = null;
                if (model == null)
                {
                    sm = new Model1();
                    Program.ConstructStationModel(sm);
                }
                else
                {
                    sm = model as Model1;
                }
                mf = new Model1Form(sm);
                break;
            }

            case (byte)ModelType.Frame * typeBit + (byte)CalculationMethod.FanYingWeiYi:
            {
                Model2 sm = null;
                if (model == null)
                {
                    sm = new Model2();
                    // Program.ConstructStationModel(sm);
                }
                else
                {
                    sm = model as Model2;
                }
                mf = new Model2Form(sm);
                break;
            }

            case (byte)ModelType.Frame * typeBit + (byte)CalculationMethod.Method3:
            {
                break;
            }

            case (byte)ModelType.Frame * typeBit + (byte)CalculationMethod.Method4:
            {
                break;
            }

            // 圆形隧道
            case (byte)ModelType.Tunnel * typeBit + (byte)CalculationMethod.InertialForce:
            {
                Model3 tm = null;
                if (model == null)
                {
                    tm = new Model3();
                    //Program.ConstructStationModel(sm);
                }
                else
                {
                    tm = model as Model3;
                }
                mf = new Model3Form(tm);
                break;
            }

            case (byte)ModelType.Tunnel * typeBit + (byte)CalculationMethod.FanYingWeiYi:
            {
                break;
            }

            case (byte)ModelType.Tunnel * typeBit + (byte)CalculationMethod.Method3:
            {
                break;
            }

            case (byte)ModelType.Tunnel * typeBit + (byte)CalculationMethod.Method4:
            {
                break;
            }

            // 矿山法
            case (byte)ModelType.Model2 * typeBit + (byte)CalculationMethod.InertialForce:
            {
                break;
            }

            case (byte)ModelType.Model2 * typeBit + (byte)CalculationMethod.FanYingWeiYi:
            {
                break;
            }

            case (byte)ModelType.Model2 * typeBit + (byte)CalculationMethod.Method3:
            {
                break;
            }

            case (byte)ModelType.Model2 * typeBit + (byte)CalculationMethod.Method4:
            {
                break;
            }
            }
            // 为新创建的子窗口进行相关初始设置
            if (mf != null)
            {
                mf.FormClosed             += MfOnFormClosed;
                mf.Model.ModelNameChanged += ModelOnModelNameChanged;
                mf.SetAbqWorkingDir(Options.DefaultAbqWorkingDir);
                mf.Text = mf.Model.DescriptionName + @" - " + mf.Model.ModelName;
            }
            return(mf);
        }
 //public void M3() { }
 public void M5(Model3 input)
 {
 }