Example #1
0
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            var list = new Area[]
            {
                new Area{Name = "A", SOATO = "17"},
                new Area{Name = "B", SOATO = "175"},
                new Area{Name = "C", SOATO = "18"},
                new Area{Name = "A", SOATO = "17"},
            };

            var list2 = list.Where(x => x.Name != "A").Select(x => x.SOATO);
            foreach (var item in list2)
            {
                Debug.WriteLine(item);
            }

            Type t = typeof(Area);
            var pe = System.Linq.Expressions.Expression.Parameter(t);
            var mi = t.GetField("Name");
            var me = System.Linq.Expressions.Expression.MakeMemberAccess(pe, mi);
            var c = System.Linq.Expressions.Expression.Constant("A", typeof(string));
            var be = System.Linq.Expressions.Expression.NotEqual(me, c);
            var efab = System.Linq.Expressions.Expression<Func<Area, bool>>
                .Lambda<Func<Area, bool>>(be, pe);


            //Bootstrapper.Init();

            //IoC.Register<MainWindow, MainWindow>();

            //IoC.Get<MainWindow>().Show();
        }
Example #2
0
        public void AddTest()
        {
            string cmdText = null;
            var cmdMock = new Mock<IDbCommand>();
            cmdMock.SetupSet(x => x.CommandText)
                .Callback(s => cmdText = s);

            var uowMock = new Mock<IUnitOfWork>();
            uowMock.Setup(x => x.GetCommand())
                .Returns(cmdMock.Object);                

            var rpstr = new GenericRepository<Area>(uowMock.Object);

            var area = new Area{Name = "Test Name", SOATO = "1703"};

            rpstr.Add(area);

            cmdMock.VerifySet(x => x.CommandText);
            cmdMock.Verify(x => x.ExecuteNonQuery());

            var etalon = "insert into Areas (Name,SOATO) values ('Test Name','1703')";

            Assert.AreEqual(etalon, cmdText);
        }
Example #3
0
        private void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            var ticks1 = DateTime.Now.Ticks;
            var ticks2 = DateTime.Now.Ticks.ToString();

            var area = new Area
            {
                Name = "Test Area " + ticks1,
                SOATO = "17" + ticks2.Substring(ticks2.Length - 6, 6)
            };

            _catMgr.AddArea(area);

            LoadAreas();
        }