public void GetAllDriversInCarsShouldReturnCollection()
        {
            MockRepository      repo = new MockRepository();
            ITaxiDataRepository sut  = repo.StrictMock <Linq2SqlTaxiDataRepository>();

            int         id  = 1;
            DriverInCar dIC = new DriverInCar(id);

            dIC.CarId    = 3;
            dIC.DriverId = 3;
            dIC.Address  = "Akademika Glushkova 12A";
            dIC.Location = "50.374211, 30.462582";

            List <DriverInCar> driversInCars = new List <DriverInCar>()
            {
                dIC
            };

            Expect.Call(sut.GetAllDriversInCars()).Return(driversInCars).Repeat.Times(3);
            repo.ReplayAll();
            Assert.NotNull(sut.GetAllDriversInCars());
            Assert.NotEmpty(sut.GetAllDriversInCars());
            Assert.IsType <List <DriverInCar> >(sut.GetAllDriversInCars());
            repo.VerifyAll();
        }
Ejemplo n.º 2
0
        public DriverInCarModel Create(DriverInCar dIC)
        {
            if (dIC == null)
            {
                return(null);
            }

            return(new DriverInCarModel(dIC));
        }
Ejemplo n.º 3
0
 public DriverInCarModel(DriverInCar d)
 {
     if (!Assert.IsNull(d))
     {
         Id       = d.Id;
         CarId    = d.CarId;
         DriverId = d.DriverId;
         Location = d.Location;
         Address  = d.Address;
         Car      = new CarModel(d.Car);
         Driver   = new DriverModel(d.Driver);
     }
 }
        public void GetDriverInCarShouldReturnNull()
        {
            MockRepository      repo = new MockRepository();
            ITaxiDataRepository sut  = repo.StrictMock <Linq2SqlTaxiDataRepository>();

            int         id  = 10;
            DriverInCar dIC = null;


            Expect.Call(sut.GetDriverInCar(id)).Return(dIC);
            repo.ReplayAll();
            Assert.Null(sut.GetDriverInCar(id));
            repo.VerifyAll();
        }
Ejemplo n.º 5
0
 public DriverInCarFixture()
 {
     dIC = new DriverInCar()
     {
         Address = "Peremogy, 50", CarId = 1, DriverId = 1, Location = "50.456487, 30.444342", Driver = new Driver()
         {
             FirstName = "Andrii", LastName = "Ivanov", HomeAddress = "Lugova, 12", PhoneNumber = "0661234567"
         }, Car = new Car()
         {
             Brand = "Lifan", Model = "620", Number = "AA2345CH"
         }
     };
     Sut = new DriverInCarModel(dIC);
 }
Ejemplo n.º 6
0
        public void EqualsShouldReturnTrue()
        {
            DriverInCar driverInCar1 = new DriverInCar()
            {
                Address = "Peremogy, 50", CarId = 1, DriverId = 1, Location = "50.456487, 30.444342"
            };
            DriverInCar driverInCar2 = new DriverInCar()
            {
                Address = "Peremogy, 50", CarId = 1, DriverId = 1, Location = "50.456487, 30.444342"
            };

            Assert.True(driverInCar1.Equals(driverInCar2));
            Assert.True(driverInCar2.Equals(driverInCar1));
            Assert.True(driverInCar1.Equals(driverInCar1));
            Assert.True(driverInCar2.Equals(driverInCar2));
        }
        public void ShouldAddDriverInCar(bool expected)
        {
            MockRepository      repo = new MockRepository();
            ITaxiDataRepository sut  = repo.StrictMock <Linq2SqlTaxiDataRepository>();

            int         id  = 1;
            DriverInCar dIC = new DriverInCar(id);

            dIC.CarId    = 3;
            dIC.DriverId = 3;
            dIC.Address  = "Akademika Glushkova 12A";
            dIC.Location = "50.374211, 30.462582";

            Expect.Call(sut.AddDriverInCar(dIC)).Return(expected);
            repo.ReplayAll();
            Assert.Equal(expected, sut.AddDriverInCar(dIC));
            repo.VerifyAll();
        }
Ejemplo n.º 8
0
        public virtual bool AddDriverInCar(DriverInCar driverInCar)
        {
            if (Assert.IsNullOrEmtpyOrWhitespace(_connectionString) || Assert.IsNull(driverInCar))
            {
                return(false);
            }

            using (TaxiDataBaseContext taxiDataBaseContext = new TaxiDataBaseContext(new SqlConnection(_connectionString)))
            {
                try
                {
                    taxiDataBaseContext.DriversInCars.InsertOnSubmit(driverInCar);
                    taxiDataBaseContext.SubmitChanges();
                    return(true);
                }
                catch (Exception exc)
                {
                    Logger.Error(exc);
                    return(false);
                }
            }
        }
Ejemplo n.º 9
0
        public virtual DriverInCar GetDriverInCar(int id)
        {
            if (Assert.IsNullOrEmtpyOrWhitespace(_connectionString) || !Assert.IsPositive(id))
            {
                return(null);
            }

            using (TaxiDataBaseContext taxiDataBaseContext = new TaxiDataBaseContext(new SqlConnection(_connectionString)))
            {
                try
                {
                    DriverInCar driverInCar = taxiDataBaseContext.GetTable <DriverInCar>().First <DriverInCar>(d => d.Id == id);
                    driverInCar.Car    = GetCar(driverInCar.CarId);
                    driverInCar.Driver = GetDriver(driverInCar.DriverId);
                    return(driverInCar);
                }
                catch (Exception exc)
                {
                    Logger.Error(exc);
                    return(null);
                }
            }
        }
Ejemplo n.º 10
0
        public void EqualsShouldReturnFalse()
        {
            DriverInCar driverInCar1 = new DriverInCar()
            {
                Address = "Peremogy, 50", CarId = 1, DriverId = 1, Location = "50.456487, 30.444342"
            };
            DriverInCar driverInCar2 = new DriverInCar()
            {
                Address = "Peremogy, 51", CarId = 1, DriverId = 1, Location = "50.456487, 30.444342"
            };
            DriverInCar driverInCar3 = new DriverInCar()
            {
                Address = "Peremogy, 50", CarId = 2, DriverId = 1, Location = "50.456487, 30.444342"
            };
            DriverInCar driverInCar4 = new DriverInCar()
            {
                Address = "Peremogy, 50", CarId = 1, DriverId = 2, Location = "50.456488, 30.444342"
            };

            Assert.False(driverInCar1.Equals(driverInCar2));
            Assert.False(driverInCar1.Equals(driverInCar3));
            Assert.False(driverInCar1.Equals(driverInCar4));
        }
Ejemplo n.º 11
0
 public void Fill(NonRaceSession session, DriverInCar te)
 {
 }
Ejemplo n.º 12
0
 public void Update(DriverInCar e)
 {
 }
Ejemplo n.º 13
0
 public DriverInCarFixture()
 {
     Sut = new DriverInCar();
 }