public void CapacityThrowsException_WhenValueIsBelowZero() { Assert.Throws <ArgumentException>(() => aquarium = new Aquarium("Name", -10)); }
public void SetUp() { this.fish = new Fish("Pesho"); this.anotherFish = new Fish("Gosho"); this.aquarium = new Aquarium("Vladi", 100); }
public AFish FindNextVictim() { return(Aquarium.GetFishes() .FirstOrDefault(fish => Randomizer.Success(0.4) && Settings.Piranha.Food.Contains(fish.Type))); }
public void Setup() { this.aquarium = new Aquarium(nameOfAquarium, capacity); }
public void TestCapacityWork() { Aquarium aquarium = new Aquarium("Plovdiv", 10); Assert.AreEqual(aquarium.Capacity, 10); }
public static void AddItem_Postfix(Aquarium __instance, InventoryItem item) { RefreshAquariumSkyAppliers(__instance, false); }
public static void Generate(IModel model, Aquarium aquarium, string fileName) { if (model == null || aquarium == null) { return; } fDocument = new RtfDocument(PaperSize.A4, PaperOrientation.Portrait, Lcid.English); try { var titleFont = CreateFont("", 16.0f, true, false, Color.Black); var textFont = CreateFont("", 12.0f, false, false, Color.Black); var dateFont = CreateFont("", 12.0f, true, true, Color.Black); AddParagraph(Localizer.LS(LSID.LogBook), titleFont, Align.Center, 0.0f, 16.0f); var events = new List <IEventEntity>(); events.AddRange(model.QueryTransfers(aquarium.Id)); events.AddRange(model.QueryNotes(aquarium.Id)); events.AddRange(model.QueryMaintenances(aquarium.Id)); events.AddRange(model.QueryMeasures(aquarium.Id)); events.Sort((x, y) => { return(x.Timestamp.CompareTo(y.Timestamp)); }); string prevDate = string.Empty, curDate; foreach (IEventEntity evnt in events) { curDate = ALCore.GetDateStr(evnt.Timestamp); if (!prevDate.Equals(curDate)) { AddParagraph(curDate, dateFont, Align.Left, 6.0f, 6.0f); prevDate = curDate; } if (evnt is Transfer) { Transfer rec = (Transfer)evnt; string strType = Localizer.LS(ALData.TransferTypes[(int)rec.Type]); string itName = model.GetRecordName(rec.ItemType, rec.ItemId); if (rec.Type == TransferType.Purchase || rec.Type == TransferType.Sale) { AddListItem(string.Format("{0}: {1} ({2} x {3:C2})", strType, itName, rec.Quantity, rec.UnitPrice), textFont); } else { AddListItem(string.Format("{0}: {1} ({2})", strType, itName, rec.Quantity), textFont); } } if (evnt is Note) { Note note = (Note)evnt; AddListItem(string.Format("{0}: {1}", note.Event, note.Content), textFont); } if (evnt is Maintenance) { Maintenance mnt = (Maintenance)evnt; string strType = Localizer.LS(ALData.MaintenanceTypes[(int)mnt.Type].Name); string notes = (string.IsNullOrEmpty(mnt.Note)) ? string.Empty : " (" + mnt.Note + ")"; AddListItem(string.Format("{0}: {1}{2}", strType, ALCore.GetDecimalStr(mnt.Value), notes), textFont); } if (evnt is Measure) { Measure msr = (Measure)evnt; AddListItem(string.Format("{0}: {1}", Localizer.LS(LSID.Measure), msr.ToString()), textFont); } } } finally { fDocument.save(fileName); } }
public void TestingCount() { Aquarium aue = new Aquarium("name", 2); Assert.AreEqual(0, aue.Count); }
public void RemoveFish_ShouldThrowExc() { Aquarium aue = new Aquarium("name", 3); Assert.Throws <InvalidOperationException>(() => aue.RemoveFish("gosho")); }
public void TestCapacityThrowsAnExceptionIfLessThan0(int capacity) { //Aquarium tes1 = new Aquarium(name, 10); Assert.Throws <ArgumentException>(() => aquarium = new Aquarium("name", capacity)); }
public void Setup() { aquarium = new Aquarium("Akva", 10); fish = new Fish("Nemo"); }
public void TestNameThrowsAnExceptionIfNullOrEmpty(string name) { //Aquarium tes1 = new Aquarium(name, 10); Assert.Throws <ArgumentNullException>(() => aquarium = new Aquarium(name, 10)); }
public void Setup() { this.aquarium = new Aquarium("name1", 2); this.fish1 = new Fish("fishi"); this.fish2 = new Fish("fishi2"); }
static void Main() { Aquarium aq = new Aquarium(); }
private AFish GetNearestHunter() { var hunters = Aquarium.GetFishes().Where(x => x is IHunter); return(!hunters.Any() ? null : hunters.MinBy(DistanceTo)); }
public void Setup() { aquarium = new Aquarium("Nemo's aquarium", 3); Nemo = new Fish("Nemo"); NemosFather = new Fish("George"); }
public void Setup() { this.fish = new Fish("Petroslav"); this.aquarium = new Aquarium("Aquarium", 1); }
public static void FillDevicesLV(IListView listView, ILabel footer, IModel model) { try { listView.Clear(); listView.AddColumn(Localizer.LS(LSID.Aquarium), 200, true, BSDTypes.HorizontalAlignment.Left); listView.AddColumn(Localizer.LS(LSID.Name), 100, true, BSDTypes.HorizontalAlignment.Left); listView.AddColumn(Localizer.LS(LSID.Brand), 50, true, BSDTypes.HorizontalAlignment.Left); listView.AddColumn(Localizer.LS(LSID.Type), 100, true, BSDTypes.HorizontalAlignment.Left); listView.AddColumn(Localizer.LS(LSID.Enabled), 60, true, BSDTypes.HorizontalAlignment.Left); listView.AddColumn(Localizer.LS(LSID.Digital), 60, true, BSDTypes.HorizontalAlignment.Left); listView.AddColumn(Localizer.LS(LSID.Power), 100, true, BSDTypes.HorizontalAlignment.Right); listView.AddColumn(Localizer.LS(LSID.WorkTime), 100, true, BSDTypes.HorizontalAlignment.Right); listView.AddColumn(Localizer.LS(LSID.State), 80, true, BSDTypes.HorizontalAlignment.Left); listView.AddColumn(Localizer.LS(LSID.Value), 80, true, BSDTypes.HorizontalAlignment.Right); double totalPow = 0.0d; var records = model.QueryDevices(); foreach (Device rec in records) { Aquarium aqm = model.GetRecord <Aquarium>(rec.AquariumId); string aqmName = (aqm == null) ? "" : aqm.Name; string strType = Localizer.LS(ALData.DeviceProps[(int)rec.Type].Name); ItemState itemState; string strState = model.GetItemStateStr(rec.Id, ItemType.Device, out itemState); bool fin = (itemState == ItemState.Broken); if (fin && ALSettings.Instance.HideLosses) { continue; } var item = listView.AddItem(rec, aqmName, rec.Name, rec.Brand, strType, rec.Enabled.ToString(), rec.Digital.ToString(), ALCore.GetDecimalStr(rec.Power), ALCore.GetDecimalStr(rec.WorkTime), strState, string.Empty ); if (rec.Enabled) { totalPow += (rec.Power /* W/h */ * rec.WorkTime /* h/day */); } if (fin) { item.SetForeColor(BSDConsts.Colors.Gray); } } totalPow /= 1000.0d; double electricCost = totalPow * ALData.kWhCost; footer.Text = string.Format(Localizer.LS(LSID.PowerFooter), totalPow, electricCost); } catch (Exception ex) { fLogger.WriteError("FillDevicesLV()", ex); } }
public static bool RemoveItem_Prefix(Aquarium __instance, InventoryItem item) { RefreshAquariumSkyAppliers(__instance, true); return(true); }
public static void FillTransfersLV(IListView listView, IModel model, IFont boldFont) { listView.Clear(); listView.AddColumn(Localizer.LS(LSID.Date), 80, true, BSDTypes.HorizontalAlignment.Left); listView.AddColumn(Localizer.LS(LSID.Brand), 50, true, BSDTypes.HorizontalAlignment.Left); listView.AddColumn(Localizer.LS(LSID.Item), 140, true, BSDTypes.HorizontalAlignment.Left); listView.AddColumn(Localizer.LS(LSID.Type), 80, true, BSDTypes.HorizontalAlignment.Left); listView.AddColumn(Localizer.LS(LSID.SourceTank), 80, true, BSDTypes.HorizontalAlignment.Left); listView.AddColumn(Localizer.LS(LSID.TargetTank), 80, true, BSDTypes.HorizontalAlignment.Left); listView.AddColumn(Localizer.LS(LSID.Quantity), 80, true, BSDTypes.HorizontalAlignment.Right); listView.AddColumn(Localizer.LS(LSID.UnitPrice), 80, true, BSDTypes.HorizontalAlignment.Right); listView.AddColumn(Localizer.LS(LSID.Shop), 180, true, BSDTypes.HorizontalAlignment.Left); listView.AddColumn(Localizer.LS(LSID.Cause), 80, true, BSDTypes.HorizontalAlignment.Left); var records = model.QueryTransfers(); foreach (Transfer rec in records) { ItemType itemType = rec.ItemType; Aquarium aqmSour = model.Cache.Get <Aquarium>(ItemType.Aquarium, rec.SourceId); Aquarium aqmTarg = model.Cache.Get <Aquarium>(ItemType.Aquarium, rec.TargetId); var itemRec = model.GetRecord(rec.ItemType, rec.ItemId); string itName = (itemRec == null) ? string.Empty : itemRec.ToString(); string strType = Localizer.LS(ALData.TransferTypes[(int)rec.Type]); var brandedItem = itemRec as IBrandedItem; string brand = (brandedItem == null) ? "-" : brandedItem.Brand; var item = listView.AddItem(rec, ALCore.GetDateStr(rec.Timestamp), brand, itName, strType, (aqmSour == null) ? string.Empty : aqmSour.Name, (aqmTarg == null) ? string.Empty : aqmTarg.Name, rec.Quantity.ToString(), ALCore.GetDecimalStr(rec.UnitPrice), rec.Shop, rec.Cause ); if (itemType == ItemType.Aquarium) { item.SetFont(boldFont); } switch (rec.Type) { case TransferType.Sale: item.SetForeColor(BSDConsts.Colors.DimGray); break; case TransferType.Death: case TransferType.Exclusion: item.SetForeColor(BSDConsts.Colors.Gray); break; } // validation after format changes /*if (itemRec is Inventory) { * var inv = itemRec as Inventory; * var invType = ALCore.GetItemType(inv.Type); * if (invType != itemType) { * item.ForeColor = Color.Red; * } * }*/ } }
public void CanCreateAquarium() { Cage cage = new Aquarium(); Assert.IsNotNull(cage); }
public static void FillTransfersLVPreview(IListView listView, IModel model, Entity item, bool ftAquariums = true) { try { ItemType itemType; switch (item.EntityType) { case EntityType.Aquarium: itemType = ItemType.Aquarium; break; case EntityType.Inhabitant: var hItem = item as Inhabitant; SpeciesType speciesType = model.GetSpeciesType(hItem.SpeciesId); itemType = ALCore.GetItemType(speciesType); break; case EntityType.Nutrition: itemType = ItemType.Nutrition; break; case EntityType.Device: itemType = ItemType.Device; break; case EntityType.Inventory: var invItem = item as Inventory; itemType = ALCore.GetItemType(invItem.Type); break; default: itemType = ItemType.None; break; } int itemId = item.Id; listView.BeginUpdate(); listView.Clear(); listView.AddColumn(Localizer.LS(LSID.Date), 80, true, BSDTypes.HorizontalAlignment.Left); listView.AddColumn(Localizer.LS(LSID.Type), 80, true, BSDTypes.HorizontalAlignment.Left); if (ftAquariums) { listView.AddColumn(Localizer.LS(LSID.SourceTank), 80, true, BSDTypes.HorizontalAlignment.Left); listView.AddColumn(Localizer.LS(LSID.TargetTank), 80, true, BSDTypes.HorizontalAlignment.Left); } listView.AddColumn(Localizer.LS(LSID.Quantity), 80, true, BSDTypes.HorizontalAlignment.Right); listView.AddColumn(Localizer.LS(LSID.UnitPrice), 80, true, BSDTypes.HorizontalAlignment.Right); listView.AddColumn(Localizer.LS(LSID.Shop), 180, true, BSDTypes.HorizontalAlignment.Left); listView.AddColumn(Localizer.LS(LSID.Cause), 80, true, BSDTypes.HorizontalAlignment.Left); //Font defFont = listView.Font; //Font boldFont = new Font(defFont, FontStyle.Bold); var records = model.QueryTransfers(itemId, (int)itemType); foreach (Transfer rec in records) { var itemRec = model.GetRecord(rec.ItemType, rec.ItemId); string itName = (itemRec == null) ? string.Empty : itemRec.ToString(); string strType = Localizer.LS(ALData.TransferTypes[(int)rec.Type]); IListItem listItem; if (ftAquariums) { Aquarium aqmSour = model.Cache.Get <Aquarium>(ItemType.Aquarium, rec.SourceId); Aquarium aqmTarg = model.Cache.Get <Aquarium>(ItemType.Aquarium, rec.TargetId); listItem = listView.AddItem(rec, ALCore.GetDateStr(rec.Timestamp), strType, (aqmSour == null) ? string.Empty : aqmSour.Name, (aqmTarg == null) ? string.Empty : aqmTarg.Name, rec.Quantity.ToString(), ALCore.GetDecimalStr(rec.UnitPrice), rec.Shop, rec.Cause ); } else { listItem = listView.AddItem(rec, ALCore.GetDateStr(rec.Timestamp), strType, rec.Quantity.ToString(), ALCore.GetDecimalStr(rec.UnitPrice), rec.Shop, rec.Cause ); } if (itemType == ItemType.Aquarium) { //listItem.Font = boldFont; } switch (rec.Type) { case TransferType.Sale: listItem.SetForeColor(BSDConsts.Colors.DimGray); break; case TransferType.Death: case TransferType.Exclusion: listItem.SetForeColor(BSDConsts.Colors.Gray); break; } } listView.EndUpdate(); } catch (Exception ex) { fLogger.WriteError("FillTransfersLV()", ex); } }
public void TestAquariumName() { Aquarium aquarium = new Aquarium("Sofia", 10); Assert.AreEqual(aquarium.Name, "Sofia"); }
void WashMe(object sender, RoutedEventArgs e) { Aquarium aq = sender as Aquarium; MessageBox.Show("Dirty!"); }
public void SetUp() { this.aquarium = new Aquarium("Akvarium", 5); }
void FireClean(object sender, RoutedEventArgs e) { Aquarium aq = (Aquarium)this.FindName("theAquarium"); aq.RaiseEvent(new RoutedEventArgs(AquariumFilter.NeedsCleaningEvent)); }
public void Setup() { this.aquarium = new Aquarium("Atlantida", 3); this.firstFish = new Fish("Nemo"); this.seocondFish = new Fish("Scarface"); }
public void Setup() { aquarium = new Aquarium("Aqua", 2); fish = new Fish("fish1"); }
private void GenerateZoo() { _zoo = new Zoo("АО \"Наш новый зоопарк\"", "Россия, г.Н-ск, ул.Новая, 50"); var aviary1 = new Yard(YardType.Plain); System.Threading.Thread.Sleep(20); var aviary2 = new Cage(CageType.WithTrees); System.Threading.Thread.Sleep(20); var aviary3 = new Cage(CageType.WithRocks, 300.00, 3); System.Threading.Thread.Sleep(20); var aviary4 = new Pool(PoolType.Pond, 400, 10); System.Threading.Thread.Sleep(20); var aviary5 = new Aquarium(AquariumType.SeaWater, 5, 10); System.Threading.Thread.Sleep(20); var aviary6 = new GlassAviary(GlassAviaryType.WithWater); System.Threading.Thread.Sleep(20); aviary1.SettleAnimal(new Mammal(MammalDetachment.Artiodactyla, "Оленьи", "Олени", "Благородный олень")); System.Threading.Thread.Sleep(20); aviary1.SettleAnimal(new Mammal(MammalDetachment.Artiodactyla, "Оленьи", "Олени", "Пятнистый олень")); System.Threading.Thread.Sleep(20); aviary1.SettleAnimal(new Mammal(MammalDetachment.Artiodactyla, "Оленьи", "Олени", "Пятнистый олень")); System.Threading.Thread.Sleep(20); aviary2.SettleAnimal(new Mammal(MammalDetachment.Primates, "Гоминиды", "Орангутаны", "Суматранский орангутан")); System.Threading.Thread.Sleep(20); aviary3.SettleAnimal(new Mammal(MammalDetachment.Carnivora, "Кошачьи", "Пантеры", "Западноафриканский лев")); System.Threading.Thread.Sleep(20); aviary3.SettleAnimal(new Mammal(MammalDetachment.Carnivora, "Кошачьи", "Пантеры", "Западноафриканский лев")); System.Threading.Thread.Sleep(20); aviary4.SettleAnimal(new Bird(BirdDetachment.Anseriformes, "Утиные", "Лебеди", "Черный лебедь")); System.Threading.Thread.Sleep(20); aviary4.SettleAnimal(new Bird(BirdDetachment.Anseriformes, "Утиные", "Лебеди", "Лебедь-шипун")); System.Threading.Thread.Sleep(20); aviary4.SettleAnimal(new Bird(BirdDetachment.Anseriformes, "Утиные", "Лебеди", "Лебедь-трубач")); System.Threading.Thread.Sleep(20); aviary5.SettleAnimal(new Fish(FishDetachment.Salmoniformes, "Лососёвые", "Лососи", "Лосось атлантический")); System.Threading.Thread.Sleep(20); aviary5.SettleAnimal(new Fish(FishDetachment.Salmoniformes, "Лососёвые", "Лососи", "Лосось атлантический")); System.Threading.Thread.Sleep(20); aviary5.SettleAnimal(new Fish(FishDetachment.Salmoniformes, "Лососёвые", "Лососи", "Лосось атлантический")); System.Threading.Thread.Sleep(20); aviary5.SettleAnimal(new Fish(FishDetachment.Salmoniformes, "Лососёвые", "Лососи", "Кумжа")); System.Threading.Thread.Sleep(20); aviary5.SettleAnimal(new Amphibian(AmphibianDetachment.Urodela, "Саламандровые", "Малые тритоны", "Обыкновенный тритон")); System.Threading.Thread.Sleep(20); aviary5.SettleAnimal(new Amphibian(AmphibianDetachment.Urodela, "Саламандровые", "Малые тритоны", "Обыкновенный тритон")); _zoo.AddAviary(aviary1); _zoo.AddAviary(aviary2); _zoo.AddAviary(aviary3); _zoo.AddAviary(aviary4); _zoo.AddAviary(aviary5); _zoo.AddAviary(aviary6); Console.Clear(); Console.WriteLine("------------------------------------------------"); Console.WriteLine("Сгенерирован зоопарк"); Console.WriteLine("С названием:{0} и \nадресом:{1}", _zoo.Name, _zoo.Address); Console.WriteLine("------------------------------------------------"); Console.WriteLine("Нажмите любую клавишу для возврата в меню..."); Console.ReadKey(); }
public void SetUp() { this.aquarium = new Aquarium(name, capacity); }