Example #1
0
        public void JSONCustomerRepository_UpdateEnity_Test()
        {
            //Arrange
            var customerRepo = new JSONBaseRepository <Customer>(@"D:\Projects\OOP Principles\VehicleShowRoom\VehicleIndustry.Dal\JSONdatabase\Tests\customers_tests.json");

            var customers = customerRepo.GetAll().ToList();
            var toUpdate  = customers[0];

            //Act
            customerRepo.UpdateEntity(toUpdate.Id.ToString(), new Customer {
                Name = "Cristina Golban"
            });
            var  retrievedCustomers = customerRepo.GetAll().ToList();
            bool rez = false;

            for (int i = 0; i < customers.Count(); i++)
            {
                if (!customers[i].Equals(retrievedCustomers[i]))
                {
                    rez = true;
                    break;
                }
            }

            //Assert
            Assert.True(rez);
        }
        public void JSONVehicleRepository_UpdateEnity_Test()
        {
            //Arrange
            var vehicleRepo = new JSONBaseRepository <Vehicle>(@"D:\Projects\OOP Principles\VehicleShowRoom\VehicleIndustry.Dal\JSONdatabase\Tests\vehicles_tests.json");
            var vehicles    = vehicleRepo.GetAll().ToList();
            var toUpdate    = vehicles[0];

            //Act
            vehicleRepo.UpdateEntity(toUpdate.Id.ToString(), new Vehicle {
                Brand = "Lamborgini", Model = "1"
            });
            var  retrievedVehicles = vehicleRepo.GetAll().ToList();
            bool rez = false;

            for (int i = 0; i < vehicles.Count(); i++)
            {
                if (!vehicles[i].Equals(retrievedVehicles[i]))
                {
                    rez = true;
                    break;
                }
            }

            //Assert
            Assert.True(rez);
        }
        public void JSONEngineRepository_UpdateEnity_Test()
        {
            //Arrange
            var engineRepo = new JSONBaseRepository <Engine>(@"D:\Projects\OOP Principles\VehicleShowRoom\VehicleIndustry.Dal\JSONdatabase\Tests\engines_tests.json");

            var engines  = engineRepo.GetAll().ToList();
            var toUpdate = engines[0];

            //Act
            engineRepo.UpdateEntity(toUpdate.Id.ToString(), new Engine {
                HP = 931
            });
            var  retrievedEngine = engineRepo.GetAll().ToList();
            bool rez             = false;

            for (int i = 0; i < engines.Count(); i++)
            {
                if (!engines[i].Equals(retrievedEngine[i]))
                {
                    rez = true;
                    break;
                }
            }

            //Assert
            Assert.True(rez);
        }
Example #4
0
        public void JSONGearboxRepository_UpdateEnity_Test()
        {
            //Arrange
            var gearboxRepo = new JSONBaseRepository <GearBox>(@"D:\Projects\OOP Principles\VehicleShowRoom\VehicleIndustry.Dal\JSONdatabase\Tests\gearboxes_tests.json");

            var gearboxes = gearboxRepo.GetAll().ToList();
            var toUpdate  = gearboxes[0];

            //Act
            gearboxRepo.UpdateEntity(toUpdate.Id.ToString(), new GearBox {
                Type = Enums.GearBoxTypeEnum.Automatic
            });
            var  retrievedVehicles = gearboxRepo.GetAll().ToList();
            bool rez = false;

            for (int i = 0; i < gearboxes.Count(); i++)
            {
                if (!gearboxes[i].Equals(retrievedVehicles[i]))
                {
                    rez = true;
                    break;
                }
            }

            //Assert
            Assert.True(rez);
        }
Example #5
0
        public void JSONCustomerRepository_DeleteEntity_Test()
        {
            //Arrange
            var customerRepo = new JSONBaseRepository <Customer>(@"D:\Projects\OOP Principles\VehicleShowRoom\VehicleIndustry.Dal\JSONdatabase\Tests\customers_tests.json");
            var customers    = customerRepo.GetAll().ToList();
            var toDelete     = customers[0];

            //Act
            customerRepo.DeleteById(toDelete.Id.ToString());
            //Assert
            Assert.True(customerRepo.GetById(toDelete.Id.ToString()) == null);
        }
Example #6
0
        public void JSONGearboxRepository_DeleteEntity_Test()
        {
            //Arrange
            var gearboxRepo = new JSONBaseRepository <GearBox>(@"D:\Projects\OOP Principles\VehicleShowRoom\VehicleIndustry.Dal\JSONdatabase\Tests\gearboxes_tests.json");

            var gearboxes = gearboxRepo.GetAll().ToList();
            var toDelete  = gearboxes[0];

            //Act
            gearboxRepo.DeleteById(toDelete.Id.ToString());
            //Assert
            Assert.True(gearboxRepo.GetById(toDelete.Id.ToString()) == null);
        }
Example #7
0
        public void JSONCustomerRepository_GetById_Test()
        {
            //Arrange
            var customerRepo  = new JSONBaseRepository <Customer>(@"D:\Projects\OOP Principles\VehicleShowRoom\VehicleIndustry.Dal\JSONdatabase\Tests\customers_tests.json");
            var customerToAdd = new Customer {
            };

            customerRepo.AddEntity(customerToAdd);
            var customer = customerRepo.GetById(customerToAdd.Id.ToString());
            //Act
            var retrievedCustomer = customerRepo.GetById(customerToAdd.Id.ToString());

            //Assert
            Assert.True(customer.Equals(retrievedCustomer));
        }
        public void JSONEngineRepository_GetById_Test()
        {
            //Arrange
            var engineRepo  = new JSONBaseRepository <Engine>(@"D:\Projects\OOP Principles\VehicleShowRoom\VehicleIndustry.Dal\JSONdatabase\Tests\engines_tests.json");
            var engineToAdd = new Engine {
            };

            engineRepo.AddEntity(engineToAdd);
            var engine = engineRepo.GetById(engineToAdd.Id.ToString());
            //Act
            var retrievedEngine = engineRepo.GetById(engineToAdd.Id.ToString());

            //Assert
            Assert.True(engine.Equals(retrievedEngine));
        }
        public void JSONVehicleRepository_GetById_Test()
        {
            //Arrange
            var vehicleRepo  = new JSONBaseRepository <Vehicle>(@"D:\Projects\OOP Principles\VehicleShowRoom\VehicleIndustry.Dal\JSONdatabase\Tests\vehicles_tests.json");
            var vehicleToAdd = new Vehicle {
            };

            vehicleRepo.AddEntity(vehicleToAdd);
            var vehicle = vehicleRepo.GetById(vehicleToAdd.Id.ToString());
            //Act
            var retrievedVehicle = vehicleRepo.GetById(vehicleToAdd.Id.ToString());

            //Assert
            Assert.True(vehicle.Equals(retrievedVehicle));
        }
Example #10
0
        public void JSONCustomerRepository_Insert_Test()
        {
            //Arrange
            var customerRepo = new JSONBaseRepository <Customer>(@"D:\Projects\OOP Principles\VehicleShowRoom\VehicleIndustry.Dal\JSONdatabase\Tests\customers_tests.json");
            var customer     = new Customer {
                Name = "Cristina Golban"
            };

            //Act
            customerRepo.AddEntity(customer);

            //retrieve from db
            var retrievedCustomer = customerRepo.GetById(customer.Id.ToString());

            //Assert
            Assert.True(customer.Equals(retrievedCustomer));
        }
Example #11
0
        public void JSONGearboxRepository_GetById_Test()
        {
            //Arrange
            var gearboxRepo = new JSONBaseRepository <GearBox>(@"D:\Projects\OOP Principles\VehicleShowRoom\VehicleIndustry.Dal\JSONdatabase\Tests\gearboxes_tests.json");

            var gearboxToAdd = new GearBox {
                Type = Enums.GearBoxTypeEnum.Manual
            };

            gearboxRepo.AddEntity(gearboxToAdd);
            var engine = gearboxRepo.GetById(gearboxToAdd.Id.ToString());
            //Act
            var retrievedGearbox = gearboxRepo.GetById(gearboxToAdd.Id.ToString());

            //Assert
            Assert.True(engine.Equals(retrievedGearbox));
        }
Example #12
0
        public void JSONGearboxRepository_Insert_Test()
        {
            //Arrange
            var gearboxRepo = new JSONBaseRepository <GearBox>(@"D:\Projects\OOP Principles\VehicleShowRoom\VehicleIndustry.Dal\JSONdatabase\Tests\gearboxes_tests.json");
            var gearbox     = new GearBox {
                Type = Enums.GearBoxTypeEnum.Automatic
            };


            //Act
            gearboxRepo.AddEntity(gearbox);



            //retrieve from db
            var retrievedGearbox = gearboxRepo.GetById(gearbox.Id.ToString());

            //Assert
            Assert.True(gearbox.Equals(retrievedGearbox));
        }
        public void JSONVehicleRepository_GetAll_Test()
        {
            //Arrange
            var vehicleRepo = new JSONBaseRepository <Vehicle>(@"D:\Projects\OOP Principles\VehicleShowRoom\VehicleIndustry.Dal\JSONdatabase\Tests\vehicles_tests.json");
            var vehicles    = vehicleRepo.GetAll().ToList();

            //Act
            var  retrievedVehicles = vehicleRepo.GetAll().ToList();
            bool rez = true;

            for (int i = 0; i < vehicles.Count(); i++)
            {
                if (!vehicles[i].Equals(retrievedVehicles[i]))
                {
                    rez = false;
                    break;
                }
            }
            //Assert
            Assert.True(rez);
        }
Example #14
0
        public void JSONCustomerRepository_GetAll_Test()
        {
            //Arrange
            var customerRepo = new JSONBaseRepository <Customer>(@"D:\Projects\OOP Principles\VehicleShowRoom\VehicleIndustry.Dal\JSONdatabase\Tests\customers_tests.json");
            var customers    = customerRepo.GetAll().ToList();

            //Act
            var retrievedCustomers = customerRepo.GetAll().ToList();
            //retrievedVehicles[0].Id = new Guid();
            bool rez = true;

            for (int i = 0; i < customers.Count(); i++)
            {
                if (!customers[i].Equals(retrievedCustomers[i]))
                {
                    rez = false;
                    break;
                }
            }
            //Assert
            Assert.True(rez);
        }