public static List <string> GetChapterAddresses(Mile mile, WMMCRC db) { List <string> fromToAddressList = new List <string>(); var FromChapterAddress = (from a in db.ChapterAddresses where a.ChapterId == mile.FromId select string.Concat(a.StreetAddress1, " ", a.StreetAddress2, " ", a.City, " ", (from b in db.States where b.Id == a.StateId select b.Name).FirstOrDefault(), " ", a.Zip )).FirstOrDefault(); fromToAddressList.Add(FromChapterAddress); var ToChapterAddress = (from c in db.ChapterAddresses where c.ChapterId == mile.ToId select string.Concat(c.StreetAddress1, " ", c.StreetAddress2, " ", c.City, " ", (from d in db.States where d.Id == c.StateId select d.Name).FirstOrDefault(), " ", c.Zip )).FirstOrDefault(); fromToAddressList.Add(ToChapterAddress); return(fromToAddressList); }
public void Should_initialize_instance(double value) { var actual = new Mile(value); Assert.IsAssignableFrom <Mile>(actual); Assert.AreEqual(value, actual.Value, nameof(actual.Value)); }
private void BtnMileKm_Click(object sender, EventArgs e) { int Mile; double Km = 1.61; while (true) { Mile = int.Parse(Microsoft.VisualBasic.Interaction.InputBox("Introduce your mileage", "Mile to km conversor", "")); if (Mile < 0) { TxtAnswers.Text = "Please enter a positive number"; } else { double FinalKm = Mile * Km; MessageBox.Show(Mile.ToString() + " miles are " + FinalKm.ToString("n2") + " Kms"); } string response = Microsoft.VisualBasic.Interaction.InputBox("Do you want to keep converting miles to kms, y/n", "", ""); if (response == "n" || response == "no" || response == "cancelar") { break; } } }
public async Task <IActionResult> Edit(int id, Mile mile) { if (id != mile.Id) { return(NotFound()); } if (ModelState.IsValid) { try { //_context.Update(mile); //await _context.SaveChangesAsync(); await _mileRepository.UpdateAsync(mile); } catch (DbUpdateConcurrencyException) { if (!await MileExistsAsync(mile.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(mile)); }
public void Should_compare_with_null_instance(double value) { var instance = new Mile(value); Assert.IsFalse(instance.Equals(null), "Equals"); Assert.AreEqual(1, instance.CompareTo(null), "CompareTo"); }
public void Should_not_throw_exception_on_division_by_zero(double value, double expectedValue) { var instance = new Mile(value); var actual = instance / 0d; Assert.AreEqual(expectedValue, actual.Value); }
async Task CreditMilesToClient(Client client, int miles, TicketResponse ticket) { var bonusMiles = new Mile { ClientId = client.Id, MilesTypeId = 2, Miles = miles, Balance = miles, CreditDate = DateTime.UtcNow, ExpiryDate = DateTime.UtcNow.AddYears(3), Description = $"Miles from flight that landed on {DateTime.UtcNow.AddDays(-1):yyyy-MM-dd}" }; var statusMiles = new Mile { ClientId = client.Id, MilesTypeId = 1, Miles = miles, Balance = miles, CreditDate = DateTime.UtcNow, ExpiryDate = DateTime.UtcNow.AddYears(3), Description = $"Status from flight that landed on {DateTime.UtcNow.AddDays(-1):yyyy-MM-dd}" }; await _mileRepository.CreateAsync(bonusMiles); await _mileRepository.CreateAsync(statusMiles); }
//Returns reference to unit t be created private Unit createUnit(string originalUnit) { Unit unit; switch (originalUnit) { case "cm": unit = new Centimeter(); break; case "ft": unit = new Foot(); break; case "in": unit = new Inch(); break; case "km": unit = new Kilometer(); break; case "m": unit = new Meter(); break; case "mile": unit = new Mile(); break; default: throw new InvalidEnumArgumentException(); } return(unit); }
public void Should_cast_from_double(double value) { var expected = new Mile(value); var actual = (Mile)value; Assert.AreEqual(expected, actual); }
public void Should_compare_with_another_type_of_instance(double value) { var instance1 = new Mile(value); object instance2 = value; Assert.IsFalse(instance1.Equals(instance2), "Equals"); Assert.Throws <ArgumentException>(() => instance1.CompareTo(instance2), "CompareTo"); }
public void Should_cast_to_double(double value) { var instance = new Mile(value); var actual = (double)instance; Assert.AreEqual(value, actual); }
public void Should_convert_to_kilometres(double miles, double expected) { var instance = new Mile(miles); Kilometre actual = instance; Assert.AreEqual(expected, actual.Value, Consts.DeltaAssert); }
public void Should_convert_from_kilometres(double expected, double kilometres) { var instance = new Kilometre(kilometres); Mile actual = instance; Assert.AreEqual(expected, actual.Value, Consts.DeltaAssert); }
public void Should_floor_value(double value, double expectedValue) { var expected = new Mile(expectedValue); var instance = new Mile(value); var actual = instance.Floor(); Assert.AreEqual(expected, actual); }
public void Should_divide_instance_by_double(double leftValue, double rightValue, double expectedValue) { var expected = new Mile(expectedValue); var instance = new Mile(leftValue); var actual = instance / rightValue; 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 Mile(1.757899e2); var actual = instance.ToString(format, Consts.CultureEnUS); Assert.AreEqual(expected, actual); }
public void Should_own_a_HashCode(double value) { var expected = value.GetHashCode(); var instance = new Mile(value); var actual = instance.GetHashCode(); Assert.AreEqual(expected, actual); }
public void Should_absolute_value(double value, double expectedValue) { var expected = new Mile(expectedValue); var instance = new Mile(value); var actual = instance.Abs(); Assert.AreEqual(expected, actual); }
public void Should_roundvalue_withMode(MidpointRounding mode, double value, double expectedValue) { var expected = new Mile(expectedValue); var instance = new Mile(value); var actual = instance.Round(mode); Assert.AreEqual(expected, actual); }
public void Should_round_value_withDigit(double value, double expectedValue) { var expected = new Mile(expectedValue); var instance = new Mile(value); var actual = instance.Round(1); Assert.AreEqual(expected, actual); }
public void Should_convert_to_string(double value) { var expected = $"{value:e} mi"; var instance = new Mile(value); var actual = instance.ToString(); Assert.AreEqual(expected, actual); }
public void Should_multiply_double_by_instance(double leftValue, double rightValue, double expectedValue) { var expected = new Mile(expectedValue); var instance = new Mile(rightValue); var actual = leftValue * instance; Assert.AreEqual(expected, actual); }
public static void GetChapterNames(Mile mile, WMMCRC database) { mile.ToName = (from s in database.Chapters where s.ChapterId == mile.ToId select s.ChapterName).FirstOrDefault(); mile.FromName = (from f in database.Chapters where f.ChapterId == mile.FromId select f.ChapterName).FirstOrDefault(); }
public void Should_subtract_two_instances(double leftValue, double rightValue, double expectedValue) { var expected = new Mile(expectedValue); var leftInstance = new Mile(leftValue); var rightInstance = new Mile(rightValue); var actual = leftInstance - rightInstance; Assert.AreEqual(expected, actual); }
public void MileConstructorTest() { Mile target = new Mile(); Assert.AreEqual("mil", target.Symbol); Assert.AreEqual(typeof(Length <>), target.QuantityType); Assert.AreEqual(true, target.IsBaseUnit); Assert.AreEqual(false, target.IsDefaultUnit); Assert.AreEqual(typeof(Yard), target.ReferenceUnit.GetType()); }
public void EqualityOfDifferentUnit() { Assert.AreNotEqual(Cup.S(4), Gallon.S(4)); Assert.AreEqual(Teaspoon.S(3), Tablespoon.S(1)); Assert.AreEqual(Ounce.S(16), Quart.S(0.5)); Assert.AreEqual(Gallon.S(3), Teaspoon.S(2304)); Assert.AreEqual(Foot.S(4.5), Yard.S(1.5)); Assert.AreEqual(Mile.S(2), Inch.Es(126720)); Assert.AreNotEqual(Inch.Es(1), Teaspoon.S(1)); Assert.AreNotEqual(Inch.Es(1), Celsius.S(1)); }
public void Should_cast_from_Yard(double yardValue, double expectedValue) { var yardInstance = new SystemOfUnits.Length.Imperial.Yard(yardValue); Mile actual = yardInstance; Assert.IsAssignableFrom <Mile>(actual); var actualValue = actual.Value; Assert.AreEqual(expectedValue, actualValue, Consts.DeltaAssert); }
public void PathFromUnitTest() { double expected = 63360; Mile mil = new Mile(); Inch i = new Inch(); UnitPathStack actual = i.PathFromUnit(mil); Assert.AreEqual(expected, actual.ConversionFactor); }
public Transaction ToTransaction(ExtendMilesViewModel model, Mile mile) { return(new Transaction { Description = "Extended", Value = mile.Qtd, TransactionDate = DateTime.Now, Price = 70, ClientID = mile.ClientId, IsAproved = true, IsCreditCard = true }); }
public Transaction ToTransaction(BuyMilesViewModel model, Mile mile) { return(new Transaction { Description = "Buy", Value = mile.Qtd, TransactionDate = DateTime.Now, Price = model.Price, ClientID = mile.ClientId, IsAproved = true, IsCreditCard = false }); }