Ejemplo n.º 1
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.º 2
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();
        }