示例#1
0
        public void MakeRepositoryGetAllTest()
        {
            //Arrange
            IncludeAllMappings.include();
            var vMake = new VehicleMakeDomain()
            {
                Name = "MakeRepositoryGetAllTest", Abrv = "MakeRepositoryGetAllTest", VehicleMakeId = Guid.NewGuid(), VehicleModel = null
            };

            var context        = new VehicleContext();
            var repository     = new Repositorys.Repository(context, new UnitOfWorkFactory(new UnitOfWork(context)));
            var testRepository = new MakeRepository(repository);
            int response;

            Task.Run(async() =>
            {
                response = await testRepository.Add(vMake);
                Assert.AreEqual(1, response);
            }).GetAwaiter().GetResult();
            //Act
            Task.Run(async() =>
            {
                var result = await testRepository.GetAll();
                //Assert
                Assert.IsNotNull(result);
            }).GetAwaiter().GetResult();
        }
示例#2
0
        public void CanAddMake()
        {
            var repo = new MakeRepository();

            Assert.AreEqual(3, repo.GetAll().Count);
            repo.Add(new Make()
            {
                MakeName = "Big"
            });
            Assert.AreEqual(4, repo.GetAll().Count);
        }
示例#3
0
        public void MakeRepositoryGetTest()
        {
            //Arrange
            IncludeAllMappings.include();
            var vMake = new VehicleMakeDomain()
            {
                Name = "MakeRepositoryGetTest", Abrv = "MakeRepositoryGetTest", VehicleModel = null
            };
            var context        = new VehicleContext();
            var repository     = new Repositorys.Repository(context, new UnitOfWorkFactory(new UnitOfWork(context)));
            var testRepository = new MakeRepository(repository);
            int response;

            Task.Run(async() =>
            {
                response = await testRepository.Add(vMake);
                //Assert.AreEqual(1, response);
            }).GetAwaiter().GetResult();

            IEnumerable <IVehicleMakeDomain> getAll;
            IVehicleMakeDomain targetMake = null;

            Task.Run(async() =>
            {
                getAll = await testRepository.GetAll();
                //Assert
                Assert.IsNotNull(getAll);

                foreach (var item in getAll)
                {
                    targetMake = item;
                }

                var result = await testRepository.Get(targetMake.VehicleMakeId);
                //Assert
                Assert.AreEqual(targetMake.VehicleMakeId, result.VehicleMakeId);
            }).GetAwaiter().GetResult();
        }
示例#4
0
        public void ModelRepositoryGetTest()
        {
            //Arrange
            //Init repo
            IncludeAllMappings.include();
            var context        = new VehicleContext();
            var repository     = new Repositorys.Repository(context, new UnitOfWorkFactory(new UnitOfWork(context)));
            var testRepository = new ModelRepository(repository);
            var makeRepository = new MakeRepository(repository);

            //Create maker
            var vMake = new VehicleMakeDomain()
            {
                Name = "ModelRepositoryGetTest", Abrv = "ModelRepositoryGetTest"
            };

            Task.Run(async() =>
            {
                var response = await makeRepository.Add(vMake);
                Assert.AreEqual(1, response);
            }).GetAwaiter().GetResult();

            //Get maker
            IEnumerable <IVehicleMakeDomain> getAllMakers = null;
            IVehicleMakeDomain targetMaker = null;

            Task.Run(async() =>
            {
                getAllMakers = await makeRepository.GetAll();
                Assert.IsNotNull(getAllMakers);

                foreach (var item in getAllMakers)
                {
                    targetMaker = item;
                }
            }).GetAwaiter().GetResult();

            //Create model
            var vModel = new VehicleModelDomain()
            {
                Name = "ModelRepositoryGetTest", Abrv = "ModelRepositoryGetTest", VehicleMakeId = targetMaker.VehicleMakeId
            };

            //Add model
            Task.Run(async() =>
            {
                var response = await testRepository.Add(vModel);

                Assert.AreEqual(1, response);
            }).GetAwaiter().GetResult();

            //Get model
            IEnumerable <IVehicleModelDomain> getAll;
            IVehicleModelDomain targetModel = null;

            Task.Run(async() =>
            {
                getAll = await testRepository.GetAll();
                Assert.IsNotNull(getAll);

                foreach (var item in getAll)
                {
                    targetModel = item;
                }

                var result = await testRepository.Get(targetModel.VehicleModelId);
                //Assert
                Assert.AreEqual(targetModel.VehicleModelId, result.VehicleModelId);
            }).GetAwaiter().GetResult();
        }
示例#5
0
 public async Task <int> Add(IVehicleMakeDomain entry)
 {
     return(await MakeRepository.Add(entry));
 }