public void Should_compare_with_null_instance(double value) { var instance = new Yard(value); Assert.IsFalse(instance.Equals(null), "Equals"); Assert.AreEqual(1, instance.CompareTo(null), "CompareTo"); }
public void Should_initialize_instance(double value) { var actual = new Yard(value); Assert.IsAssignableFrom <Yard>(actual); Assert.AreEqual(value, actual.Value, nameof(actual.Value)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Number,BayId")] Yard yard) { if (id != yard.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(yard); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!YardExists(yard.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["BayId"] = new SelectList(_context.Bays, "Id", "Name", yard.BayId); return(View(yard)); }
/// <summary> /// Method for converting yard to inch /// </summary> /// <param name="yard"></param> /// <returns></returns> public Inches YardToInchConverter(Yard yard) { var inchValue = yard.GetValue() * 36; Inches inches = new Inches(inchValue); return(inches); }
public void Should_not_throw_exception_on_division_by_zero(double value, double expectedValue) { var instance = new Yard(value); var actual = instance / 0d; Assert.AreEqual(expectedValue, actual.Value); }
public void TestEvictAnimal() { var aviary = new Yard(YardType.Rock); //Успешная попытка выселить существующее животное var animal1 = new Mammal(MammalDetachment.Carnivora, "семейство1", "род1", "вид1"); aviary.SettleAnimal(animal1); aviary.EvictAnimal(animal1); Assert.AreEqual(0, aviary.GetListOfInhabitants().Count); //Неуспешная попытка выселить несуществующее животное try { aviary.EvictAnimal(null); Assert.Fail(); } catch (ArgumentException) { } //Неуспешная попытка выселить отсутствующее в вольере животное try { aviary.EvictAnimal(animal1); Assert.Fail(); } catch (ArgumentException) { } }
public ActionResult DeleteYard(string yardName) { Yard myYard = new Yard(); try { SqlDataReader reader; using (SqlConnection connection = getConnection()) { SqlCommand cmd = new SqlCommand("SELECT * FROM [YARD] WHERE yardName=@yardName"); cmd.CommandType = CommandType.Text; cmd.Connection = connection; cmd.Parameters.AddWithValue("@yardName", yardName); connection.Open(); reader = cmd.ExecuteReader(); while (reader.Read()) { myYard.yardName = reader["yardName"].ToString(); myYard.yardLocation = reader["yardLocation"].ToString(); myYard.yardCountry = reader["yardCountry"].ToString(); } reader.Close(); connection.Close(); } } catch (Exception ex) { Console.WriteLine(ex.Message); } return(View(myYard)); }
public ActionResult Index() { int yardId = Convert.ToInt32(HttpContext.Request["yardid"]); string query = $"SELECT [YardId],[Name],[cur_equipment],[cur_units],[max_equipment],[max_units],[update] FROM Yard WHERE YardId = {yardId}"; SqlConnection conn = new SqlConnection(connStr); SqlCommand cmd = new SqlCommand(query, conn); conn.Open(); List <Yard> yards = IDataTable.To <Yard>(DAO.Exec(cmd)); conn.Close(); SqlDependencyService service = new SqlDependencyService(); service.Config(); Yard yard = yards.Find(y => y.YardId == yardId); ViewBag.yard = (yard != null) ? yard : new Yard(); string Name = (yard == null)?"":yard.Name; ViewBag.Title = $"Yarda {Name}"; return(View()); }
public void Arithmetic() { Assert.AreEqual(-Ounce.S(4), -(Pint.S(0.25))); Assert.AreEqual(Cup.S(1), Ounce.S(4) + Pint.S(0.25)); Assert.AreEqual(Pint.S(-0.25), Quart.S(0.25) - Ounce.S(12)); Assert.AreEqual(-Foot.S(3), Inch.Es(36) - Yard.S(2)); }
public IHttpActionResult PutYard(int id, Yard yard) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != yard.YardId) { return(BadRequest()); } db.Entry(yard).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!YardExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
/// <summary> /// Method for convertinf yard value to feet /// </summary> /// <param name="yard"></param> /// <returns></returns> public Feet YardToFeetConverter(Yard yard) { var yardToFeet = yard.GetValue() * 3; var feetValue = new Feet(yardToFeet); return(feetValue); }
public void Should_cast_from_double(double value) { var expected = new Yard(value); var actual = (Yard)value; Assert.AreEqual(expected, actual); }
public ActionResult DeleteConfirmed(int id) { Yard yard = db.Yards.Find(id); db.Yards.Remove(yard); db.SaveChanges(); return(RedirectToAction("Index")); }
public void Should_cast_to_double(double value) { var instance = new Yard(value); var actual = (double)instance; Assert.AreEqual(value, actual); }
public void Arithmetic() { Assert.AreEqual(Tablespoon.S(-3), -Tablespoon.S(3)); Assert.AreEqual(-Cup.S(1.5), Cup.S(6.5) - Cup.S(8)); Assert.AreEqual(-Tablespoon.S(24), Cup.S(6.5) - Gallon.S(0.5)); Assert.AreEqual(-24.Tablespoons(), 6.5.Cups() - 0.5.Gallons()); Assert.AreEqual(-Foot.S(6), Inch.Es(18) - Yard.S(2.5)); }
public void Should_compare_with_another_type_of_instance(double value) { var instance1 = new Yard(value); object instance2 = value; Assert.IsFalse(instance1.Equals(instance2), "Equals"); Assert.Throws <ArgumentException>(() => instance1.CompareTo(instance2), "CompareTo"); }
public void Should_own_a_HashCode(double value) { var expected = value.GetHashCode(); var instance = new Yard(value); var actual = instance.GetHashCode(); Assert.AreEqual(expected, actual); }
public void Should_absolute_value(double value, double expectedValue) { var expected = new Yard(expectedValue); var instance = new Yard(value); var actual = instance.Abs(); Assert.AreEqual(expected, actual); }
public void Should_roundvalue_withMode(MidpointRounding mode, double value, double expectedValue) { var expected = new Yard(expectedValue); var instance = new Yard(value); var actual = instance.Round(mode); Assert.AreEqual(expected, actual); }
public void Should_round_value_withDigit(double value, double expectedValue) { var expected = new Yard(expectedValue); var instance = new Yard(value); var actual = instance.Round(1); Assert.AreEqual(expected, actual); }
public void Should_floor_value(double value, double expectedValue) { var expected = new Yard(expectedValue); var instance = new Yard(value); var actual = instance.Floor(); Assert.AreEqual(expected, actual); }
public void Should_format_string(string format, string mask) { var expected = string.Format(Consts.CultureEnUS, mask, 1.757899e2); var instance = new Yard(1.757899e2); var actual = instance.ToString(format, Consts.CultureEnUS); Assert.AreEqual(expected, actual); }
public void Should_convert_to_string(double value) { var expected = $"{value:e} yd"; var instance = new Yard(value); var actual = instance.ToString(); Assert.AreEqual(expected, actual); }
public void Should_divide_instance_by_double(double leftValue, double rightValue, double expectedValue) { var expected = new Yard(expectedValue); var instance = new Yard(leftValue); var actual = instance / rightValue; Assert.AreEqual(expected, actual); }
public ActionResult <double> YardToInchConverter(Yard yard) { var inchValue = _quantityMeasurementManager.YardToInchConverter(yard); if (inchValue != null) { return(this.Ok(inchValue.GetValue())); } return(this.BadRequest()); }
public IActionResult YardToFeetConveter(Yard yard) { var feetValue = _quantityMeasurementManager.YardToFeetConverter(yard); if (feetValue != null) { return(this.Ok(feetValue.GetValue())); } return(this.BadRequest()); }
public ActionResult Edit([Bind(Include = "YardID,YardName,YardLocation")] Yard yard) { if (ModelState.IsValid) { db.Entry(yard).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(yard)); }
public void Should_multiply_double_by_instance(double leftValue, double rightValue, double expectedValue) { var expected = new Yard(expectedValue); var instance = new Yard(rightValue); var actual = leftValue * instance; Assert.AreEqual(expected, actual); }
public void Should_subtract_two_instances(double leftValue, double rightValue, double expectedValue) { var expected = new Yard(expectedValue); var leftInstance = new Yard(leftValue); var rightInstance = new Yard(rightValue); var actual = leftInstance - rightInstance; Assert.AreEqual(expected, actual); }
public void Ensure_that_you_can_build_a_house_in_the_yard() { Yard yard = new Yard(); House house = yard.BuildHouse(); Assert.IsNotNull(house); Assert.AreNotEqual(default(Guid), house.ObjectId); Assert.AreSame(house, yard.House); Assert.IsTrue(yard.Contents.Any(x => x.ObjectId == house.ObjectId)); Assert.AreSame(yard, house.Yard); Assert.AreSame(yard, house.ParentContainerObject); }
public void TestGetYardSize() { // Arrange Yard yard = new Yard(50, 50); // Act double result = yard.GetYardSize(); // Assert Assert.AreEqual(2500d, result); }
public void Ensure_that_only_one_house_may_exist_in_the_yard() { Yard yard = new Yard(); yard.BuildHouse(); yard.BuildHouse(); }
public void SetUp() { _testAvatar = new Avatar(); _testWorld = new WideWorld(); _testYard = _testWorld.DrawResidentialPlot(); _testHouse = _testYard.BuildHouse(); _testDog = _testWorld.FindRandomDog(); }