示例#1
0
        public static void Initialize(MyRestaurantContext context)
        {
            PaymentTypeInitializer.Initialize(context);
            UnitOfMeasureInitializer.Initialize(context);
            StockTypeInitializer.Initialize(context);
            StockItemInitializer.Initialize(context);
            SupplierInitializer.Initialize(context);
            UserInitializer.Initialize(context);
            PurchaseOrderInitializer.Initialize(context);
            PurchaseOrderItemInitializer.Initialize(context);

            if (!context.GoodsReceivedNotes.Any())
            {
                var goodsReceivedNotes = new List <GoodsReceivedNote>
                {
                    new GoodsReceivedNote {
                        PurchaseOrderId = 1,
                        InvoiceNumber   = "INV_20210132_01",
                        PaymentTypeId   = 1,
                        Nbt             = 0.5m,
                        Vat             = 0.5m,
                        Discount        = 0.5m,
                        ReceivedBy      = context.Users.First(d => d.FirstName == "Admin").Id,
                        ReceivedDate    = DateTime.Now.AddDays(-5),
                        ApprovedBy      = Guid.Empty,
                        ApprovalStatus  = Status.Pending,
                        ApprovedDate    = default,
示例#2
0
        public async Task Verify_DeleteRange_Deleted_Successfully()
        {
            //Arrange
            UnitOfMeasureInitializer.Initialize(_myRestaurantContext);

            //Act
            var uoms = await _myRestaurantContext.GetAllAsync <UnitOfMeasure>();

            //Assert
            uoms.Should().HaveCount(5);

            //Act
            _myRestaurantContext.DeleteRange(uoms);
            await _myRestaurantContext.CommitAsync();

            uoms = await _myRestaurantContext.GetAllAsync <UnitOfMeasure>();

            //Assert
            uoms.Should().HaveCount(0);
        }
        public static void Initialize(MyRestaurantContext context)
        {
            UnitOfMeasureInitializer.Initialize(context);

            StockTypeInitializer.Initialize(context);

            if (!context.StockItems.Any())
            {
                var stockItems = new List <StockItem>
                {
                    new StockItem {
                        TypeId = 1, Name = "Rice", ItemUnit = 10, UnitOfMeasureId = 1
                    },
                    new StockItem {
                        TypeId = 1, Name = "Chilli Powder", ItemUnit = 250, UnitOfMeasureId = 2
                    },
                    new StockItem {
                        TypeId = 2, Name = "Water", ItemUnit = 1, UnitOfMeasureId = 4
                    },
                    new StockItem {
                        TypeId = 3, Name = "Blue Pen", ItemUnit = 10, UnitOfMeasureId = 5
                    },
                    new StockItem {
                        TypeId = 3, Name = "Oats", ItemUnit = 186, UnitOfMeasureId = 1
                    },
                    new StockItem {
                        TypeId = 1, Name = "Cheese", ItemUnit = 88, UnitOfMeasureId = 2
                    },
                    new StockItem {
                        TypeId = 1, Name = "Pasta", ItemUnit = 52, UnitOfMeasureId = 1
                    },
                    new StockItem {
                        TypeId = 1, Name = "Chips", ItemUnit = 21, UnitOfMeasureId = 1
                    },
                    new StockItem {
                        TypeId = 1, Name = "Nut butter", ItemUnit = 167, UnitOfMeasureId = 1
                    },
                    new StockItem {
                        TypeId = 1, Name = "Popcorn", ItemUnit = 101, UnitOfMeasureId = 1
                    },
                    new StockItem {
                        TypeId = 3, Name = "Mouse", ItemUnit = 5, UnitOfMeasureId = 5
                    },
                    new StockItem {
                        TypeId = 1, Name = "Sausages", ItemUnit = 72, UnitOfMeasureId = 1
                    },
                    new StockItem {
                        TypeId = 1, Name = "Flour ", ItemUnit = 99, UnitOfMeasureId = 1
                    },
                    new StockItem {
                        TypeId = 1, Name = "Chips Large", ItemUnit = 116, UnitOfMeasureId = 1
                    },
                    new StockItem {
                        TypeId = 3, Name = "Table Large", ItemUnit = 1, UnitOfMeasureId = 5
                    },
                    new StockItem {
                        TypeId = 2, Name = "Vinegar", ItemUnit = 125, UnitOfMeasureId = 4
                    },
                    new StockItem {
                        TypeId = 2, Name = "Ketchup", ItemUnit = 199, UnitOfMeasureId = 3
                    },
                    new StockItem {
                        TypeId = 1, Name = "Mustard", ItemUnit = 73, UnitOfMeasureId = 2
                    },
                    new StockItem {
                        TypeId = 1, Name = "Butter", ItemUnit = 60, UnitOfMeasureId = 2
                    },
                    new StockItem {
                        TypeId = 1, Name = "Dried fruit", ItemUnit = 120, UnitOfMeasureId = 2
                    },
                    new StockItem {
                        TypeId = 3, Name = "Table", ItemUnit = 2, UnitOfMeasureId = 5
                    },
                    new StockItem {
                        TypeId = 2, Name = "Cooking Oil", ItemUnit = 148, UnitOfMeasureId = 4
                    },
                    new StockItem {
                        TypeId = 1, Name = "Garlic", ItemUnit = 143, UnitOfMeasureId = 2
                    },
                    new StockItem {
                        TypeId = 3, Name = "Towels", ItemUnit = 20, UnitOfMeasureId = 5
                    },
                    new StockItem {
                        TypeId = 3, Name = "Gloves", ItemUnit = 30, UnitOfMeasureId = 5
                    },
                    new StockItem {
                        TypeId = 3, Name = "Keyboard", ItemUnit = 5, UnitOfMeasureId = 5
                    },
                    new StockItem {
                        TypeId = 2, Name = "Honey", ItemUnit = 87, UnitOfMeasureId = 3
                    },
                    new StockItem {
                        TypeId = 1, Name = "Sugar", ItemUnit = 142, UnitOfMeasureId = 1
                    },
                    new StockItem {
                        TypeId = 1, Name = "Tuna", ItemUnit = 177, UnitOfMeasureId = 2
                    }
                };
                context.StockItems.AddRange(stockItems);
                context.SaveChanges();
            }
        }
示例#4
0
 public UnitOfMeasureServiceTest()
 {
     UnitOfMeasureInitializer.Initialize(_myRestaurantContext);
 }