Exemplo n.º 1
0
        public void GetAllProductsTest()
        {
            // Arrange - We're mocking our dbSet & dbContext
            var options = new DbContextOptionsBuilder <ProteusContext>()
                          .UseInMemoryDatabase(databaseName: "Proteus")
                          .Options;

            //insert seed data into db
            using (var context = new ProteusContext(options))
            {
                context.Products.Add(new Product()
                {
                    ProductName = "IPhone", CategoryId = 1, UnitPrice = 19.5M, UnitsInStock = 10, QuantityPerUnit = "2", UnitsOnOrder = 1, ReorderLevel = 1, Discontinued = false
                });
                context.Products.Add(new Product()
                {
                    ProductName = "Samsung", CategoryId = 1, UnitPrice = 33.5M, UnitsInStock = 10, QuantityPerUnit = "2", UnitsOnOrder = 1, ReorderLevel = 1, Discontinued = false
                });
                context.Products.Add(new Product()
                {
                    ProductName = "LG TV", CategoryId = 2, UnitPrice = 33.5M, UnitsInStock = 10, QuantityPerUnit = "2", UnitsOnOrder = 1, ReorderLevel = 1, Discontinued = false
                });
                context.SaveChanges();
            }

            // Act - fetch data
            var            dbContext      = new ProteusContext(options);
            List <Product> acutaldResults = dbContext.Products.ToList();

            //Assert
            Assert.AreEqual(expected: 3, actual: acutaldResults.Count);
        }
Exemplo n.º 2
0
        public override void Layout(Point pos, Size space)
        {
            Size  myPreferredSize = PreferredSize;
            int   pad             = (int)(space.Height - myPreferredSize.Height) / Children.Count;
            float yAcc            = 0;

            foreach (var tuple in Children)
            {
                IUINode comp      = tuple.Item1;
                Size    compISize = comp.PreferredSize;
                ProteusContext.Log(comp.GetType().ToString() + " " + compISize.ToString());
                float w = compISize.Width;
                float h = compISize.Height;

                if (ExpandChildenHorizontally)
                {
                    w = myPreferredSize.Width;
                }

                if (ExpandChildrenVertically)
                {
                    h += pad;
                }
                ProteusContext.Log(comp.GetType().ToString() + " " + compISize.ToString());
                comp.Layout(new Point(0, yAcc),
                            new Size(w, h));
                yAcc += comp.Size.Height;
            }
        }
Exemplo n.º 3
0
        public CategoryServiceTests()
        {
            //create in memory db
            var options = new DbContextOptionsBuilder <ProteusContext>()
                          .UseInMemoryDatabase(databaseName: "Proteus")
                          .Options;

            //insert seed data into db
            using (var context = new ProteusContext(options))
            {
                context.Categories.Add(new Category()
                {
                    CategoryName = "Phone"
                });
                context.Categories.Add(new Category()
                {
                    CategoryName = "TV"
                });
                context.SaveChanges();
            }
            var dbContext = new ProteusContext(options);

            _categoryRepoMock = new CategoryRepository(dbContext);

            _sut = new CategoryService(_categoryRepoMock, _loggerMock.Object);
        }
Exemplo n.º 4
0
 private void DoMouseMove(MouseEvent obj)
 {
     if (_buttonDown)
     {
         ProteusContext.Log("move=" + obj.ClientPosX + "," + obj.ClientPosY);
         float deltaX = obj.ClientPosX - _grabOffset.X;
         float deltay = obj.ClientPosY - _grabOffset.Y;
         Transformation = Transformation.Translate(deltaX, deltay);
         Render(Matrix.Identity);
     }
 }
Exemplo n.º 5
0
        public PButton(string text, string bkgImage = null) : base(MakeHTML(text, bkgImage))
        {
            objRefFromJS = DotNetObjectReference.Create(this);
            if (bkgImage != null)
            {
                _styleSettings["background-size"]   = "100%";
                _styleSettings["background-origin"] = "content";
                _styleSettings["background-image"]  = "url(" + bkgImage + ")";
            }

            ProteusContext.JSInvokeVoid("Proteus.attachOnClick",
                                        _domElement, objRefFromJS, "OnClickReceiver");
        }
Exemplo n.º 6
0
        public override void RenderLocal(Matrix localXform)
        {
            ProteusContext.Log("Render matrix=" + localXform.ToString());
            Point origin = localXform.TransformPoint(Point.Zero);

            //ProteusContext.JSInvokeVoid(
            //    "Proteus.setElementLayout",_domElement,origin.X,
            //    origin.Y,Size.Width,Size.Height);
            _styleSettings["position"] = "fixed";
            _styleSettings["left"]     = origin.X + "px";
            _styleSettings["top"]      = origin.Y + "px";
            _styleSettings["width"]    = Size.Width + "px";
            _styleSettings["height"]   = Size.Height + "px";
            ProteusContext.JSInvokeVoid(
                "Proteus.resetStyle", _domElement, _styleSettings);
        }
Exemplo n.º 7
0
        public HTMLComponent(string html)
        {
            _domElement = ProteusContext.JSInvoke <IJSObjectReference>(
                "Proteus.htmlToElement", html);
            _objRefFromJS = DotNetObjectReference.Create(this);
            float[] sza = ProteusContext.JSInvoke <float[]>(
                "Proteus.getElementSize", _domElement);
            Size size = new Size(sza[0], sza[1]);

            ProteusContext.Log(html);
            ProteusContext.Log("html size=" + size.ToString());
            NaturalSize = size;
            MinSize     = NaturalSize;
            ProteusContext.JSInvokeVoid("Proteus.setMouseCallbacks", _domElement,
                                        _objRefFromJS, "DoJSMouseDown", "DoJSMouseUp", "DoJSMouseMove");
        }
Exemplo n.º 8
0
        [SetUp]//like a constructor
        public void SetUp()
        {
            // Arrange - We're mocking our dbSet & dbContext
            var options = new DbContextOptionsBuilder <ProteusContext>()
                          .UseInMemoryDatabase(databaseName: "Proteus")
                          .Options;

            //insert seed data into db
            using (var context = new ProteusContext(options))
            {
                context.Categories.Add(new Category()
                {
                    CategoryName = "Phone"
                });
                context.Categories.Add(new Category()
                {
                    CategoryName = "TV"
                });
                context.SaveChanges();
            }

            _dbContext = new ProteusContext(options);
        }
Exemplo n.º 9
0
 public void DoJSMouseMove(MouseEvent evt)
 {
     ProteusContext.Log("evt=" + evt.ClientPosX + "," + evt.ClientPosY);
     OnMouseMove?.Invoke(evt);
 }
Exemplo n.º 10
0
 public void DoJSMouseUp(MouseEvent evt)
 {
     ProteusContext.Log("mouse up");
     OnMouseUp?.Invoke(evt);
 }
Exemplo n.º 11
0
 public void DoJSMouseDown(MouseEvent evt)
 {
     ProteusContext.Log("mouse down");
     OnMouseDown?.Invoke(evt);
 }
Exemplo n.º 12
0
 public HTMLContainerWrapper(AbstractUIContainer <TInfo> layout)
 {
     _wrapped = layout;
     _div     = ProteusContext.JSInvoke <IJSObjectReference>(
         "Proteus.htmlToElement", "<div></div>");
 }
Exemplo n.º 13
0
 private void DoMouseDown(MouseEvent obj)
 {
     _buttonDown = true;
     ProteusContext.Log(obj.ClientPosX + "," + obj.ClientPosY);
     _grabOffset = new Point(obj.ClientPosX, obj.ClientPosY);
 }
 public CategoryRepository(ProteusContext dbContext) : base(dbContext)
 {
 }
Exemplo n.º 15
0
 public ProductRepository(ProteusContext dbContext) : base(dbContext)
 {
 }
Exemplo n.º 16
0
 public Repository(ProteusContext dbContext)
 {
     _dbContext = dbContext ?? throw new ArgumentNullException(nameof(dbContext));
 }