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(); }
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); }
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); }
public VisualHardwareGrid(Assemblage.IN8 CPU) { graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; this.IsMouseVisible = true; this.CPU = CPU; graphics.PreferredBackBufferHeight = 600; graphics.PreferredBackBufferWidth = 800; }
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); }
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); }
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); }
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); }
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)); }
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; }
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); }