Ejemplo n.º 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();
        }
Ejemplo n.º 2
0
        public void MakeServiceReadTest()
        {
            //Arange
            IncludeAllMappings.include();
            var context         = new VehicleContext();
            var repository      = new Repository.Repositorys.Repository(context, new UnitOfWorkFactory(new UnitOfWork(context)));
            var makeRepository  = new MakeRepository(repository);
            var modelRepository = new ModelRepository(repository);
            var vMake           = new VehicleMakeDomain()
            {
                Name = "MakeServiceReadTest", Abrv = "MakeServiceReadTest", VehicleModel = null
            };
            var testService = new MakeService(makeRepository, modelRepository);

            IEnumerable <IVehicleMakeDomain> readAll = null;
            IVehicleMakeDomain targetItem            = null;

            Task.Run(async() =>
            {
                readAll = await testService.ReadAll();
                Assert.IsNotNull(readAll);
                targetItem = readAll.LastOrDefault();
            }).GetAwaiter().GetResult();

            Task.Run(async() =>
            {
                //Act
                var result = await testService.Read(targetItem.VehicleMakeId);
                //Assert
                Assert.AreEqual(targetItem.VehicleMakeId, result.VehicleMakeId);
            }).GetAwaiter().GetResult();
        }
Ejemplo n.º 3
0
        public void ModelServiceReadAllTest()
        {
            //Arange
            IncludeAllMappings.include();
            var context         = new VehicleContext();
            var repository      = new Repository.Repositorys.Repository(context, new UnitOfWorkFactory(new UnitOfWork(context)));
            var makeRepository  = new MakeRepository(repository);
            var modelRepository = new ModelRepository(repository);
            var makeService     = new MakeService(makeRepository, modelRepository);
            var testService     = new ModelService(modelRepository);

            //Add make
            var vMake = new VehicleMakeDomain()
            {
                Name = "ModelServiceReadAllTest", Abrv = "ModelServiceReadAllTest", VehicleModel = null
            };

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

            IVehicleMakeDomain targetMake = null;

            //Get make
            Task.Run(async() =>
            {
                var response = await makeService.ReadAll();
                Assert.IsNotNull(response);
                targetMake = response.LastOrDefault();
            }).GetAwaiter().GetResult();

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

            //Add model
            Task.Run(async() =>
            {
                var response = await testService.Add(vModel);
                Assert.AreEqual(1, response);
            }).GetAwaiter().GetResult();

            Task.Run(async() =>
            {
                //Act
                var result = await testService.ReadAll();
                //Assert
                Assert.IsNotNull(result);
            }).GetAwaiter().GetResult();
        }
Ejemplo n.º 4
0
        public void MakeServiceAddTest()
        {
            //Arange
            IncludeAllMappings.include();
            var context         = new VehicleContext();
            var repository      = new Repository.Repositorys.Repository(context, new UnitOfWorkFactory(new UnitOfWork(context)));
            var makeRepository  = new MakeRepository(repository);
            var modelRepository = new ModelRepository(repository);
            var vMake           = new VehicleMakeDomain()
            {
                Name = "MakeRepositoryAddTest", Abrv = "MakeRepositoryAddTest", VehicleModel = null
            };
            var testService = new MakeService(makeRepository, modelRepository);

            Task.Run(async() =>
            {
                //Act
                var result = await testService.Add(vMake);
                //Assert
                Assert.AreEqual(1, result);
            }).GetAwaiter().GetResult();
        }
Ejemplo n.º 5
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();
        }
Ejemplo n.º 6
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();
        }