public void DbRef_List_Using_Abstract_Class()
        {
            using (var db = new LiteDatabase(new MemoryStream()))
            {
                var projectsCollection = db.GetCollection <ProjectList>("projects");
                var itemsCollection    = db.GetCollection <ItemBase>("items");

                var itemA = new ItemA {
                    Name = "Item A1", DetailsA = "Details A1"
                };
                itemsCollection.Insert(itemA);
                var itemB = new ItemB {
                    Name = "Item B1", DetailsB = "Details B1"
                };
                itemsCollection.Insert(itemB);

                var project = new ProjectList
                {
                    Name  = "Project 1",
                    Items = new List <ItemBase> {
                        itemA, itemB
                    }
                };
                projectsCollection.Insert(project);

                var queryResult = projectsCollection.FindAll().First();

                // no Include - must use $type to load reference class

                queryResult.Items[0].GetType().Should().Be(typeof(ItemA));
                queryResult.Items[1].GetType().Should().Be(typeof(ItemB));
            }
        }
Example #2
0
        public override void Render(UiContext context, RectangleF parentRectangle)
        {
            if (!Visible)
            {
                return;
            }
            var myRectangle = GetMyRectangle(context, parentRectangle);

            Background?.Draw(context, myRectangle);
            ItemA?.Render(context, myRectangle);
            ItemB?.Render(context, myRectangle);
            UiRenderable border = Border;

            if (Enabled)
            {
                if (Selected)
                {
                    border = SelectedBorder ?? border;
                }
                if (rectangleA.Contains(context.MouseX, context.MouseY) ||
                    rectangleB.Contains(context.MouseX, context.MouseY))
                {
                    border = HoverBorder ?? border;
                }
            }
            if (ItemA != null)
            {
                border?.Draw(context, rectangleA);
            }
            if (ItemB != null)
            {
                border?.Draw(context, rectangleB);
            }
        }
 public ItemAB(ItemA a, ItemB b)
 {
     FieldA1 = a.FieldA1;
     FieldA2 = a.FieldA2;
     FieldB1 = b.FieldB1;
     FieldB2 = b.FieldB2;
 }
Example #4
0
    public void AddItem(ItemA item)
    {
        if (item is ConsumableItemA)
        {
            foreach (ConsumableItemA c in IEnumCI)                      //for all the classes of ConsumableItems
            {
                if (c.GetType() == item.GetType())                      //is the item a manapotion, health potion, etc(dynamic)
                {
                    if (DetectItem(consumableItems, c))                 //checks if the list contains that objects at least once
                    {
                        consumableItems.Where(x => x.GetType() == c.GetType()).First().amount++;
                    }
                    //adds one to the count if yes

                    else
                    {
                        consumableItems.Add((ConsumableItemA)item);      //creates new entry if not
                    }
                    break;
                }
            }
            OnItemListChanged?.Invoke(this, EventArgs.Empty);           //updates ui
            return;
        }
    }
Example #5
0
 public ItemViewModel Create(ItemA item)
 {
     return(new ItemViewModel()
     {
         Name = item.Name
     });
 }
    public void Test2(ref ItemA obj)
    {
        Console.WriteLine("A2");
        var objT = default(T);

        Test(ref objT);
    }
            public void ItemA_IsAnItem()
            {
                //Arrange
                var itemA = new ItemA();

                //Act


                //Assert
                itemA.Should().BeAssignableTo <Item>();
            }
Example #8
0
        public void Given_IHaveSelectedToAddAnItemToTheBasket_Then_TheItemShouldBeAddedToTheBasket()
        {
            //Arrange
            var item   = new ItemA();
            var basket = new Basket();

            //Act
            basket.AddItem(item);

            //Assert
            Assert.AreEqual(1, basket.GetItems().Count);
        }
            public void TheoryItemAsPrice(int quantity, decimal expectedTotalPrice)
            {
                //Arrange
                var itemA = new ItemA();

                //Act


                //Assert
                var total = itemA.GetPriceForQuantity(quantity);

                total.Should().Be(expectedTotalPrice);
            }
Example #10
0
 public override void OnMouseDown(UiContext context, RectangleF parentRectangle)
 {
     if (!Visible)
     {
         return;
     }
     if (Enabled)
     {
         var myRectangle = GetMyRectangle(context, parentRectangle);
         ItemA?.OnMouseUp(context, myRectangle);
         ItemB?.OnMouseDown(context, myRectangle);
     }
 }
Example #11
0
        public void Revalidate_OtherItemBecomesInvalid_RevalidatesOtherItem()
        {
            Results.EnabledValidators = ValidatorTypes.Property;

            Results.SetupFailing().PropertyValidation
            .Targeting(ItemABC, x => x.ItemProperty)
            .On(ItemABC);

            Results.SetupFailing().CollectionPropertyValidation
            .Targeting(ItemABC, x => x.ItemProperty)
            .On(OwnerOfAB, CollectionAValidatorKey);

            ItemA.Revalidate(x => x.ItemProperty);;
            Results.VerifySetupValidationResults();
        }
Example #12
0
        public void MultipleItemsAreInvalidInSingleCollection_OneInvalidItemIsRevalidated_RevalidatesInvalidItemsAndAddsErrors()
        {
            Results.EnabledValidators = ValidatorTypes.Property;

            Results.SetupFailing().CollectionPropertyValidation
            .Targeting(ItemA, x => x.ItemProperty)
            .On(OwnerOfAB, CollectionAValidatorKey);

            Results.SetupFailing().CollectionPropertyValidation
            .Targeting(ItemAB, x => x.ItemProperty)
            .On(OwnerOfAB, CollectionAValidatorKey);

            ItemA.Revalidate(x => x.ItemProperty);;

            Results.VerifySetupValidationResults();
        }
Example #13
0
 public override void OnMouseClick(UiContext context, RectangleF parentRectangle)
 {
     DoSelect = false;
     if (!Visible)
     {
         return;
     }
     if (Enabled)
     {
         var myRectangle = GetMyRectangle(context, parentRectangle);
         ItemA?.OnMouseClick(context, myRectangle);
         ItemB?.OnMouseClick(context, myRectangle);
         if (rectangleA.Contains(context.MouseX, context.MouseY) ||
             rectangleB.Contains(context.MouseX, context.MouseY))
         {
             DoSelect = true;
         }
     }
 }
Example #14
0
        public void Revalidate_OtherItemBecomesInvalid_ValidatesUnvalidatedOwnerCollectionsOfOtherItems()
        {
            Results.EnabledValidators = ValidatorTypes.Property;

            Results.SetupFailing().CollectionPropertyValidation
            .Targeting(ItemABC, x => x.ItemProperty)
            .On(OwnerOfAB, CollectionAValidatorKey);

            ItemA.Revalidate(x => x.ItemProperty);;

            ExpectItemPropertyValidationOf(ItemA);
            ExpectCollectionPropertyValidationOf(OwnerOfAB.CollectionA);

            ExpectItemPropertyValidationOf(ItemABC);
            ExpectCollectionPropertyValidationOf(OwnerOfAB.CollectionB);
            ExpectCollectionPropertyValidationOf(OwnerOfC.CollectionC);

            Results.VerifyInvocationSequence();
        }
Example #15
0
        public void Revalidate_OtherItemWasPreviouslyInvalid_ValidatesUnvalidatedCollectionsOfOtherItem()
        {
            Results.EnabledValidators = ValidatorTypes.Property;

            Results.SetFailed("Previous error").CollectionPropertyValidation
            .Targeting(ItemABC, x => x.ItemProperty)
            .On(OwnerOfAB, CollectionAValidatorKey);

            ItemA.Revalidate(x => x.ItemProperty);

            ExpectItemPropertyValidationOf(ItemA);
            ExpectCollectionPropertyValidationOf(OwnerOfAB.CollectionA);

            ExpectItemPropertyValidationOf(ItemABC);
            ExpectCollectionPropertyValidationOf(OwnerOfAB.CollectionB);
            ExpectCollectionPropertyValidationOf(OwnerOfC.CollectionC);

            Results.VerifyInvocationSequence();
        }
Example #16
0
        public void MultipleItemsAreInvalidInSingleCollection_OneInvalidItemIsRevalidated_ValidatesOwnerCollectionsAndRevalidatesInvalidItems()
        {
            Results.EnabledValidators = ValidatorTypes.Property;

            Results.SetupFailing().CollectionPropertyValidation
            .Targeting(ItemA, x => x.ItemProperty)
            .On(OwnerOfAB, CollectionAValidatorKey);

            Results.SetupFailing().CollectionPropertyValidation
            .Targeting(ItemAB, x => x.ItemProperty)
            .On(OwnerOfAB, CollectionAValidatorKey);

            ItemA.Revalidate(x => x.ItemProperty);;

            ExpectItemPropertyValidationOf(ItemA);
            ExpectCollectionPropertyValidationOf(OwnerOfAB.CollectionA);
            ExpectItemPropertyValidationOf(ItemAB);
            ExpectCollectionPropertyValidationOf(OwnerOfAB.CollectionB);

            Results.VerifyInvocationSequence();
        }
 private void CreateDatabase(string fileName)
 {
     IObjectContainer db = Db4oEmbedded.OpenFile(Config(), fileName);
     var removed = new Collection4();
     for (var idx = 0; idx < NumItemsPerClass; idx++)
     {
         var itemA = new ItemA(idx);
         var itemB = new ItemB(FillStr
             ('x', idx));
         db.Store(itemA);
         db.Store(itemB);
         if ((idx%DeleteRatio) == 0)
         {
             removed.Add(itemA);
             removed.Add(itemB);
         }
     }
     db.Commit();
     DeleteAndReadd(db, removed);
     db.Close();
 }
        public void DbRef_Item_Using_Abstract_Class()
        {
            using (var db = new LiteDatabase(new MemoryStream()))
            {
                var projectsCollection = db.GetCollection <ProjectItem>("projects");
                var itemsCollection    = db.GetCollection <ItemBase>("items");

                var itemA = new ItemA {
                    Name = "Item A1", DetailsA = "Details A1"
                };
                itemsCollection.Insert(itemA);
                var itemB = new ItemB {
                    Name = "Item B1", DetailsB = "Details B1"
                };
                itemsCollection.Insert(itemB);

                var projectA = new ProjectItem
                {
                    Name = "Project A",
                    Item = itemA
                };

                var projectB = new ProjectItem
                {
                    Name = "Project B",
                    Item = itemB
                };

                projectsCollection.Insert(projectA);
                projectsCollection.Insert(projectB);

                var queryResult = projectsCollection.FindAll().ToArray();

                // no Include - must use $type to load reference class

                queryResult[0].Item.GetType().Should().Be(typeof(ItemA));
                queryResult[1].Item.GetType().Should().Be(typeof(ItemB));
            }
        }
Example #19
0
        private void CreateDatabase(string fileName, int blockSize)
        {
            IObjectContainer db = Db4oEmbedded.OpenFile(Config(blockSize), fileName);
            var removed         = new Collection4();

            for (var idx = 0; idx < NumItemsPerClass; idx++)
            {
                var itemA = new ItemA(idx);
                var itemB = new ItemB(FillStr('x'
                                              , idx));
                db.Store(itemA);
                db.Store(itemB);
                if ((idx % DeleteRatio) == 0)
                {
                    removed.Add(itemA);
                    removed.Add(itemB);
                }
            }
            db.Commit();
            DeleteAndReadd(db, removed);
            db.Close();
        }
Example #20
0
 public void Visit(ItemA item)
 {
     Debug.Log("Item:A -> visitor:B");
 }
Example #21
0
 public override void ApplyStylesheet(Stylesheet sheet)
 {
     base.ApplyStylesheet(sheet);
     ItemA?.ApplyStylesheet(sheet);
     ItemB?.ApplyStylesheet(sheet);
 }
Example #22
0
 private void AddItemA(ItemA result, Dictionary <string, THashSet <string> > report)
 {
     AddField("fieldA", result.FieldA.ToString(), report);
     AddField("fieldB", result.FieldB?.Select(x => x.ToString()), report);
     AddField("fieldC", result.FieldC.ToString(), report);
 }
 public double Calculate(ItemA itemA)
 {
     return(itemA.NoOfItems / 3 * 130 + itemA.NoOfItems % 3 * itemA.Cost);
 }