[Test, Isolated] // use 'Isolated' attr. because this test changes the state of the db & we want to make sure the changes are rolled back. public void Update_WhenCalled_ShouldUpdateTheGivenCoop() { // Arrange // Mock the current user (w/ extension method) var user = _context.Users.First(); _controller.MockCurrentUser(user.Id, user.UserName); // Add co-op session to context var game = _context.Games.Single(g => g.Id == 1); // get a game that we know the Id for var coop = new Coop { Host = user, DateTime = DateTime.Now.AddDays(1), Game = game, Venue = "-" }; _context.Coops.Add(coop); _context.SaveChanges(); // Act var result = _controller.Update(new CoopFormViewModel { Id = coop.Id, Date = DateTime.Today.AddMonths(1).ToString("d MMM yyyy"), Time = "20:00", Venue = "Venue", Game = 2 // Note: we will be updating the game id so we can check later and know the update was successful }); // Assert _context.Entry(coop).Reload(); // refresh the updated co-op session from the database coop.DateTime.Should().Be(DateTime.Today.AddMonths(1).AddHours(20)); coop.Venue.Should().Be("Venue"); coop.GameId.Should().Be(2); }
public void StartSimulation(int month) { //INI Dosyası Okunuyor if (ReadConfigurationFile()) { //Simulasyonu baslat Coop coop = new Coop(); // T 0 Anindan Bir disi bir erkek tavsan olusturuluyor. coop.AddFemaleRabbitToCoop(new FemaleRabbit(TotalTimeOfPregnancy, LoseOfFertility, PercentageOfMaleRabbitBorn, MaximumNumberOfNewbornRabbits, FemaleRabbitLifeTime)); coop.AddMaleRabbitToCoop(new MaleRabbit(MaleRabbitLifeTime)); for (int currentMonth = 1; currentMonth <= month; currentMonth++) { // Tavsanlar bir ay yaslandiriliyor. coop.GetAllRabbitsOlder(); } //simulasyon sonucu yazdiriliyor int maxAge = MaleRabbitLifeTime > FemaleRabbitLifeTime ? MaleRabbitLifeTime : FemaleRabbitLifeTime; for (int currentMonth = 0; currentMonth < maxAge; currentMonth++) { Console.WriteLine(currentMonth + " Aylık " + coop.GetMaleRabbitCount(currentMonth) + " Erkek " + coop.GetFemaleRabbitCount(currentMonth) + " Dişi"); } //debug esnasinda sonuclari gorebilmek icin bu satir eklendi. Console.ReadLine(); } }
public static void dayUpdate_Postfix(Coop __instance, int dayOfMonth) { if (!Mod.instance.buildings.ContainsKey(__instance.buildingType)) { return; } var bdata = Mod.instance.buildings[__instance.buildingType]; if (bdata.AutoFeedsAnimals) { int num = Math.Min((__instance.indoors.Value as AnimalHouse).animals.Count() - __instance.indoors.Value.numberOfObjectsWithName("Hay"), (Game1.getLocationFromName("Farm") as Farm).piecesOfHay); (Game1.getLocationFromName("Farm") as Farm).piecesOfHay.Value -= num; for (int ix = 0; ix < __instance.indoors.Value.map.Layers[0].LayerWidth && num > 0; ++ix) { for (int iy = 0; iy < __instance.indoors.Value.map.Layers[0].LayerHeight && num > 0; ++iy) { if (__instance.indoors.Value.doesTileHaveProperty(ix, iy, "Trough", "Back") != null) { __instance.indoors.Value.objects.Add(new Vector2(ix, iy), new StardewValley.Object(178, 1, false, -1, 0)); --num; } } } } }
/// <summary>The method to call after <see cref="Coop.dayUpdate"/>.</summary> private static void After_DayUpdate(Coop __instance, int dayOfMonth) { if (!Mod.Instance.Buildings.TryGetValue(__instance.buildingType.Value, out BuildingData buildingData)) { return; } if (buildingData.AutoFeedsAnimals && __instance.indoors.Value is AnimalHouse animalHouse) { Farm farm = Game1.getFarm(); int num = Math.Min(animalHouse.animals.Count() - __instance.indoors.Value.numberOfObjectsWithName("Hay"), farm.piecesOfHay.Value); farm.piecesOfHay.Value -= num; for (int ix = 0; ix < __instance.indoors.Value.map.Layers[0].LayerWidth && num > 0; ++ix) { for (int iy = 0; iy < __instance.indoors.Value.map.Layers[0].LayerHeight && num > 0; ++iy) { if (__instance.indoors.Value.doesTileHaveProperty(ix, iy, "Trough", "Back") != null) { __instance.indoors.Value.objects.Add(new Vector2(ix, iy), new SObject(178, 1)); --num; } } } } }
protected void Button1_Click(object sender, EventArgs e) { this.DivCadCoop.Visible = false; this.DivLoginCoop.Visible = true; Coop c = new Coop(); try { if (c.verificaCoope(TextBox1.Text, TextBox2.Text) || ((TextBox1.Text == " ") && (TextBox2.Text == " "))) { string cnpj = c.Cnpj; Response.Redirect("Cooperativa.aspx?CNPJ=" + cnpj); } else { Label1.Text = "Email ou senha incorreto!"; Div_Error.Visible = true; TextBox1.Text = ""; TextBox2.Text = ""; } } catch (Exception p) { Label1.Text = p.Message; Div_Error.Visible = true; TextBox1.Text = ""; TextBox2.Text = ""; } }
public ActionResult Create(CoopFormViewModel viewModel) { // Check that model state is valid if (!ModelState.IsValid) { // Set the Games property of view model viewModel.Games = _unitOfWork.Games.GetGames(); return(View("CoopForm", viewModel)); } var coop = new Coop { HostId = User.Identity.GetUserId(), DateTime = viewModel.GetDateTime(), GameId = viewModel.Game, Venue = viewModel.Venue }; // Add the new co-op session _unitOfWork.Coops.Add(coop); // Complete the transaction _unitOfWork.Complete(); return(RedirectToAction("Mine", "Coops")); }
public void AddCoop(int id, Coop c) { Student s = (Student)_users.GetUserById(id); s.Coops.Add(c); _users.UpdateUser(s); _users.Save(); }
public void LifeCyclePoultry(Coop coop, int months) { if (months <= 0) { MessageBox.Show("There are 1 female and 1 male newborn rabbits in the coop", "Info"); } else { coop.AddPoultry(PoultryEnum.Rabbit, GenderEnum.Female); coop.AddPoultry(PoultryEnum.Rabbit, GenderEnum.Male); for (int month = 0; month <= months;) { if (coop.PoultryList.ToList().Count() > 0) { int newBornFemale = 0; int newBornMale = 0; foreach (Poultry femalePoultry in coop.PoultryList.Where(x => x.GenderEnum == GenderEnum.Female).ToList()) { if (femalePoultry.GenderEnum == GenderEnum.Female && femalePoultry.LoseofFertility > femalePoultry.Age && femalePoultry.Age > 0) { if (femalePoultry.isPregnant) { newBornFemale += coop.GetNumberofNewborn() * coop.GetPercentageofBorn() / 100; newBornMale += coop.GetNumberofNewborn() * (100 - coop.GetPercentageofBorn()) / 100; femalePoultry.isPregnant = false; femalePoultry.isPostPartumPeriod = true; } else if (femalePoultry.Age > 0 && femalePoultry.isPostPartumPeriod) { femalePoultry.isPostPartumPeriod = false; } else { femalePoultry.isPregnant = true; } } } for (int i = 0; i < newBornFemale; i++) { coop.AddPoultry(PoultryEnum.Rabbit, GenderEnum.Female); } for (int i = 0; i < newBornMale; i++) { coop.AddPoultry(PoultryEnum.Rabbit, GenderEnum.Male); } AddLifeCycle(coop); month += Statistics.addLife; } } } Show(months, coop); }
public ActionResult AddComment(Coop c) { int code = scs.UpdateCoop(c); if (code > 0) { return(RedirectToAction("Details", new { id = c.CoopId })); } return(View(c)); }
public static bool performActionOnUpgrade_Prefix(Coop __instance, GameLocation location) { if (!Mod.instance.buildings.ContainsKey(__instance.buildingType)) { return(true); } var bdata = Mod.instance.buildings[__instance.buildingType]; return(false); }
public void AddLifeCycle(Coop coop) { foreach (Poultry poultry in coop.PoultryList.ToList()) { if (coop.IsDeath(poultry.PoultryEnum, poultry.Age)) { coop.PoultryList.Remove(poultry); } poultry.Age += Statistics.addLife; } }
// this patch doesn't work - crashes the game from __instance being null (your guess is as good as mine) /* * public static bool getUpgradeSignLocation_Postfix(Coop __instance, ref Vector2 __result) * { * if (!Mod.instance.buildings.ContainsKey(__instance.buildingType)) * { * return true; * } * * var bdata = Mod.instance.buildings[__instance.buildingType]; * * __result = new Vector2( __instance.tileX.Value + bdata.UpgradeSignX, __instance.tileY.Value + bdata.UpgradeSignY ) * Game1.tileSize * * return false; * } * //*/ public static bool draw_Prefix(Coop __instance, SpriteBatch b) { if (!Mod.instance.buildings.ContainsKey(__instance.buildingType)) { return(false); } var bdata = Mod.instance.buildings[__instance.buildingType]; if (__instance.isMoving) { return(false); } if (__instance.daysOfConstructionLeft.Value > 0) { __instance.drawInConstruction(b); } else { __instance.drawShadow(b, -1, -1); Vector2 animalDoorBase = new Vector2(__instance.tileX.Value + __instance.animalDoor.X, __instance.tileY.Value + __instance.animalDoor.Y - bdata.AnimalDoorHeight + 1); int animalDoorY = Mod.instance.Helper.Reflection.GetField <NetInt>(__instance, "yPositionOfAnimalDoor").GetValue().Value; float alpha = Mod.instance.Helper.Reflection.GetField <NetFloat>(__instance, "alpha").GetValue().Value; for (int ix = 0; ix < bdata.AnimalDoorWidth; ++ix) { for (int iy = 0; iy < bdata.AnimalDoorHeight; ++iy) { var pos = Game1.GlobalToLocal(Game1.viewport, (animalDoorBase + new Vector2(ix, iy)) * Game1.tileSize); var rect = new Rectangle(ix * 16, bdata.BuildingHeight + iy * 16, 16, 16); b.Draw(bdata.texture, pos, new Rectangle(rect.X + bdata.AnimalDoorWidth * 16, rect.Y, rect.Width, rect.Height), Color.White * alpha, 0, Vector2.Zero, Game1.pixelZoom, SpriteEffects.None, 1e-06f); } } float depth = ( float )((__instance.tileY.Value + __instance.tilesHigh.Value) * 64 / 10000.0 + 9.99999974737875E-05); for (int ix = 0; ix < bdata.AnimalDoorWidth; ++ix) { for (int iy = 0; iy < bdata.AnimalDoorHeight; ++iy) { var pos = Game1.GlobalToLocal(Game1.viewport, (animalDoorBase + new Vector2(ix, iy)) * Game1.tileSize) + new Vector2(0, animalDoorY); var rect = new Rectangle(ix * 16, bdata.BuildingHeight + iy * 16, 16, 16); b.Draw(bdata.texture, pos, rect, Color.White * alpha, 0, Vector2.Zero, Game1.pixelZoom, SpriteEffects.None, depth); } } b.Draw(bdata.texture, Game1.GlobalToLocal(Game1.viewport, new Vector2(__instance.tileX.Value, __instance.tileY.Value + __instance.tilesHigh.Value) * Game1.tileSize), new Rectangle(0, 0, bdata.TileWidth * 16, bdata.BuildingHeight), Color.White * alpha, 0, new Vector2(0, bdata.BuildingHeight), Game1.pixelZoom, SpriteEffects.None, depth + 0.00001f); if (__instance.daysUntilUpgrade.Value <= 0) { return(false); } b.Draw(Game1.mouseCursors, Game1.GlobalToLocal(Game1.viewport, new Vector2(__instance.tileX.Value + bdata.UpgradeSignX, __instance.tileY.Value + bdata.UpgradeSignY) * Game1.tileSize), new Rectangle(367, 309, 16, 15), Color.White * alpha, 0, Vector2.Zero, Game1.pixelZoom, SpriteEffects.None, depth + 0.00001f); } return(false); }
public void LangEN() { langRuBut.SetActive(true); langEnBut.SetActive(false); info.lang = 0; GetComponent <RUENGImageChanger>().Start(); Tables.GetComponent <RUENGTablesChanger>().Start(); Endless.GetComponent <RUENGImageChanger>().Start(); Coop.GetComponent <RUENGImageChanger>().Start(); NewGame.GetComponent <RUENGImageChanger>().Start(); CoopInputField.GetComponent <RUENGTextChanger>().Start(); info.Save(); }
public CoopHint(Coop coop) { _coop = coop; _rectangle = new RectanglePiece(500, 1000) { Colour = RpTextureColorManager.GetCoopLayoutColor(_coop), Alpha = 0.5f }; Children = new Drawable[] { _rectangle }; }
public void Cancel_CoopIsCanceled_ShouldReturnNotFound() { // Setup - add a canceled co-op session to repository var coop = new Coop(); coop.Cancel(); _mockRepository.Setup(r => r.GetCoopWithAttendees(1)).Returns(coop); // Action - attempt to cancel a co-op session that has already been canceled var result = _controller.Cancel(1); // Assert - co-op session not found result.Should().BeOfType <NotFoundResult>(); }
public static void performActionOnConstruction_Postfix(Coop __instance, GameLocation location) { if (!Mod.instance.buildings.ContainsKey(__instance.buildingType)) { return; } var bdata = Mod.instance.buildings[__instance.buildingType]; __instance.indoors.Value.objects.Remove(new Microsoft.Xna.Framework.Vector2(3, 3)); StardewValley.Object @object = new StardewValley.Object(new Vector2(bdata.FeedHopperX, bdata.FeedHopperY), 99, false); @object.fragility.Value = 2; __instance.indoors.Value.objects.Add(new Vector2(bdata.FeedHopperX, bdata.FeedHopperY), @object); __instance.daysOfConstructionLeft.Value = bdata.DaysToConstruct; }
public void Cancel_ValidRequest_ShouldReturnOk() { // Setup - add a co-op session to repository for the current user var coop = new Coop { HostId = _userId }; _mockRepository.Setup(r => r.GetCoopWithAttendees(1)).Returns(coop); // Action - make a valid cancel request on a co-op session var result = _controller.Cancel(1); // Assert - co-op session canceled ok result.Should().BeOfType <OkResult>(); }
public void Cancel_UserCancelingAnotherUsersCoop_ShouldReturnUnauthorized() { // Setup - add a co-op session that belongs to a different user var coop = new Coop { HostId = _userId + "-" }; _mockRepository.Setup(r => r.GetCoopWithAttendees(1)).Returns(coop); // Action - attempt to cancel another user's co-op session var result = _controller.Cancel(1); // Assert - not authorized to cancel result.Should().BeOfType <UnauthorizedResult>(); }
/// <summary>The method to call after <see cref="Coop.performActionOnConstruction"/>.</summary> private static void After_PerformActionOnConstruction(Coop __instance, GameLocation location) { if (!Mod.Instance.Buildings.TryGetValue(__instance.buildingType.Value, out BuildingData buildingData)) { return; } __instance.indoors.Value.objects.Remove(new Vector2(3, 3)); StardewValley.Object @object = new StardewValley.Object(new Vector2(buildingData.FeedHopperX, buildingData.FeedHopperY), 99) { Fragility = 2 }; __instance.indoors.Value.objects.Add(new Vector2(buildingData.FeedHopperX, buildingData.FeedHopperY), @object); __instance.daysOfConstructionLeft.Value = buildingData.DaysToConstruct; }
/// <summary> /// RpHitObject's border co-op color /// </summary> /// <returns></returns> public static Color4 GetCoopHitObjectColor(Coop coop) { switch (coop) { case Coop.Both: //Both return(new Color4(100, 100, 100, 255)); case Coop.LeftOnly: //Left : blue return(new Color4(70, 192, 206, 255)); case Coop.RightOnly: //Right : purple return(new Color4(224, 80, 178, 255)); } return(new Color4(255, 255, 255, 255)); }
void Start() { m_agent = GetComponent <NavMeshAgent>(); m_animator = GetComponent <Animator>(); GameObject[] nestObjects = GameObject.FindGameObjectsWithTag("Nest"); m_nests = new Nest[nestObjects.Length]; for (int i = 0; i < nestObjects.Length; ++i) { m_nests[i] = nestObjects[i].GetComponent <Nest>(); } m_coop = GameObject.FindGameObjectWithTag("Coop").GetComponent <Coop>(); m_exits = GameObject.FindGameObjectsWithTag("Exit"); }
protected void LinkButton1_Click(object sender, EventArgs e) { Coop c = new Coop(); GridViewBuscaCooperativa.DataSource = c.PesquisaCooperativa(); GridViewBuscaCooperativa.DataBind(); this.Div_Busca_Cooperativa.Visible = true; this.Div_Amostra_Solicitada.Visible = false; this.Div_Perfil_do_Produtor.Visible = false; this.Div_Historico_de_Negociação.Visible = false; this.Div_Editar_Perfil.Visible = false; this.Divbemvindo.Visible = false; this.Div_Iniciar_Negociação.Visible = false; this.Div_Error.Visible = false; }
public void GetUpcomingCoopsByHost_CoopIsForADifferentHost_ShouldNotBeReturned() { // Setup - create a co-op session in the future that is for a different host var coop = new Coop() { DateTime = DateTime.Now.AddDays(1), HostId = "1" }; // Setup - use extension method to populate mock DbSet with this coop object _mockCoops.SetSource(new[] { coop }); // Action - try to get co-op session that belongs to a different host var coops = _repository.GetUpcomingCoopsByHost(coop.HostId + "-"); // Assert - coops should be empty coops.Should().BeEmpty(); }
public void GetUpcomingCoopsByHost_CoopIsForTheGivenHostAndIsInTheFuture_ShouldBeReturned() { // Setup - create a co-op session in the future that is for the current user/host var coop = new Coop() { DateTime = DateTime.Now.AddDays(1), HostId = "1" }; // Setup - use extension method to populate mock DbSet with this coop object _mockCoops.SetSource(new[] { coop }); // Action - try to get co-op session var coops = _repository.GetUpcomingCoopsByHost(coop.HostId); // Assert - coops should contain the above "setup" co-op session coops.Should().Contain(coop); }
public void GetUpcomingCoopsByHost_CoopIsInThePast_ShouldNotBeReturned() { // Setup - create a co-op session in the past var coop = new Coop() { DateTime = DateTime.Now.AddDays(-1), HostId = "1" }; // Setup - use extension method to populate mock DbSet with this coop object _mockCoops.SetSource(new[] { coop }); // Action - try to get co-op session that is in the past var coops = _repository.GetUpcomingCoopsByHost("1"); // Assert - coops should be empty coops.Should().BeEmpty(); }
public static void BuildingDayUpdatePrefix(Coop __instance, ref int dayOfMonth) { AnimalHouse animalHouseInstance = (AnimalHouse)__instance.indoors.Value; int eggID = animalHouseInstance.incubatingEgg.Y; FarmAnimal farmAnimal; // If egg is ready to hatch ... if (eggID > 0 && animalHouseInstance.incubatingEgg.X <= 0) { farmAnimal = ModEntry.BirthAnimal(animalHouseInstance, eggID); if (farmAnimal != null) { __instance.indoors.Value.map.GetLayer("Front").Tiles[1, 2].TileIndex = 45; } } }
public ActionResult Edit(Coop c) { int result = DateTime.Compare(c.StartDate, c.EndDate); if (result >= 0) { ViewBag.DateError = "The start date must be earlier than end date."; return(View(c)); } int code = scs.UpdateCoop(c); if (code > 0) { return(RedirectToAction("Index", "Students")); } return(View(c)); }
private bool IsNamingNewlyHatchedFarmAnimal() { Coop coop; try { coop = new Coop(Game1.currentLocation); } catch { // Probably not in a coop return(false); } // It comes with the Big Coop and the Deluxe Coop return(coop.CanHaveIncubator()); }
protected void Button3_Click(object sender, EventArgs e) { try { if (TextBoxCNPJ.Text != "" && int.Parse(DropDownCIDADE.SelectedValue) != 0 && TextBoxNOME.Text != "" && TextBoxTELEFONE.Text != "" && TextBoxDESCRI.Text != "" && TextBoxEMAIL.Text != "" && TextBoxSENHA.Text != "" && TextBoxSITE.Text != "") { Coop c = new Coop(TextBoxCNPJ.Text, int.Parse(DropDownCIDADE.SelectedValue), TextBoxNOME.Text, TextBoxTELEFONE.Text, TextBoxDESCRI.Text, TextBoxEMAIL.Text, TextBoxSENHA.Text, TextBoxSITE.Text); c.inserir(); string cnpj = c.Cnpj; this.DivCadCoop.Visible = false; this.DivLoginCoop.Visible = true; Labelalerta.Text = "Cadastrado com Sucesso!!"; Alerta.Visible = true; } else { Label1.Text = "Algum campo não foi preenchido corretamente!"; Div_Error.Visible = true; this.DivCadCoop.Visible = true; this.DivLoginCoop.Visible = false; TextBoxCNPJ.Text = ""; TextBoxNOME.Text = ""; TextBoxTELEFONE.Text = ""; TextBoxDESCRI.Text = ""; TextBoxEMAIL.Text = ""; TextBoxSENHA.Text = ""; TextBoxSITE.Text = ""; } } catch (Exception p) { Label1.Text = p.Message; Div_Error.Visible = true; this.DivCadCoop.Visible = true; this.DivLoginCoop.Visible = false; TextBoxCNPJ.Text = ""; TextBoxNOME.Text = ""; TextBoxTELEFONE.Text = ""; TextBoxDESCRI.Text = ""; TextBoxEMAIL.Text = ""; TextBoxSENHA.Text = ""; TextBoxSITE.Text = ""; } // Response.Redirect("Cooperativa.aspx?CNPJ=" + cnpj); }
public async Task <List <Coop> > CoopInfo() { using (var client = new HttpClient()) { client.BaseAddress = new Uri("http://www.ist.rit.edu/"); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); try { HttpResponseMessage response = new HttpResponseMessage(); response = await client.GetAsync("api/employment/coopTable/coopInformation", HttpCompletionOption.ResponseHeadersRead); response.EnsureSuccessStatusCode(); var data = await response.Content.ReadAsStringAsync(); var rtnResults = JsonConvert.DeserializeObject <Dictionary <string, List <Coop> > >(data); List <Coop> coopTable = new List <Coop>(); Coop coop = new Coop(); foreach (KeyValuePair <string, List <Coop> > kvp in rtnResults) { foreach (var item in kvp.Value) { coopTable.Add(item); } } return(coopTable); } catch (HttpRequestException hre) { var msg = hre.Message; List <Coop> coopList = new List <Coop>(); return(coopList); //return "HttpRequestException"; } catch (Exception ex) { var msg = ex.Message; List <Coop> coopList = new List <Coop>(); return(coopList); //return "Exception"; ; } } }
public List<Coop> CargaCoop() { List<Coop> coop = new List<Coop>(); sqlDataAdapter.SelectCommand = new SqlCommand(); sqlDataAdapter.SelectCommand.Connection = sqlConnectionWeb; sqlDataAdapter.SelectCommand.CommandText = "ConsultaCoop"; sqlDataAdapter.SelectCommand.CommandType = CommandType.StoredProcedure; sqlDataAdapter.Fill(ds, "ConsultaCoop"); foreach (DataRow dr in ds.Tables["ConsultaCoop"].Rows) { Coop tmp = new Coop(); tmp.Id = Convert.ToString(dr["Id_Coop"]); tmp.Name = Convert.ToString(dr["Coop"]); coop.Add(tmp); } return coop; }