Exemple #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);
        }
Exemple #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;
            }
        }
Exemple #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);
        }
Exemple #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);
     }
 }
Exemple #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");
        }
Exemple #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);
        }
Exemple #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");
        }
Exemple #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);
        }
Exemple #9
0
 public void DoJSMouseMove(MouseEvent evt)
 {
     ProteusContext.Log("evt=" + evt.ClientPosX + "," + evt.ClientPosY);
     OnMouseMove?.Invoke(evt);
 }
Exemple #10
0
 public void DoJSMouseUp(MouseEvent evt)
 {
     ProteusContext.Log("mouse up");
     OnMouseUp?.Invoke(evt);
 }
Exemple #11
0
 public void DoJSMouseDown(MouseEvent evt)
 {
     ProteusContext.Log("mouse down");
     OnMouseDown?.Invoke(evt);
 }
Exemple #12
0
 public HTMLContainerWrapper(AbstractUIContainer <TInfo> layout)
 {
     _wrapped = layout;
     _div     = ProteusContext.JSInvoke <IJSObjectReference>(
         "Proteus.htmlToElement", "<div></div>");
 }
Exemple #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)
 {
 }
Exemple #15
0
 public ProductRepository(ProteusContext dbContext) : base(dbContext)
 {
 }
Exemple #16
0
 public Repository(ProteusContext dbContext)
 {
     _dbContext = dbContext ?? throw new ArgumentNullException(nameof(dbContext));
 }