コード例 #1
0
        public void Write(Assemblage assemblage)
        {
            var select = assemblage.ListOfNomenc.GroupBy(i => i.Nomenclature).Select(g => new LineItem()
            {
                Nomenclature = g.Key,
                Quantity     = g.Sum(i => i.Quantity),
                Sum          = g.Sum(i => i.Sum)
            });

            foreach (var item in select)
            {
                var recordNomenclature = new RemainNomenclature
                {
                    Nomenclature = item.Nomenclature,
                    RecordType   = RecordType.Expose,
                    Quantity     = item.Quantity,
                };
                var recordCostPrice = new RemainCostPrice
                {
                    Nomenclature = item.Nomenclature,
                    RecordType   = RecordType.Expose,
                    Amount       = item.Quantity,
                };

                recordNomenclature.Warehouse = assemblage.Warehouse;
                _remainNomenclature.Create(recordNomenclature);
                _remainCostPrice.Create(recordCostPrice);
            }
            _repository.Create(assemblage);
            _remainNomenclature.RecalcBalances();
            _remainCostPrice.RecalcBalances();
        }
コード例 #2
0
ファイル: ICM.cs プロジェクト: Blecki/InnerWorkings
        public void Connect(Assemblage.IN8 CPU, params byte[] ports)
        {
            if (ports.Length != 2) throw new InvalidOperationException("ICM-CD2 display must be connected to 2 ports");
            this.CPU = CPU;
            dataPort = ports[0];
            controlPort = ports[1];

            CPU.AttachHardware(this, ports);
        }
コード例 #3
0
        public void TestAssemblageDbFindById_WithAssemblageId_ShouldFindTheAssemblageInDbById()
        {
            var repository = new Repository <Assemblage>(_db);
            var assemblage = new Assemblage();

            repository.Create(assemblage);
            var assemblageFindById = repository.GetById(assemblage.Id);

            Assert.Equal(assemblage.Id, assemblageFindById.Id);
        }
コード例 #4
0
        public VisualHardwareGrid(Assemblage.IN8 CPU)
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
            this.IsMouseVisible = true;

            this.CPU = CPU;

            graphics.PreferredBackBufferHeight = 600;
            graphics.PreferredBackBufferWidth = 800;
        }
コード例 #5
0
        public void TestAssemblageDbAdd_WithNewAssemblage_ShouldAddTheAssemblageToDb()
        {
            var repository         = new Repository <Assemblage>(_db);
            var assemblage         = new Assemblage();
            var assemblageFindById = repository.GetById(assemblage.Id);

            Assert.Null(assemblageFindById);
            repository.Create(assemblage);
            assemblageFindById = repository.GetById(assemblage.Id);
            Assert.NotNull(assemblageFindById);
        }
コード例 #6
0
ファイル: SO11705351.cs プロジェクト: cash2one/HBNews
        static Assemblage GetData()
        {
            var whole = new Whole();
            var part  = new Part {
                Whole = whole
            };

            whole.Parts.Add(part);
            var assemblage = new Assemblage();

            assemblage.Parts.Add(part);
            return(assemblage);
        }
コード例 #7
0
        public void TestAssemblageDbDelete_WithAssemblage_ShouldDeleteTheAssemblageFromDb()
        {
            var repository = new Repository <Assemblage>(_db);
            var assemblage = new Assemblage();

            repository.Create(assemblage);
            var assemblageFindById = repository.GetById(assemblage.Id);

            Assert.NotNull(assemblageFindById);
            repository.Delete(assemblage.Id);
            assemblageFindById = repository.GetById(assemblage.Id);
            Assert.Null(assemblageFindById);
        }
コード例 #8
0
        public void TestAssemblageDbUbdate_WithNewAssemblage_ShouldUpdateTheAssemblageToDb()
        {
            var repository = new Repository <Assemblage>(_db);
            var assemblage = new Assemblage();

            repository.Create(assemblage);
            var assemblageFindById = repository.GetById(assemblage.Id);

            Assert.Null(assemblageFindById.Warehouse);
            var warehouse = new Warehouse("warehouse name");

            assemblage.Warehouse = warehouse;
            repository.Update(assemblage);
            Assert.Equal("warehouse name", assemblageFindById.Warehouse.Description);
        }
コード例 #9
0
ファイル: UnitTests.cs プロジェクト: alex327512/demoApp
        public void Test_Assemblage_WithEmptyData_ShouldContainData()
        {
            DateTime date       = DateTime.Now;
            var      assemblage = new Assemblage(date);

            assemblage.Warehouse = SelectWarehouse("Main");
            assemblage.ListOfNomenc.Add(CreateLineItem(SelectNomenclature("AMD"), 100, 100));

            Assert.NotEqual(Guid.Empty, assemblage.Id);
            Assert.Equal(date, assemblage.Date);
            Assert.Equal("Main", assemblage.Warehouse.Description);
            Assert.Collection(assemblage.ListOfNomenc, item => item.Nomenclature.Description.Equals("AMD"));
            Assert.Collection(assemblage.ListOfNomenc, item => item.Price.Equals(100));
            Assert.Collection(assemblage.ListOfNomenc, item => item.Quantity.Equals(100));
            Assert.Collection(assemblage.ListOfNomenc, item => item.Sum.Equals(100 * 100));
        }
コード例 #10
0
        public VisualHardwareHost(System.Type hostedHardwareType, Assemblage.IN8 CPU, params byte[] ports)
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

            this.CPU = CPU;
            this.ports = ports;

            screenDevice = Activator.CreateInstance(hostedHardwareType) as IVisualHardware;
            if (screenDevice == null) throw new InvalidProgramException("Cannot host devices that are not visual hardware.");

            screenDevice.Connect(CPU, ports);
            var size = screenDevice.PreferredWindowSize;

            graphics.PreferredBackBufferHeight = (int)size.X;
            graphics.PreferredBackBufferWidth = (int)size.Y;
        }
コード例 #11
0
ファイル: SevenSegment.cs プロジェクト: Blecki/InnerWorkings
 public void Connect(Assemblage.IN8 CPU, params byte[] ports)
 {
     if (ports.Length != 1) throw new InvalidOperationException("7-segment display takes exactly one port");
     CPU.AttachHardware(this, ports);
 }