private ClientData CreateTestClient() { var db = new AlicargoDataContext(_context.Connection); var user = _fixture.Build<DbContext.User>() .Without(x => x.Admins) .Without(x => x.Clients) .Without(x => x.Brokers) .Without(x => x.Forwarders) .Without(x => x.Carriers) .Without(x => x.Senders) .With(x => x.TwoLetterISOLanguageName, TwoLetterISOLanguageName.Russian) .Create(); db.Users.InsertOnSubmit(user); db.SubmitChanges(); var client = _fixture.Build<Client>() .Without(x => x.Applications) .Without(x => x.Calculations) .Without(x => x.Transit) .With(x => x.TransitId, TestConstants.TestTransitId) .With(x => x.User, user) .Create(); db.Clients.InsertOnSubmit(client); db.SubmitChanges(); return new ClientData { Emails = client.Emails, LegalEntity = client.LegalEntity, BIC = client.BIC, Nic = client.Nic, Contacts = client.Contacts, Phone = client.Phone, INN = client.INN, KPP = client.KPP, OGRN = client.OGRN, Bank = client.Bank, LegalAddress = client.LegalAddress, MailingAddress = client.MailingAddress, RS = client.RS, KS = client.KS, TransitId = client.TransitId, ClientId = client.Id, Login = user.Login, Language = user.TwoLetterISOLanguageName, UserId = user.Id, ContractDate = client.ContractDate, ContractNumber = client.ContractNumber, FactureCost = client.FactureCost, FactureCostEx = client.FactureCostEx, InsuranceRate = client.InsuranceRate, PickupCost = client.PickupCost, TransitCost = client.TransitCost, TariffPerKg = client.TariffPerKg, ScotchCostEdited = client.ScotchCostEdited, DefaultSenderId = null, Comments = client.Comments }; }
public void TestInitialize() { _db = new AlicargoDataContext(Settings.Default.MainConnectionString); _composition = new CompositionHelper(Settings.Default.MainConnectionString, Settings.Default.FilesConnectionString); _controller = _composition.Kernel.Get<AirWaybillController>(); }
public void Test_Create() { var password = _mock.Create<string>(); var authentication = _mock.Build<AuthenticationModel>() .With(x => x.ConfirmPassword, password) .With(x => x.NewPassword, password) .Create(); var model = _mock.Build<ClientModel>() .With(x => x.Emails, "*****@*****.**") .With(x => x.Authentication, authentication) .With(x => x.ContractDate, DateTimeProvider.Now.ToString()) .With(x => x.DefaultSenderId, TestConstants.TestSenderId) .Create(); var transit = _mock.Build<TransitEditModel>() .With(x => x.CityId, TestConstants.TestCityId1) .Create(); _controller.Create(model, transit); var context = new AlicargoDataContext(Settings.Default.MainConnectionString); var client = context.Clients.First(x => x.User.Login == authentication.Login); client.User.PasswordHash.Should().NotBe(new byte[0]); client.User.PasswordSalt.Should().NotBe(new byte[0]); client.ShouldBeEquivalentTo( model, options => options.ExcludingMissingProperties() .Excluding(x => x.ContractDate) .Excluding(x => x.InsuranceRate)); client.ContractDate.ToString().ShouldBeEquivalentTo(model.ContractDate); client.InsuranceRate.ShouldBeEquivalentTo(model.InsuranceRate / 100); client.Transit.ShouldBeEquivalentTo(transit, options => options.ExcludingMissingProperties()); }
public BrokerRepository(IDbConnection connection) { _context = new AlicargoDataContext(connection); _selector = x => new BrokerData { Id = x.Id, Name = x.Name, Email = x.Email, UserId = x.UserId, Language = x.User.TwoLetterISOLanguageName, Login = x.User.Login }; }
public ManagerRepository(IDbConnection connection) { _context = new AlicargoDataContext(connection); _selector = x => new UserEntityData { EntityId = x.Id, UserId = x.UserId, Name = x.Name, Login = x.User.Login, Email = x.Email, Language = x.User.TwoLetterISOLanguageName }; }
public ApplicationEditor(IDbConnection connection, ISqlProcedureExecutor executor, long defaultStateId) { _executor = executor; _defaultStateId = defaultStateId; _context = new AlicargoDataContext(connection); }
public ApplicationRepository(IDbConnection connection) { _context = new AlicargoDataContext(connection); _orderer = new ApplicationRepositoryOrderer(); _selector = x => new ApplicationData { AddressLoad = x.AddressLoad, Id = x.Id, FactoryName = x.FactoryName, Invoice = x.Invoice, MarkName = x.MarkName, Volume = x.Volume, Count = x.Count, AirWaybill = x.AirWaybill.Bill, Characteristic = x.Characteristic, ClientLegalEntity = x.Client.LegalEntity, ClientId = x.ClientId, ClientNic = x.Client.Nic, CountryId = x.CountryId, Class = (ClassType?)x.ClassId, CreationTimestamp = x.CreationTimestamp, DateInStock = x.DateInStock, DateOfCargoReceipt = x.DateOfCargoReceipt, FactoryContact = x.FactoryContact, FactoryEmail = x.FactoryEmail, FactoryPhone = x.FactoryPhone, StateChangeTimestamp = x.StateChangeTimestamp, StateId = x.StateId, TermsOfDelivery = x.TermsOfDelivery, TransitId = x.TransitId, TransitAddress = x.Transit.Address, CarrierName = x.Transit.Carrier.Name, CarrierContact = x.Transit.Carrier.Contact, CarrierAddress = x.Transit.Carrier.Address, CarrierPhone = x.Transit.Carrier.Phone, CarrierEmail = x.Transit.Carrier.Email, CarrierId = x.Transit.CarrierId, TransitCityId = x.Transit.CityId, TransitDeliveryType = (DeliveryType)x.Transit.DeliveryTypeId, TransitMethodOfTransit = (MethodOfTransit)x.Transit.MethodOfTransitId, TransitPhone = x.Transit.Phone, TransitRecipientName = x.Transit.RecipientName, TransitReference = x.TransitReference, TransitWarehouseWorkingTime = x.Transit.WarehouseWorkingTime, WarehouseWorkingTime = x.WarehouseWorkingTime, Weight = x.Weight, MethodOfDelivery = (MethodOfDelivery)x.MethodOfDeliveryId, IsPickup = x.IsPickup, Value = x.Value, CurrencyId = (CurrencyType)x.CurrencyId, AirWaybillId = x.AirWaybillId, SenderId = x.SenderId, SenderContact = x.Sender.Contact, SenderPhone = x.Sender.Phone, SenderAddress = x.Sender.Address, SenderEmail = x.Sender.Email, AirWaybillDateOfArrival = x.AirWaybill.DateOfArrival, AirWaybillDateOfDeparture = x.AirWaybill.DateOfDeparture, AirWaybillGTD = x.AirWaybill.GTD, ClientEmails = x.Client.Emails, ClientUserId = x.Client.UserId, TariffPerKg = x.TariffPerKg, SenderRate = x.SenderRate, SenderName = x.Sender.Name, FactureCost = x.FactureCost, FactureCostEx = x.FactureCostEx, SenderScotchCost = x.Sender.TariffOfTapePerBox * x.Count, TransitCost = x.TransitCost, PickupCost = x.PickupCost, ForwarderName = x.Forwarder.Name, ForwarderId = x.ForwarderId, InsuranceRate = x.InsuranceRate, CalculationProfit = x.CalculationProfit, CalculationTotalTariffCost = x.CalculationTotalTariffCost, DisplayNumber = x.DisplayNumber, FactureCostEdited = x.FactureCostEdited, FactureCostExEdited = x.FactureCostExEdited, PickupCostEdited = x.PickupCostEdited, ScotchCostEdited = x.ScotchCostEdited, TransitCostEdited = x.TransitCostEdited, CountInInvoce = x.CountInInvoce, DocumentWeight = x.DocumentWeight, MRN = x.MRN, Comments = x.Comments }; }