Exemplo n.º 1
0
            public void InThreeFillUps_ButForgotInSecondFillUps()
            {
                var f1 = new FillUp();
                f1.Odometer = 1000;
                f1.Liters = 50.0;
                f1.IsFull = true;

                var f2 = new FillUp();
                f2.Odometer = 1600;
                f2.Liters = 40;
                f2.IsFull = true;
                f2.IsForgot = true; // Forgot fillup 2

                var f3 = new FillUp();
                f3.Odometer = 2000;
                f3.Liters = 50;
                f3.IsFull = true;

                f1.NextFillUp = f2;
                f2.NextFillUp = f3;

                var kml1 = f1.KilometersPerLiter;
                var kml2 = f2.KilometersPerLiter;
                var kml3 = f3.KilometersPerLiter;

                Assert.Null(kml1);
                Assert.Equal(8.0, kml2);
                Assert.Null(kml3);
            }
Exemplo n.º 2
0
            public void ForgotTreeFillUps_TheFirstIsNotKnown()
            {
                var f1 = new FillUp();
                f1.Odometer = 1000;
                f1.Liters = 50.0;
                f1.IsFull = true;

                var f2 = new FillUp();
                f2.Odometer = 1600;
                f2.Liters = 60;
                f2.IsFull = true;
                f2.IsForgot = true;

                f1.NextFillUp = f2;

                var f3 = new FillUp(2000, 50, true);
                f2.NextFillUp = f3;

                var kml1 = f1.KilometersPerLiter;
                var kml2 = f2.KilometersPerLiter;
                var kml3 = f3.KilometersPerLiter;

                Assert.Null(kml1);
                Assert.Equal(8,kml2);
                Assert.Null(kml3);
            }
Exemplo n.º 3
0
        public FillUp AddFillUpNoNextFillUp(int odometer, double liters)
        {
            FillUp f = new FillUp(odometer, liters);

            //this.FillUps.Add(f);
            FillUps.Add(f);
            return(f);
        }
Exemplo n.º 4
0
        public FillUp AddFillUp(int odometer, double liters)
        {
            FillUp f = new FillUp(odometer, liters);

            if (FillUps?.Count > 0)
            {
                FillUps.LastOrDefault().NextFillUp = f;
            }
            FillUps.Add(f);
            return(f);
        }
Exemplo n.º 5
0
            public void NewFillUp_HasCorrectInitialValues()
            {
                // Arrange, Act
                var f = new FillUp();

                double liters = f.Liters;

                Assert.Equal(0, f.Odometer);
                Assert.Equal(0.0, liters);
                Assert.True(f.IsFull);
            }
Exemplo n.º 6
0
        public FillUp AddFillUp(int odometer, double liters, bool isFull = true)
        {
            var fillUpItem = new FillUp(odometer, liters, isFull);

            if (FillUps.Count > 0)
            {
                FillUps.Last().NextFileUp = fillUpItem;
            }
            FillUps.Add(fillUpItem);
            return(fillUpItem);
        }
Exemplo n.º 7
0
            public void ThirdFillUps_TheSecondHasCorrectKmL()
            {
                var f2 = new FillUp(odometer: 1500, liters:40.0);
                var f3 = new FillUp(2250, 56, true);
                f2.NextFillUp = f3;

                var kml1 = f2.KilometersPerLiter;
                var kml2 = f3.KilometersPerLiter;

                Assert.NotNull(kml1);
                Assert.Equal(13.4, kml1);
                Assert.Null(kml2);
            }
            public void ForgotInSecondFillUps_TheFirstIsNotKnow()
            {
                var f1 = new FillUp { Odometer = 1000, Liters = 50.0, IsFull = true };
                var f2 = new FillUp { Odometer = 1500, Liters = 40.0, IsFull = true };

                f1.NextFillUp = f2;
                f2.IsForgot = true;

                var kml1 = f1.KilometersPerLiter;
                var kml2 = f2.KilometersPerLiter;

                Assert.Null(kml1);
                Assert.Null(kml2);
            }
Exemplo n.º 9
0
            public void FirstFillUp_DontKnowKmL()
            {
                // Arrange
                var f = new FillUp();
                f.Odometer = 1000;
                f.Liters = 50;
                f.IsFull = true;

                // Act
                double? kml = f.KilometersPerLiter;

                // Assert
                Assert.Null(kml);
            }
Exemplo n.º 10
0
        // Method

        public FillUp AddFillUp(int odometer, double liters)
        {
            FillUp f    = new FillUp(odometer, liters);
            FillUp last = FillUps.LastOrDefault();

            if (last != null)
            {
                last.NextFillUp = f;
            }

            FillUps.Add(f);

            return(f);
        }
Exemplo n.º 11
0
        public FillUp AddFillUp(int odoMeter, double liters)
        {
            FillUp f = new FillUp(odoMeter, liters);

            //var prevFillUp = FillUps.LastOrDefault();
            var prevFillUp = FillUps.Where(x => x.NextFillUp == null).FirstOrDefault();

            if (prevFillUp != null)
            {
                prevFillUp.NextFillUp = f;
            }

            FillUps.Add(f);

            return(f);
        }
Exemplo n.º 12
0
        public FillUp AddFillUp(int odometer, double liters)
        {
            var f = new FillUp()
            {
                Odometer = odometer,
                Liters   = liters
            };

            if (FillUps.Any())
            {
                FillUps.OrderBy(x => x.Odometer).Last().NextFillUp = f;
            }

            FillUps.Add(f);
            return(f);
        }
Exemplo n.º 13
0
            public void InThreeFillUps_ButForgotInsecondFillUps()
            {
                var f1 = new FillUp { Odometer = 1000, Liters = 50.0, IsFull = true };
                var f2 = new FillUp { Odometer = 1600, Liters = 60.0, IsFull = true, IsForgot = true };
                var f3 = new FillUp { Odometer = 2000, Liters = 50.0, IsFull = true };

                f1.NextFillUp = f2;
                f2.NextFillUp = f3;

                var kml1 = f1.KilometersPerLiter;
                var kml2 = f2.KilometersPerLiter;
                var kml3 = f3.KilometersPerLiter;

                Assert.Null(kml1);
                Assert.Equal(8.0, kml2);
                Assert.Null(kml3);
            }
Exemplo n.º 14
0
        public FillUp AddFillUp(int odometer, double liters, bool isFull = true)
        {
            var f = new FillUp();

            f.Odometer   = odometer;
            f.Liters     = liters;
            f.IsFull     = isFull;
            f.NextFillUp = null;

            if (FillUps.Count > 0)
            {
                FillUps.Last().NextFillUp = f;
            }

            FillUps.Add(f);
            return(f);
        }
Exemplo n.º 15
0
        public FillUp AddFillUp(int odometer, double liters, bool isFull = true)
        {
            FillUp f = new FillUp(odometer, liters, isFull);

            if (FillUps.Count > 0)
            {
                FillUps.LastOrDefault().NextFillUp = f;
            }
            if (FillUps.Count == 0 || (FillUps.Count > 0 && FillUps.LastOrDefault().Odometer < f.Odometer))
            {
                FillUps.Add(f);
            }
            else
            {
                throw new InvalidOperationException();
            }

            return(f);
        }
Exemplo n.º 16
0
        public FillUp AddFillUp(int odometer, double liters)
        {
            var f = new FillUp()
            {
                Odometer = odometer,
                Liters   = liters
            };

            //if (FillUps.Count > 0) {
            //    FillUps[FillUps.Count - 1].NextFillUp = f;
            //}
            if (FillUps.Any <FillUp>())
            {
                FillUps.OrderBy(x => x.Odometer).Last().NextFillUp = f;
            }

            FillUps.Add(f);

            return(f);
        }
Exemplo n.º 17
0
        public FillUp AddFillUp(int odometer, double liters, bool forgot = false)
        {
            FillUp f1 = new FillUp();

            f1.Odometer      = odometer;
            f1.Liters        = liters;
            f1.ForgotPrevios = forgot;

            //if (FillUps.Count > 0)
            if (FillUps.Any())
            {
                // FillUp f0 =
                //FillUps[FillUps.Count-1].NextFillUp = f1;
                FillUps.Last().NextFillUp = f1;
            }

            FillUps.Add(f1);
            return(f1);
            // throw new NotImplementedException();
        }
Exemplo n.º 18
0
        public FillUp AddFillUp(int odometer, double lister)
        {
            if (odometer <= 0)
            {
                throw new Exception();
            }
            if (lister <= 0)
            {
                throw new Exception();
            }
            var fillUp = new FillUp(odometer, lister);

            if (FillUps.Count > 0)
            {
                var last = FillUps.Last();
                last.Next = fillUp;
            }

            FillUps.Add(fillUp);
            return(fillUp);
        }
Exemplo n.º 19
0
            public void SecondFillUps_TheFirstHasCorrectKmL()
            {
                var f1 = new FillUp();
                f1.Odometer = 1000;
                f1.Liters = 50.0;
                f1.IsFull = true;

                var f2 = new FillUp();
                f2.Odometer = 1500;
                f2.Liters = 40;
                f2.IsFull = true;

                f1.NextFillUp = f2;

                var kml1 = f1.KilometersPerLiter;
                var kml2 = f2.KilometersPerLiter;

                Assert.NotNull(kml1);
                Assert.Equal(12.5, kml1);
                Assert.Null(kml2);
            }
Exemplo n.º 20
0
            public void ForgotInSecondFillUps_TheFirstIsNotKnown()
            {
                var f1 = new FillUp();
                f1.Odometer = 1000;
                f1.Liters = 50.0;
                f1.IsFull = true;

                var f2 = new FillUp();
                f2.Odometer = 1500;
                f2.Liters = 40;
                f2.IsFull = true;

                f1.NextFillUp = f2;

                f2.IsForgot = true; // Forgot fillup 2

                var kml1 = f1.KilometersPerLiter;
                var kml2 = f2.KilometersPerLiter;

                Assert.Null(kml1);
                Assert.Null(kml2);
            }
Exemplo n.º 21
0
        public FillUp AddFillUp(int odometer, double liters, bool isFull = true, bool isForgot = false)
        {
            //throw new NotImplementedException();
            var f = new FillUp();
            f.Odometer = odometer;
            f.Liters = liters;
            f.IsFull = isFull;
            f.IsForgot = isForgot;

            var prev = this.FillUps.LastOrDefault();
            if (prev != null)
            {
                prev.NextFillUp = f;
                f.PreviousFillUp = prev;
            }

            this.FillUps.Add(f);

            return f;
        }
Exemplo n.º 22
0
        public FillUp AddFillUp(int odometer,
                            double liters,

                            bool isFull = true,
                            bool isForgot = false)
        {
            var f = new FillUp();
              f.Odometer = odometer;
              f.Liters = liters;
              f.IsFull = isFull;
              f.IsForgot = isForgot;

              if (this.FillUps.Count > 0)
              {
            this.FillUps.Last().NextFillUp = f;
            f.PreviousFillUp = this.FillUps.Last();

              }

              this.FillUps.Add(f);

              return f;
        }
Exemplo n.º 23
0
        public FillUp AddFillUp(int odometer, double liters, bool isFull = true, bool isForgot = false)
        {
            var thisFillUp = new FillUp();

            thisFillUp.Odometer = odometer;
            thisFillUp.Liters = liters;
            thisFillUp.IsFull = isFull;
            thisFillUp.IsForgot = isForgot;
            thisFillUp.Date = SystemTime.Now();

            var previousFillUp = this.FillUps.LastOrDefault();
            if (previousFillUp != null) {
                previousFillUp.NextFillUp = thisFillUp;
                thisFillUp.PreviousFillUp = previousFillUp;
            }

            this.FillUps.Add(thisFillUp);

            return thisFillUp;
        }
Exemplo n.º 24
0
        public FillUp AddFillUp(int odometer, double liters, bool isFull = true, bool isForgot = false)
        {
            var fillUp = new FillUp
            {
                Odometer = odometer,
                Liters = liters,
                IsFull = isFull,
                IsForgot = isForgot
            };

            if (FillUps.Count > 0)
            {
                fillUp.PreviousFillUp = this.FillUps.Last();
                this.FillUps.Last().NextFillUp = fillUp;
            }

            FillUps.Add(fillUp);

            return fillUp;
        }