Пример #1
0
        private async Task SeedArticle()
        {
            var col = await InitCollection <Article>("article");

            var articles = new List <Article>()
            {
                new Article()
                {
                    Code = "XC10<3", Type = "TO", Densite = 8.0f, Prix = 0.75f
                },
                new Article()
                {
                    Code = "XC10>=3", Type = "TO", Densite = 8.0f, Prix = 0.68f
                },
                new Article()
                {
                    Code = "215", Type = "MO", Designation = "Laser Bystronic", TxPrep = 70, TxOpe = 110, TpPrep = 0.0f, TpBase = 0.0f
                },
                new Article()
                {
                    Code = "300", Type = "MO", Designation = "Pliage", TxPrep = 60, TxOpe = 80, TpPrep = 0.0f, TpBase = 0.0f
                },
                new Article()
                {
                    Code = "ARTICLE TEST", Designation = "Designation test", Type = "CH"
                }
            };
            await col.InsertManyAsync(articles);

            var art = await ArticleRepo.GetAsync(art => art.Code == "ARTICLE TEST");

            var nome = await ArticleRepo.GetAsync(art => art.Code == "XC10>=3");

            var ope = await ArticleRepo.GetAsync(art => art.Code == "215");

            var ope1 = await ArticleRepo.GetAsync(art => art.Code == "300");

            art.Nomenclatures = new List <Nomenclature>()
            {
                new Nomenclature()
                {
                    Code = nome.Id, Operation = 10, Quantite = 0.5f
                }
            };
            art.Operations = new List <Operation>()
            {
                new Operation()
                {
                    Code = ope.Id, Ordre = 10, Nombre = 2, TxPrep = ope.TxPrep, TxOpe = ope.TxOpe, TpPrep = ope.TpPrep, TpOpe = ope.TpOpe, BaseOpe = 0.5f
                },
                new Operation()
                {
                    Code = ope1.Id, Ordre = 20, Nombre = 5, TxPrep = ope1.TxPrep, TxOpe = ope1.TxOpe, TpPrep = ope1.TpPrep, TpOpe = ope1.TpOpe, BaseOpe = 0.003f
                }
            };
            await ArticleRepo.UpdateAsync(art);
        }
Пример #2
0
        private void StubInventoryRepositories()
        {
            #region EntityRepository LoadAsync GetAsync
            A.CallTo(() => EntityRepository.LoadAsync <Article>(Product1InteriorDoor.Id)).Returns(Product1InteriorDoor);
            A.CallTo(() => EntityRepository.GetAsync <Article>(Product1InteriorDoor.Id)).Returns(Product1InteriorDoor);

            A.CallTo(() => EntityRepository.LoadAsync <Article>(Product2InteriorDoor.Id)).Returns(Product2InteriorDoor);
            A.CallTo(() => EntityRepository.GetAsync <Article>(Product2InteriorDoor.Id)).Returns(Product2InteriorDoor);

            A.CallTo(() => EntityRepository.LoadAsync <Article>(Material1Timber.Id)).Returns(Material1Timber);
            A.CallTo(() => EntityRepository.GetAsync <Article>(Material1Timber.Id)).Returns(Material1Timber);

            A.CallTo(() => EntityRepository.LoadAsync <Article>(Material2Foil.Id)).Returns(Material2Foil);
            A.CallTo(() => EntityRepository.GetAsync <Article>(Material2Foil.Id)).Returns(Material2Foil);

            A.CallTo(() => EntityRepository.LoadAsync <Article>(Material4TintedGlass.Id)).Returns(Material4TintedGlass);
            A.CallTo(() => EntityRepository.GetAsync <Article>(Material4TintedGlass.Id)).Returns(Material4TintedGlass);

            A.CallTo(() => EntityRepository.LoadAsync <Article>(Material3Mdf.Id)).Returns(Material3Mdf);
            A.CallTo(() => EntityRepository.GetAsync <Article>(Material3Mdf.Id)).Returns(Material3Mdf);

            A.CallTo(() => EntityRepository.LoadAsync <Article>(Component1Vertical.Id)).Returns(Component1Vertical);
            A.CallTo(() => EntityRepository.GetAsync <Article>(Component1Vertical.Id)).Returns(Component1Vertical);

            A.CallTo(() => EntityRepository.LoadAsync <Article>(Component2Horizontal.Id)).Returns(Component2Horizontal);
            A.CallTo(() => EntityRepository.GetAsync <Article>(Component2Horizontal.Id)).Returns(Component2Horizontal);

            A.CallTo(() => EntityRepository.LoadAsync <Article>(Component3MdfFiller.Id)).Returns(Component3MdfFiller);
            A.CallTo(() => EntityRepository.GetAsync <Article>(Component3MdfFiller.Id)).Returns(Component3MdfFiller);

            A.CallTo(() => EntityRepository.LoadAsync <Article>(Component4GlassFiller.Id)).Returns(Component4GlassFiller);
            A.CallTo(() => EntityRepository.GetAsync <Article>(Component4GlassFiller.Id)).Returns(Component4GlassFiller);

            A.CallTo(() => EntityRepository.LoadAsync <Article>(ArticleToArchive.Id)).Returns(ArticleToArchive);
            A.CallTo(() => EntityRepository.GetAsync <Article>(ArticleToArchive.Id)).Returns(ArticleToArchive);

            #endregion

            #region ArticleRepository LoadAsync GetAsync

            A.CallTo(() => ArticleRepo.LoadAsync(Product1InteriorDoor.Id)).Returns(Product1InteriorDoor);
            A.CallTo(() => ArticleRepo.GetAsync(Product1InteriorDoor.Id)).Returns(Product1InteriorDoor);

            A.CallTo(() => ArticleRepo.LoadAsync(Product2InteriorDoor.Id)).Returns(Product2InteriorDoor);
            A.CallTo(() => ArticleRepo.GetAsync(Product2InteriorDoor.Id)).Returns(Product2InteriorDoor);

            A.CallTo(() => ArticleRepo.LoadAsync(Material1Timber.Id)).Returns(Material1Timber);
            A.CallTo(() => ArticleRepo.GetAsync(Material1Timber.Id)).Returns(Material1Timber);

            A.CallTo(() => ArticleRepo.LoadAsync(Material2Foil.Id)).Returns(Material2Foil);
            A.CallTo(() => ArticleRepo.GetAsync(Material2Foil.Id)).Returns(Material2Foil);

            A.CallTo(() => ArticleRepo.LoadAsync(Material4TintedGlass.Id)).Returns(Material4TintedGlass);
            A.CallTo(() => ArticleRepo.GetAsync(Material4TintedGlass.Id)).Returns(Material4TintedGlass);

            A.CallTo(() => ArticleRepo.LoadAsync(Material3Mdf.Id)).Returns(Material3Mdf);
            A.CallTo(() => ArticleRepo.GetAsync(Material3Mdf.Id)).Returns(Material3Mdf);

            A.CallTo(() => ArticleRepo.LoadAsync(Component1Vertical.Id)).Returns(Component1Vertical);
            A.CallTo(() => ArticleRepo.GetAsync(Component1Vertical.Id)).Returns(Component1Vertical);

            A.CallTo(() => ArticleRepo.LoadAsync(Component2Horizontal.Id)).Returns(Component2Horizontal);
            A.CallTo(() => ArticleRepo.GetAsync(Component2Horizontal.Id)).Returns(Component2Horizontal);

            A.CallTo(() => ArticleRepo.LoadAsync(Component3MdfFiller.Id)).Returns(Component3MdfFiller);
            A.CallTo(() => ArticleRepo.GetAsync(Component3MdfFiller.Id)).Returns(Component3MdfFiller);

            A.CallTo(() => ArticleRepo.LoadAsync(Component4GlassFiller.Id)).Returns(Component4GlassFiller);
            A.CallTo(() => ArticleRepo.GetAsync(Component4GlassFiller.Id)).Returns(Component4GlassFiller);

            A.CallTo(() => ArticleRepo.LoadAsync(ArticleToArchive.Id)).Returns(ArticleToArchive);
            A.CallTo(() => ArticleRepo.GetAsync(ArticleToArchive.Id)).Returns(ArticleToArchive);

            #endregion

            var ids0 = Product1InteriorDoor.BillsOfMaterial.First().Input.Select(i => i.Article.Id);
            A.CallTo(() => EntityRepository.LoadSomeAsync(A <IEnumerable <Guid> > .That.IsSameSequenceAs(ids0), A <Expression <Func <Article, bool> > > .Ignored, A <int?> .Ignored, A <int?> .Ignored, A <string> .Ignored, A <string> .Ignored))
            .Returns(Product1InteriorDoor.BillsOfMaterial.First().Input.Select(i => i.Article).ToList());

            var ids1 = new[] { Component1Vertical.Id, Component2Horizontal.Id, Component3MdfFiller.Id, Material2Foil.Id };
            A.CallTo(() => EntityRepository.LoadSomeAsync(A <IEnumerable <Guid> > .That.IsSameSequenceAs(ids1), A <Expression <Func <Article, bool> > > .Ignored, A <int?> .Ignored, A <int?> .Ignored, A <string> .Ignored, A <string> .Ignored))
            .Returns(new List <Article> {
                Component1Vertical, Component2Horizontal, Component3MdfFiller, Material2Foil
            });

            A.CallTo(() => ArticleRepo.FindSpoiledCounterpartAsync(Product1InteriorDoor, true))
            .Returns(Product1InteriorDoorSpoiled);
            A.CallTo(() => ArticleRepo.FindSpoiledCounterpartAsync(Component1Vertical, true))
            .Returns(Component1VerticalSpoiled);

            A.CallTo(() => EntityRepository.GetSomeAsync(A <IEnumerable <Guid> > .That.Contains(Product1InteriorDoor.Id), A <Expression <Func <Article, bool> > > .Ignored, A <int?> .Ignored, A <int?> .Ignored, A <string> .Ignored, A <string> .Ignored))
            .Returns(new[] { Product1InteriorDoor });

            A.CallTo(() => EntityRepository.GetSomeAsync(A <IEnumerable <Guid> > .That.Contains(Material2Foil.Id), A <Expression <Func <Article, bool> > > .Ignored, A <int?> .Ignored, A <int?> .Ignored, A <string> .Ignored, A <string> .Ignored))
            .Returns(new[] { Material2Foil });

            A.CallTo(() => EntityRepository.LoadAsync <Uom>(PieceUom.Id)).Returns(PieceUom);
            A.CallTo(() => EntityRepository.GetAsync <Uom>(PieceUom.Id)).Returns(PieceUom);

            A.CallTo(() => EntityRepository.LoadAsync <Uom>(CubicMeterUom.Id)).Returns(CubicMeterUom);
            A.CallTo(() => EntityRepository.GetAsync <Uom>(CubicMeterUom.Id)).Returns(CubicMeterUom);

            A.CallTo(() => EntityRepository.LoadAsync <BillOfMaterial>(Component2Horizontal.PrimaryBillOfMaterial.Id))
            .Returns(Component2Horizontal.PrimaryBillOfMaterial);
            A.CallTo(() => EntityRepository.GetAsync <BillOfMaterial>(Component2Horizontal.PrimaryBillOfMaterial.Id))
            .Returns(Component2Horizontal.PrimaryBillOfMaterial);

            A.CallTo(() => EntityRepository.LoadAsync <BillOfMaterial>(Product1InteriorDoor.PrimaryBillOfMaterial.Id))
            .Returns(Product1InteriorDoor.PrimaryBillOfMaterial);
            A.CallTo(() => EntityRepository.GetAsync <BillOfMaterial>(Product1InteriorDoor.PrimaryBillOfMaterial.Id))
            .Returns(Product1InteriorDoor.PrimaryBillOfMaterial);

            A.CallTo(() => EntityRepository.LoadAsync <BillOfMaterial>(Product2InteriorDoor.PrimaryBillOfMaterial.Id))
            .Returns(Product2InteriorDoor.PrimaryBillOfMaterial);
            A.CallTo(() => EntityRepository.GetAsync <BillOfMaterial>(Product2InteriorDoor.PrimaryBillOfMaterial.Id))
            .Returns(Product2InteriorDoor.PrimaryBillOfMaterial);

            var inStockP1 = Shops.SelectMany(s => s.Inventory).Where(i => i.Article == Product1InteriorDoor)
                            .Sum(i => i.Amount);
            A.CallTo(() => InventoryRepo.FindTotalAmountInStockAsync(Product1InteriorDoor)).Returns(inStockP1);

            var inOrdersP1 = Orders.SelectMany(s => s.ItemsOrdered).Where(i => i.Article == Product1InteriorDoor)
                             .Sum(i => i.Amount);
            A.CallTo(() => InventoryRepo.FindSpareInventoryAsync(Product1InteriorDoor)).Returns(inStockP1 - inOrdersP1);

            var inStockC1 = Shops.SelectMany(s => s.Inventory).Where(i => i.Article == Component1Vertical)
                            .Sum(i => i.Amount);
            A.CallTo(() => InventoryRepo.FindTotalAmountInStockAsync(Component1Vertical)).Returns(inStockC1);
            A.CallTo(() => InventoryRepo.FindSpareInventoryAsync(Component1Vertical)).Returns(inStockC1);

            var inStockC2 = Shops.SelectMany(s => s.Inventory).Where(i => i.Article == Component2Horizontal)
                            .Sum(i => i.Amount);
            A.CallTo(() => InventoryRepo.FindTotalAmountInStockAsync(Component2Horizontal)).Returns(inStockC2);
            A.CallTo(() => InventoryRepo.FindSpareInventoryAsync(Component2Horizontal)).Returns(inStockC2);

            var inStockC3 = Shops.SelectMany(s => s.Inventory).Where(i => i.Article == Component3MdfFiller)
                            .Sum(i => i.Amount);
            A.CallTo(() => InventoryRepo.FindTotalAmountInStockAsync(Component3MdfFiller)).Returns(inStockC3);
            A.CallTo(() => InventoryRepo.FindSpareInventoryAsync(Component3MdfFiller)).Returns(inStockC3);

            A.CallTo(() => InventoryRepo.FindTotalAmountInOrdersAsync(Product2InteriorDoor)).Returns(1);

            A.CallTo(() => InventoryRepo.FindTotalAmountInOrdersAsync(Material1Timber))
            .Returns(AmountInOrders(Material1Timber));
            A.CallTo(() => InventoryRepo.FindTotalAmountInOrdersAsync(Material2Foil))
            .Returns(AmountInOrders(Material2Foil));
            A.CallTo(() => InventoryRepo.FindTotalAmountInOrdersAsync(Material3Mdf)).Returns(AmountInOrders(Material3Mdf));
            A.CallTo(() => InventoryRepo.FindTotalAmountInOrdersAsync(Material4TintedGlass))
            .Returns(AmountInOrders(Material4TintedGlass));
        }