예제 #1
0
 public void NotThrowException_WhenValidUnitOfWorkIsPassed()
 {
     //arrange
     var validUnitOfWork = new Mock <IUnitOfWork>();
     //act
     var carService = new Services.CarService(validUnitOfWork.Object);
 }
예제 #2
0
        public void ThrowServiceExcpetion_WhenNullArgumentIsPassed()
        {
            //arrange
            var fakeUnitOfWork = new Mock <IUnitOfWork>();
            var sut            = new Services.CarService(fakeUnitOfWork.Object);

            //act
            //assert
            Assert.ThrowsException <ServiceException>(() => sut.AddCar(null));
        }
예제 #3
0
        public void NotThrowException_WhenValidUnitOfWorkIsPassed()
        {
            //arrange
            var contexOptions = new DbContextOptionsBuilder <DealershipContext>()
                                .UseInMemoryDatabase(databaseName: "AddCarToDatabase_WhenValidParametersArePassed").Options;
            var extrasServiceMock = new Mock <IExtraService>();

            //act
            using (var dealershipContext = new DealershipContext(contexOptions))
            {
                var carService = new Services.CarService(dealershipContext, extrasServiceMock.Object);
            }
        }
예제 #4
0
        public void AddCarToDatabase_WhenValidParametersArePassed()
        {
            var contexOptions = new DbContextOptionsBuilder <DealershipContext>()
                                .UseInMemoryDatabase(databaseName: "AddCarToDatabase_WhenValidParametersArePassed").Options;

            var testCar = new Mock <Car>();

            DealershipContext dealershipContext;

            using (dealershipContext = new DealershipContext(contexOptions))
            {
                var unitofWork = new UnitOfWork(dealershipContext);
                var carService = new Services.CarService(unitofWork);


                carService.AddCar(testCar.Object);
            }
            using (dealershipContext = new DealershipContext(contexOptions))
            {
                Assert.IsTrue(dealershipContext.Cars.Count() == 1);
            }
        }