Exemple #1
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();
        }
Exemple #2
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();
        }
Exemple #3
0
        public void MakeServiceReadAllTest()
        {
            //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 testService     = new MakeService(makeRepository, modelRepository);

            Task.Run(async() =>
            {
                //Act
                var result = await testService.ReadAll();
                //Assert
                Assert.IsNotNull(result);
            }).GetAwaiter().GetResult();
        }