示例#1
0
        public virtual int _GetUniqueIdentifier()
        {
            var hashCode = 399326290;

            hashCode = hashCode * -1521134295 + (Id?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (LicensePlate?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (ContainerId?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (ShipId?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (TrainId?.GetHashCode() ?? 0);
            return(hashCode);
        }
示例#2
0
        public void RandomChars_GenerateRandomSetsOfNums()
        {
            // Arrange
            LicensePlate licencePlateOne = new LicensePlate();
            // Act
            string numsOne = licencePlateOne.RandomNums();
            string numsTwo = licencePlateOne.RandomNums();

            // Assert
            Assert.NotEqual(numsOne, numsTwo);
        }
示例#3
0
        public void RandomNums_GenerateRandomNum()
        {
            // Arrange
            LicensePlate licencePlateOne = new LicensePlate();
            // Act
            string nums         = licencePlateOne.RandomNums();
            char   firstNumber  = nums[0];
            char   secondNumber = nums[1];

            // Assert
            Assert.NotEqual(firstNumber, secondNumber);
        }
示例#4
0
        public void RamdomChars_GenerateRandomChar()
        {
            // Arrange
            LicensePlate licencePlateOne = new LicensePlate();
            // Act
            string chars        = licencePlateOne.RandomChars();
            char   firstLetter  = chars[0];
            char   secondLetter = chars[1];

            // Assert
            Assert.NotEqual(firstLetter, secondLetter);
        }
示例#5
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (Name != null ? Name.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Surname != null ? Surname.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (LicensePlate != null ? LicensePlate.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Phone != null ? Phone.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Apartaments != null ? Apartaments.GetHashCode() : 0);
         return(hashCode);
     }
 }
示例#6
0
        public void GenerateLicensePlate_GenerateALicensePlate()
        {
            // Arrange
            LicensePlate licencePlateOne = new LicensePlate();
            int          expected        = 7;

            // Act
            licencePlateOne = licencePlateOne.GenerateLicensePlate();
            int actual = licencePlateOne.LicenseNumber.Length;

            // Assert
            Assert.Equal(expected, actual);
        }
        public Person(string name, string mobilePhone, string phone, Address address, string email, LicensePlate licensePlate, int?membershipId = null)
        {
            Name = CheckName(name);

            CheckPhone(mobilePhone, phone);
            MobilePhone = mobilePhone;
            Phone       = phone;

            PersonAddress    = address;
            EmailAdress      = CheckEmail(email);
            LicensePlate     = licensePlate;
            MembershipId     = membershipId;
            RegistrationDate = DateTime.Now;
        }
示例#8
0
        public void GenerateLicensePlate_GenerateDifferentLicensePlates()
        {
            // Arrange
            List <LicensePlate> licensePlates = new List <LicensePlate>();

            // Act
            for (int i = 0; i < 10; i++)
            {
                LicensePlate licensePlate = new LicensePlate();
                licensePlates.Add(licensePlate.GenerateLicensePlate());
            }
            // Assert
            Assert.NotEqual(licensePlates[0].LicenseNumber, licensePlates[1].LicenseNumber);
        }
        public Person(int id, string name, string mobilePhone, string phone, Address personAddress, string emailAdress, LicensePlate licensePlate, int?membershipId = null, DateTime?registrationDate = null)
        {
            Id   = id;
            Name = CheckName(name);

            CheckPhone(mobilePhone, phone);
            MobilePhone = mobilePhone;
            Phone       = phone;

            PersonAddress    = personAddress;
            EmailAdress      = CheckEmail(emailAdress);
            LicensePlate     = licensePlate;
            MembershipId     = membershipId;
            RegistrationDate = CheckRegistrationDate(registrationDate);
        }
        public void NoExistingPlates_PostedPlate_ShouldBeMadePrimary()
        {
            _repoMock = NSubstitute.Substitute.For <IGenericRepository <LicensePlate> >();
            _repoMock.AsQueryable().ReturnsForAnyArgs(new List <LicensePlate>()
            {
            }.AsQueryable());
            uut = new LicensePlateService(_repoMock);
            var plate = new LicensePlate()
            {
                PersonId = 1
            };

            uut.HandlePost(plate);
            Assert.AreEqual(true, plate.IsPrimary);
        }
示例#11
0
        public void PredictPicoYPlaca_PassPlateWithPicoYPlacaOtherDay_ReturnsCorrectString(string plate)
        {
            //Arrange
            var licensePlate = new LicensePlate {
                LicensePlateNumber = plate
            };
            DateTime     date            = new DateTime(2019, 11, 06);
            TimeSpan     time            = new TimeSpan(5, 00, 0);
            const string expectedMessage = "Chill today is not your day.........of Pico y Placa";

            //Act
            var actualMessage = Predictor.PredictPicoYPlaca(licensePlate, date, time);

            //Assert
            Assert.AreEqual(expectedMessage, actualMessage);
        }
示例#12
0
        public void PredictPicoYPlaca_PassSpecialOrPublicPlate_ReturnsCorrectString(string plate)
        {
            //Arrange
            var licensePlate = new LicensePlate {
                LicensePlateNumber = plate
            };
            DateTime     date            = DateTime.Now;
            TimeSpan     time            = DateTime.Now.TimeOfDay;
            const string expectedMessage = "Relax you can circulate any day any time :)";

            //Act
            var actualMessage = Predictor.PredictPicoYPlaca(licensePlate, date, time);

            //Assert
            Assert.AreEqual(expectedMessage, actualMessage);
        }
示例#13
0
        public void PredictPicoYPlaca_PassPlateWithPicoYPlacaAfterNoonRestriction_ReturnsCorrectString(string plate)
        {
            //Arrange
            var licensePlate = new LicensePlate {
                LicensePlateNumber = plate
            };
            DateTime     date            = new DateTime(2019, 11, 07);
            TimeSpan     time            = new TimeSpan(18, 00, 0);
            const string expectedMessage = "PULL OVER NOW!!!!!!!!!";

            //Act
            var actualMessage = Predictor.PredictPicoYPlaca(licensePlate, date, time);

            //Assert
            Assert.AreEqual(expectedMessage, actualMessage);
        }
示例#14
0
        public void PredictPicoYPlaca_PassPlateWithPicoYPlacaNotRestricted_ReturnsCorrectString(string plate)
        {
            //Arrange
            var licensePlate = new LicensePlate {
                LicensePlateNumber = plate
            };
            DateTime     date            = new DateTime(2019, 11, 06);
            TimeSpan     time            = new TimeSpan(5, 00, 0);
            const string expectedMessage = "You can circulate, FOR NOW!!!";

            //Act
            var actualMessage = Predictor.PredictPicoYPlaca(licensePlate, date, time);

            //Assert
            Assert.AreEqual(expectedMessage, actualMessage);
        }
示例#15
0
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (LicensePlate != null)
         {
             hashCode = hashCode * 59 + LicensePlate.GetHashCode();
         }
         if (Engine != null)
         {
             hashCode = hashCode * 59 + Engine.GetHashCode();
         }
         if (Body != null)
         {
             hashCode = hashCode * 59 + Body.GetHashCode();
         }
         if (LowVoltage != null)
         {
             hashCode = hashCode * 59 + LowVoltage.GetHashCode();
         }
         if (Lighting != null)
         {
             hashCode = hashCode * 59 + Lighting.GetHashCode();
         }
         if (Brakes != null)
         {
             hashCode = hashCode * 59 + Brakes.GetHashCode();
         }
         if (Sensors != null)
         {
             hashCode = hashCode * 59 + Sensors.GetHashCode();
         }
         if (Miscellaneous != null)
         {
             hashCode = hashCode * 59 + Miscellaneous.GetHashCode();
         }
         if (Conditioning != null)
         {
             hashCode = hashCode * 59 + Conditioning.GetHashCode();
         }
         return(hashCode);
     }
 }
示例#16
0
        public override bool Equals(object compared)
        {
            if ((compared == null) || !this.GetType().Equals(compared.GetType()))
            {
                return(false);
            }

            LicensePlate lp = (LicensePlate)compared;

            if (!this.liNumber.Equals(lp.liNumber))
            {
                return(false);
            }
            if (!this.country.Equals(lp.country))
            {
                return(false);
            }
            return(true);
        }
示例#17
0
        static void Main(string[] args)
        {
            bool exit = false;

            do
            {
                Console.Clear();
                Console.WriteLine("******Pico & Placa Predictor******");

                string licensePlate = GetLicensePlate();
                while (!InputValidator.IsLicensePlateValid(licensePlate))
                {
                    Console.WriteLine("Wrong license plate Format!");
                    licensePlate = GetLicensePlate();
                }

                string   date = GetDate();
                DateTime convertedDate;
                while (!InputValidator.StringToDateOrTime(date, true, out convertedDate))
                {
                    Console.WriteLine("Wrong date format!");
                    date = GetDate();
                }

                string   time = GetTime();
                DateTime convertedTime;
                while (!InputValidator.StringToDateOrTime(time, false, out convertedTime))
                {
                    Console.WriteLine("Wrong time format!");
                    time = GetTime();
                }
                Console.Clear();
                //Create the model for the License
                var licenseModel = new LicensePlate {
                    LicensePlateNumber = licensePlate
                };
                //Get and display the message from the predictor
                Console.WriteLine(Predictor.PredictPicoYPlaca(licenseModel, convertedDate, convertedTime.TimeOfDay));
                Console.Write("Exit? (Y/N): ");
                exit = Console.ReadLine().ToLower() == "y";
            } while (!exit);
        }