public Task <Vehicle> CreateDomainVehicle(int companyId, VehicleAM vehicle)
 {
     return(DomainVehicleService.Create(
                companyId,
                vehicle.RegistrationNumber,
                vehicle.BrandCatalogItemId,
                vehicle.CapacityCatalogItemId,
                vehicle.KindCatalogItemId));
 }
        public async void SignUpDriverCompany()
        {
            var ApplicationVehicle = new VehicleAM
            {
                RegistrationNumber    = "К100ЕЕ77",
                BrandCatalogItemId    = 0,
                CapacityCatalogItemId = 1,
                KindCatalogItemId     = 2
            };

            var ApplicationDriver = new DriverAM
            {
                IdentityUserId = 6,
                FirstName      = "Петя",
                LastName       = "Лиссерман"
            };

            var garageAddress = new AddressAM
            {
                Country  = "Россия",
                Province = "Ярославская",
                Locality = "Рыбинск",
                District = "Центральный"
            };

            var driverCompanyModel = new DriverCompanyAM
            {
                GarageAddress = garageAddress,
                CompanyName   = "Транспортные Системы",
                Vehicle       = ApplicationVehicle,
                Driver        = ApplicationDriver
            };

            var domainCompany = new Company {
                Id = 1
            };
            var domainVehicle = new Vehicle {
                Id = 2
            };
            var domainDriver = new Driver {
                Id = 3
            };
            var domainGarage = new Garage {
                Id = 4
            };

            Suite.DomainGarageServiceMock
            .Setup(m => m.GetByAddress(garageAddress.Country, garageAddress.Province, garageAddress.Locality, garageAddress.District))
            .ReturnsAsync(domainGarage);

            Suite.DomainCompanyServiceMock
            .Setup(m => m.Create(domainGarage.Id, driverCompanyModel.CompanyName))
            .ReturnsAsync(domainCompany);

            Suite.VehicleServiceMock
            .Setup(m => m.CreateDomainVehicle(domainCompany.Id, ApplicationVehicle))
            .ReturnsAsync(domainVehicle);

            Suite.DomainDriverServiceMock
            .Setup(m => m.Create(ApplicationDriver.FirstName, ApplicationDriver.LastName, ApplicationDriver.PhoneNumber, domainCompany.Id))
            .ReturnsAsync(domainDriver);

            Suite.TransactionServiceMock
            .Setup(m => m.BeginTransaction())
            .ReturnsAsync(Suite.TransactionMock.Object);

            await Suite.SignUpService.SignUpDriverCompany(driverCompanyModel);

            Suite.DomainGarageServiceMock
            .Verify(m => m.GetByAddress(garageAddress.Country, garageAddress.Province, garageAddress.Locality, garageAddress.District), Times.Once);

            Suite.DomainCompanyServiceMock
            .Verify(m => m.Create(domainGarage.Id, driverCompanyModel.CompanyName), Times.Once);

            Suite.VehicleServiceMock
            .Verify(m => m.CreateDomainVehicle(
                        domainCompany.Id,
                        It.Is <VehicleAM>(v => v == ApplicationVehicle)), Times.Once);

            Suite.DomainDispatcherServiceMock
            .Verify(m => m.Create(ApplicationDriver.FirstName, ApplicationDriver.LastName, ApplicationDriver.PhoneNumber, domainCompany.Id), Times.Once);

            Suite.DomainDriverServiceMock
            .Verify(m => m.Create(ApplicationDriver.FirstName, ApplicationDriver.LastName, ApplicationDriver.PhoneNumber, domainCompany.Id), Times.Once);

            Suite.DomainDriverServiceMock
            .Verify(m => m.AssignVehicle(domainDriver.Id, domainVehicle.Id), Times.Once);

            Suite.TransactionMock
            .Verify(m => m.Commit(), Times.Once);

            Suite.TransactionMock
            .Verify(m => m.Rollback(), Times.Never);
        }