// GET: Admin/RealStates/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } RealState realState = _realStateRepo.Get(id.Value); if (realState == null) { return(HttpNotFound()); } var selectedCity = _geoDivisionRepo.Get(realState.GeoDivisionId); var selectedState = _geoDivisionRepo.GetGeoDivisionParent(selectedCity.ParentId.Value); var selectedCountry = _geoDivisionRepo.GetGeoDivisionParent(selectedState.ParentId.Value); ViewBag.SelectedState = selectedState.Id; ViewBag.SelectedCountry = selectedCountry.Id; ViewBag.States = _geoDivisionRepo.GetGeoDivisionChildren(selectedCountry.Id); ViewBag.Cities = _geoDivisionRepo.GetGeoDivisionChildren(selectedState.Id); ViewBag.Countries = _geoDivisionRepo.GetCountries(); return(View(realState)); }
public void TestRunWinner() { //Arrange Player p1 = new Player(100); Player p2 = new Player(0); RealState r = new RealState(100, 10); var mock = new Mock <IDice>(); mock.Setup(s => s.Roll()).Returns(1); var dice = mock.Object; Game g = new Game(new List <Player>() { p1, p2 }, new List <RealState>() { r }, dice); //Act Player winner = g.Run(); //Assert Assert.AreEqual(p1, winner); }
public double GetPower(RealState state) { if (state == null) { throw new ArgumentNullException(nameof(state)); } return((state.Solution[_posNode] - state.Solution[_negNode]) * -Current); }
public double GetCurrent(RealState state) { if (state == null) { throw new ArgumentNullException(nameof(state)); } return((state.Solution[_posNode] - state.Solution[_negNode]) * _temp.Conductance); }
public double GetVoltage(RealState state) { if (state == null) { throw new ArgumentNullException(nameof(state)); } return(state.Solution[_posNode] - state.Solution[_negNode]); }
public double GetCurrent(RealState state) { if (state == null) { throw new ArgumentNullException(nameof(state)); } return(state.Solution[BranchEq]); }
public double GetPower(RealState state) { if (state == null) { throw new ArgumentNullException(nameof(state)); } return(QCap.Derivative * (state.Solution[_posNode] - state.Solution[_negNode])); }
public double GetPower(RealState state) { if (state == null) { throw new ArgumentNullException(nameof(state)); } return((state.Solution[_posNode] - state.Solution[_negNode]) * state.Solution[ControlBranchEq] * _bp.Coefficient); }
public double GetCurrent(RealState state) { if (state == null) { throw new ArgumentNullException(nameof(state)); } return(state.Solution[ControlBranchEq] * _bp.Coefficient); }
public void TestNotHasOwner() { //Arrange RealState r = new RealState(50, 5); //Act //Assert Assert.IsFalse(r.HasOwner()); }
public double GetPower(RealState state) { if (state == null) { throw new ArgumentNullException(nameof(state)); } double v = state.Solution[_posNode] - state.Solution[_negNode]; return(v * v * _bp.Coefficient); }
public void TestRentIsOwner() { //Arrange Player p1 = new Player(5); RealState r = new RealState(50, 5, owner: p1); //Act r.RentTo(p1); //Assert Assert.AreEqual(5, p1.Balance); }
public void TestInit() { //Arrange RealState r = new RealState(50, 5); //Act //Assert Assert.AreEqual(50, r.Price); Assert.AreEqual(5, r.Rent); Assert.IsNull(r.Owner); }
public void TestHasOwner() { //Arrange Player p = new Player(0); RealState r = new RealState(50, 5, owner: p); //Act //Assert Assert.IsTrue(r.HasOwner()); Assert.AreEqual(p, r.Owner); }
public void TestForeclose() { //Arrange Player p = new Player(0); RealState r = new RealState(50, 5, owner: p); //Act r.Foreclose(); //Assert Assert.IsFalse(r.HasOwner()); }
public Complex GetPower(RealState state) { if (state == null) { throw new ArgumentNullException(nameof(state)); } Complex v = state.Solution[_posNode] - state.Solution[_negNode]; Complex i = state.Solution[_contBranch] * _bp.Coefficient.Value; return(-v *Complex.Conjugate(i)); }
public void TestSellError() { //Arrange Player p1 = new Player(100); Player p2 = new Player(100); RealState r = new RealState(50, 5, owner: p1); //Act //Assert Assert.Throws <RealState.SellException>(() => r.SellTo(p2)); }
public void TestHasOwnedBy() { //Arrange Player p1 = new Player(0); Player p2 = new Player(0); RealState r = new RealState(50, 5, owner: p1); //Act //Assert Assert.IsTrue(r.OwnerIs(p1)); Assert.IsFalse(r.OwnerIs(p2)); }
/// <summary> /// Constructor /// </summary> /// <param name="inductance">Inductor</param> /// <param name="current">Current</param> /// <param name="flux">Flux</param> /// <param name="state">State</param> public UpdateFluxEventArgs(double inductance, double current, StateDerivative flux, RealState state) { if (flux == null) { throw new ArgumentNullException(nameof(flux)); } Inductance = inductance; Current = current; OriginalFlux = flux.Current; Flux = flux; State = state ?? throw new ArgumentNullException(nameof(state)); }
public void TestDealSell() { //Arrange Player p1 = new Player(100); RealState r = new RealState(50, 5); //Act r.Deal(p1); //Assert Assert.IsTrue(r.OwnerIs(p1)); Assert.AreEqual(50, p1.Balance); }
public ActionResult Create(RealState realState, HttpPostedFileBase RealStateImage, HttpPostedFileBase VideoImage, HttpPostedFileBase Video) { realState.LastViewDate = DateTime.Now; if (ModelState.IsValid) { #region Upload Files if (RealStateImage != null) { // Saving Temp Image var newFileName = Guid.NewGuid() + Path.GetExtension(RealStateImage.FileName); RealStateImage.SaveAs(Server.MapPath("/Files/RealStateImages/Temp/" + newFileName)); // Resize Image ImageResizer big = new ImageResizer(2000, 2000, true); big.Resize(Server.MapPath("/Files/RealStateImages/Temp/" + newFileName), Server.MapPath("/Files/RealStateImages/Big/" + newFileName)); ImageResizer image = new ImageResizer(370, 270, true); image.Resize(Server.MapPath("/Files/RealStateImages/Temp/" + newFileName), Server.MapPath("/Files/RealStateImages/" + newFileName)); // Deleting Temp Image System.IO.File.Delete(Server.MapPath("/Files/RealStateImages/Temp/" + newFileName)); realState.Image = newFileName; } if (VideoImage != null) { // Saving Temp Image var newFileName = Guid.NewGuid() + Path.GetExtension(VideoImage.FileName); VideoImage.SaveAs(Server.MapPath("/Files/RealStateImages/Temp/" + newFileName)); // Resize Image ImageResizer image = new ImageResizer(870, 500, true); image.Resize(Server.MapPath("/Files/RealStateImages/Temp/" + newFileName), Server.MapPath("/Files/RealStateImages/VideoImages/" + newFileName)); // Deleting Temp Image System.IO.File.Delete(Server.MapPath("/Files/RealStateImages/Temp/" + newFileName)); realState.VideoThumbnail = newFileName; } if (Video != null) { var newFileName = Guid.NewGuid() + Path.GetExtension(Video.FileName); Video.SaveAs(Server.MapPath("/Files/RealStateImages/Videos/" + newFileName)); realState.VideoStr = newFileName; } #endregion _realStateRepo.Add(realState); return(RedirectToAction("Index")); } return(View(realState)); }
public void TestSell() { //Arrange Player p = new Player(100); RealState r = new RealState(50, 5); //Act r.SellTo(p); //Assert Assert.IsTrue(r.HasOwner()); Assert.IsTrue(r.OwnerIs(p)); Assert.AreEqual(50, p.Balance); }
// GET: Admin/RealStates/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } RealState realState = _realStateRepo.Get(id.Value); if (realState == null) { return(HttpNotFound()); } return(PartialView(realState)); }
public void TestSize() { //Arrange RealState r = new RealState(100, 10); Board b = new Board(new List <Player>(), new List <RealState>() { r }); //Act //Assert Assert.AreEqual(1, b.Size); }
public void TestDealRent() { //Arrange Player p1 = new Player(100); Player p2 = new Player(0); RealState r = new RealState(50, 5, owner: p2); //Act r.Deal(p1); //Assert Assert.AreEqual(95, p1.Balance); Assert.AreEqual(5, p2.Balance); }
public void TestTieAgain() { //Arrange List <Player> players = Player.FromStrategies(0); RealState r = new RealState(100, 10); Game g = new Game(players, new List <RealState>() { r }); //Act //Assert Assert.AreEqual(players[0], g.Leader); }
public void TestInit() { //Arrange List <Player> players = Player.FromStrategies(300); RealState r = new RealState(100, 10); Game g = new Game(players, new List <RealState>() { r }); //Act //Assert players.ForEach(p => Assert.IsTrue(p.Balance == 300)); Assert.IsNotNull(g.Board); }
public void TestLeader() { //Arrange List <Player> players = Player.FromStrategies(0); RealState r = new RealState(100, 10); Game g = new Game(players, new List <RealState>() { r }); //Act players[0].Receive(1); players[1].Receive(2); players[2].Receive(3); //Assert Assert.AreEqual(players[2], g.Leader); }
public void TestRemove() { //Arrange Player p = new Player(0); RealState r = new RealState(100, 10); Board b = new Board(new List <Player>() { p }, new List <RealState>() { r }); //Act b.Remove(p); //Assert Assert.AreEqual(0, b.Players.Count); }
public RealStateInfoDto CreateRealStateInfo(RealState realState) { var plan = GetRealStatePlanWithLowestPrice(realState.Id); var info = new RealStateInfoDto() { Id = realState.Id, Title = _currentLang == 1 ? realState.Title : realState.EnglishTitle, ShortDescription = _currentLang == 1 ? realState.ShortDescription : realState.EnglishShortDescription, Area = plan.Area, Rooms = plan.Rooms, Bathrooms = plan.BathRooms, MinPrice = CurrencyHelper.ExchangeAmount(plan.Price, _currentCurrency), Location = GetLocationStr(realState.GeoDivisionId), RealStateType = realState.Type, Image = realState.Image }; return(info); }