public ActionResult AddCar() { var c = new Car(); c.Make = "Honda"; c.Model = "Jazz"; c.Color = "White"; var r = new Random(); var odo = 1000; for (int i = 0; i < r.Next(3, 10); i++) { var isForgot = r.Next(100) < 5; // 5% forgot brain level. var liters = r.Next(300, 800) / 10.0; //30.0-80.0 float c.AddFillUp(odo, liters, isFull: true, isForgot: isForgot); odo += r.Next(300, 800); } //s.Add(c); app.Cars.Add(c); app.Cars.SaveChanges(); return RedirectToAction("Index"); }
public void SingleFillUp_IsNull() { var c = new Car(); var f1 = c.AddFillUp(1000, 50.0, true); Assert.Null(c.AvergeKiloMetersPerLiter); }
public void NewFillUp_UsesCurrentDateTime() { var c = new Car(); var dt = DateTime.Now; SystemTime.SetDateTime(dt); var f = c.AddFillUp(1000, 50.0); Assert.Equal(dt, SystemTime.Now()); }
public void ThreeFillUps() { var c = new Car(); FillUp f1 = c.AddFillUp(odometer: 1000,liters: 50.0,isFull: true); FillUp f2 = c.AddFillUp(odometer: 1600,liters: 60.0,isFull: true); FillUp f3 = c.AddFillUp(odometer: 2000,liters: 50.0,isFull: true); var kml = c.AverageKilometersPerListes; Assert.Equal(9.1,kml); }
public void CanAddNewFillUp() { var c = new Car(); FillUp f = c.AddFillUp(odometer: 1000,liters: 50.0,isFull: true); Assert.Equal(1,c.FillUps.Count()); Assert.Equal(1000,f.Odometer); Assert.Equal(50.0,f.Liters); Assert.True(f.IsFull); }
public void AddTwoFillUps() { var c = new Car(); FillUp f1 = c.AddFillUp(odometer: 1000, liters: 50.0, isFull: true); FillUp f2 = c.AddFillUp(odometer: 2000, liters: 50.0, isFull: true); Assert.Equal(2, c.FillUps.Count()); Assert.Equal(f1.NextFillUp, f2); Assert.Equal(f1, f2.PreviousFillUp); }
public void CanAddTwoFillUp() { var c = new Car(); var f1 = c.AddFillUp(odometer: 1000, liters: 50.0, isFull: true); var f2 = c.AddFillUp(odometer: 1500, liters: 50.0, isFull: true); Assert.Equal(2, c.FillUps.Count); Assert.Same(f1.NextFillUp, f2); Assert.Same(f1, f2.PreviousFillUp); }
public void CanAddTreeFillUp() { var c = new Car(); FillUp f1 = c.AddFillUp(odometer: 1000, liters: 50.5, isFull: true); FillUp f2 = c.AddFillUp(odometer: 1000, liters: 50.5, isFull: true); FillUp f3 = c.AddFillUp(odometer: 1000, liters: 50.5, isFull: true); Assert.Equal(3, c.FillUps.Count()); Assert.Same(f2, f1.NextFillUp); Assert.Same(f3, f2.NextFillUp); }
public void CanAddTreeFillUp() { var c = new Car(); var f1 = c.AddFillUp(odometer: 1000, liters: 50.0, isFull: true); var f2 = c.AddFillUp(odometer: 1600, liters: 60.0, isFull: true); var f3 = c.AddFillUp(odometer: 2000, liters: 50.0, isFull: true); Assert.Equal(3, c.FillUps.Count); Assert.Same(f1.NextFillUp, f2); Assert.Same(f2.NextFillUp, f3); }
public void InvalidMake_AddFailed() { using (var app = new App(testing: true)) { var c = new Car(); c.Make = "Google"; // valid make Assert.ThrowsAny<Exception>(() => { app.Cars.Add(c); }); } }
public void ValidMake_AddOk() { using(var app = new App(testing: true)) { var c = new Car(); c.Make = "Honda"; // valid make app.Cars.Add(c); app.Cars.SaveChanges(); var n = app.Cars.All().Count(); Assert.Equal(1,n); } }
public void oneBlock() { var c = new Car(); FillUp f1 = c.AddFillUp(1000, 50, true, false); FillUp f2 = c.AddFillUp(1600, 60, true, true); FillUp f3 = c.AddFillUp(2000, 50, true, false); c.AddFillUp(2600, 60, true); var kml = c.get_AveragekilomaterPerLister; Assert.Equal(9.1, kml); }
public void OneBlock() { var c = new Car(); c.AddFillUp(1000,50,true,isForgot: false); c.AddFillUp(1600,60,true,isForgot: true); c.AddFillUp(2000,50,true); c.AddFillUp(2600,60,true); c.AddFillUp(3500,50,true,true); var kml = c.AverageKilometersPerListes; Assert.Equal(9.1,kml); }
public void CanAvgKmPerLiter() { var c = new Car(); // add f1 FillUp f1 = c.AddFillUp(odometer: 1000, liters: 50.0, isFull: true); // add f2 FillUp f2 = c.AddFillUp(odometer: 1600, liters: 60.0, isFull: true); // add f3 FillUp f3 = c.AddFillUp(odometer: 2000, liters: 50.0, isFull: true); double? kml = c.AverageKilometersPerListes; Assert.Equal(9.1, kml); }
public void AddTwoFillUps() { var c = new Car(); // add f1 FillUp f1 = c.AddFillUp(odometer: 500, liters: 50.0, isFull: true); // add f2 FillUp f2 = c.AddFillUp(odometer: 1000, liters: 20.0, isFull: true); //Assert that c has 2 file ups. Assert.Equal(2, c.FillUps.Count()); //Assert that f1.NextFillUp is f2 -> use .same Assert.Same(f2, f1.NextFillUp); Assert.Same(f1, f2.PreviousFillUp); }
public void twoBlock() { var c = new Car(); c.AddFillUp(1000, 50); c.AddFillUp(1600, 60); c.AddFillUp(2000, 50); c.AddFillUp(4000, 50, isForgot: true); c.AddFillUp(4600, 50); c.AddFillUp(5000, 50); var kml = c.get_AveragekilomaterPerLister; Assert.Equal(9.6, kml); }
public void TwoBlock() { var c = new Car(); c.AddFillUp(1000,50); c.AddFillUp(1600,60); c.AddFillUp(2000,50); c.AddFillUp(4000,50,isForgot: true); c.AddFillUp(4600,50); c.AddFillUp(5000,50); var kml = c.AverageKilometersPerListes; Assert.Equal(9.6,kml); }
public void AddTwoFillUps() { // add f1 // add f2 var c = new Car(); FillUp f1 = c.AddFillUp(odometer: 1000,liters: 50.0,isFull: true); FillUp f2 = c.AddFillUp(odometer: 1600,liters: 60.0,isFull: true); FillUp f3 = c.AddFillUp(odometer: 2000,liters: 50.0,isFull: true); // assert that c has 2 fill ups // assert that f1.NextFillUp is f2 Assert.Equal(3,c.FillUps.Count()); Assert.Same(f2,f1.NextFillUp); Assert.Same(f3,f2.NextFillUp); Assert.Same(f1,f2.PreviousFillUp); Assert.Same(f2,f3.PreviousFillUp); }
public void AddThreeFillUps() { var c = new Car(); // add f1 FillUp f1 = c.AddFillUp(odometer: 500, liters: 50.0, isFull: true); // add f2 FillUp f2 = c.AddFillUp(odometer: 1000, liters: 20.0, isFull: true); // add f3 FillUp f3 = c.AddFillUp(odometer: 800, liters: 30.0, isFull: true); //Assert that c has 3 file ups. Assert.Equal(3, c.FillUps.Count()); //Assert that f1.NextFillUp is f2 -> use .Same Assert.Same(f1.NextFillUp, f2); //Assert that f2.NextFillUp is f3 -> use .Same Assert.Same(f2.NextFillUp, f3); }
public ActionResult AddCar() { var c = new Car(); c.Make = "Toyota"; c.Model = "Camry"; c.Color = "White"; var r = new Random(); var odometer = 100; for (int i = 0; i < r.Next(3, 10+1); i++) { var isForgot = r.Next(100) < 5; // 5% forgot brain level. var liters = r.Next(300, 800) / 10.0; c.AddFillUp(odometer, liters, isFull: true, isForgot: isForgot); odometer += r.Next(300, 800); } s.Add(c); return RedirectToAction("Index"); }
public void AddThreeFillUps() { var c = new Car(); FillUp f1 = c.AddFillUp(odometer: 1000, liters: 50.0, isFull: true); FillUp f2 = c.AddFillUp(odometer: 1500, liters: 40.0, isFull: true); FillUp f3 = c.AddFillUp(odometer: 2100, liters: 56.0, isFull: true); Assert.Equal(3, c.FillUps.Count()); Assert.Same(f2, f1.NextFillUp); Assert.Same(f3, f2.NextFillUp); Assert.Same(f1, f2.PreviousFillUp); }
public void NoFillUp_IsNull() { var c = new Car(); Assert.Null(c.AvergeKiloMetersPerLiter); }
public void TwoFillUp_IsNull() { var c = new Car(); FillUp f1 = c.AddFillUp(odometer: 1000,liters: 50.0,isFull: true); FillUp f2 = c.AddFillUp(odometer: 1600,liters: 60.0,isFull: true); Assert.Equal(10,c.AverageKilometersPerListes); }
public void NewCar_HasCorrectInitialValues() { Car c = new Car(); c.Make = "Honda"; c.Model = "Accord"; Assert.Equal("Honda", c.Make); Assert.Equal("Accord", c.Model); Assert.Equal(0, c.FillUps.Count()); }
public void TwoFillUps() { var c = new Car(); var f1 = c.AddFillUp(odometer: 1000, liters: 50.0, isFull: true); var f2 = c.AddFillUp(odometer: 1600, liters: 60.0, isFull: true); Assert.Equal(10, c.AvergeKiloMetersPerLiter); }
public void NoFillUp_IsNull() { var c = new Car(); Assert.Null(c.AverageKilometersPerListes); }
public void OneBlock() { var c = new Car(); c.AddFillUp(odometer: 1000, liters: 50.0, isFull: true); c.AddFillUp(odometer: 1600, liters: 60.0, isFull: true, isForgot: true); c.AddFillUp(odometer: 2000, liters: 50.0, isFull: true); c.AddFillUp(odometer: 2600, liters: 60.0, isFull: true); c.AddFillUp(odometer: 3500, liters: 50.0, isFull: true, isForgot: true); double? kml = c.AverageKilometersPerListes; Assert.Equal(9.1, kml); }
public void SingleFillUp_IsNull() { var c = new Car(); FillUp f1 = c.AddFillUp(odometer: 1000, liters: 50.0, isFull: true); Assert.Null(c.AverageKilometersPerListes); }
public Car Add(Car item) { var c = repo.Add(item); repo.SaveChanges(); return c; }
public void NoFillUp_Isnull() { var c = new Car(); Assert.Null(c.get_AveragekilomaterPerLister); }