public void Move_only_address_to_another_client() { var oldClient = DataMother.CreateTestClientWithAddressAndUser(); var newClient = DataMother.CreateTestClientWithAddressAndUser(); var address = oldClient.Addresses[0]; var addressIdForMove = address.Id; Open(address); browser.TextField(Find.ById("TextForSearchClient")).TypeText(newClient.Id.ToString()); browser.Button(Find.ById("SearchClientButton")).Click(); Thread.Sleep(2000); Assert.IsTrue(browser.SelectList(Find.ById("clientsList")).Exists); Assert.That(browser.SelectList(Find.ById("clientsList")).Options.Count, Is.GreaterThan(0)); Assert.IsTrue(browser.Button(Find.ByValue("Отмена")).Exists); Assert.IsTrue(browser.Button(Find.ByValue("Переместить")).Exists); ClickButton("Переместить"); AssertText("Адрес доставки успешно перемещен"); AssertText(newClient.Name); Assert.That(browser.Text, Is.Not.StringContaining(oldClient.Name)); session.Refresh(oldClient); session.Refresh(newClient); address = session.Load <Address>(addressIdForMove); Assert.That(address.Client.Id, Is.EqualTo(newClient.Id)); Assert.That(newClient.Addresses.Count, Is.EqualTo(2)); Assert.That(oldClient.Addresses.Count, Is.EqualTo(0)); }
public void Seup() { client = DataMother.CreateTestClientWithAddressAndUser(); user = client.Users.First(); user.AvaliableAddresses.Add(client.Addresses.First()); Flush(); }
public void Return_updated_addresses() { var client = DataMother.CreateTestClientWithAddressAndUser(); var user = client.Users[0]; var address = client.Addresses[0]; user.AvaliableAddresses.Add(address); var userAccount = user.Accounting; userAccount.IsFree = true; var addressAccount = address.Accounting; addressAccount.IsFree = true; session.Save(client); //анонимные объекты internal для того что бы получить доступ к полям использую exposed object var result = Exposed.From(controller.Update(userAccount.Id, null, false, null, null, null, null)); session.Refresh(addressAccount); Assert.That(addressAccount.IsFree, Is.False); Assert.That(result.message, Is.EqualTo(String.Format("Следующие адреса доставки стали платными: {0}", address.Value))); Assert.That(result.accounts.Length, Is.EqualTo(1)); var resultAccount = Exposed.From(result.accounts[0]); Assert.That(resultAccount.id, Is.EqualTo(addressAccount.Id)); Assert.That(resultAccount.free, Is.EqualTo(addressAccount.IsFree)); }
public void Move_only_user_to_another_client() { var oldClient = DataMother.CreateTestClientWithAddressAndUser(); var newClient = DataMother.CreateTestClientWithAddressAndUser(); oldClient.Name += oldClient.Id.ToString(); session.SaveOrUpdate(oldClient); var user = oldClient.Users[0]; newClient.Name += newClient.Id.ToString(); session.SaveOrUpdate(newClient); Open("users/{0}/edit", user.Id); browser.TextField(Find.ById("TextForSearchClient")).TypeText(newClient.Id.ToString()); browser.Button(Find.ById("SearchClientButton")).Click(); Thread.Sleep(2000); Assert.IsTrue(browser.SelectList(Find.ById("clientsList")).Exists); Assert.That(browser.SelectList(Find.ById("clientsList")).Options.Count, Is.GreaterThan(0)); Assert.IsTrue(browser.Button(Find.ByValue("Отмена")).Exists); Assert.IsTrue(browser.Button(Find.ByValue("Переместить")).Exists); ClickButton("Переместить"); AssertText("Пользователь успешно перемещен"); session.Refresh(oldClient); session.Refresh(newClient); session.Refresh(user); Assert.That(user.Client.Id, Is.EqualTo(newClient.Id)); Assert.That(newClient.Users.Count, Is.EqualTo(2)); Assert.That(oldClient.Users.Count, Is.EqualTo(0)); }
public void Move_user_with_logs() { var oldClient = DataMother.CreateTestClientWithAddressAndUser(); var user = oldClient.Users[0]; var address = oldClient.Addresses[0]; user.AvaliableAddresses = new List <Address>(); address.AvaliableForUsers.Add(user); var newClient = DataMother.CreateTestClientWithAddressAndUser(); controller.MoveUserOrAddress(newClient.Id, user.Id, address.Id, newClient.Orgs().First().Id, false); session.Flush(); session.Refresh(oldClient); session.Refresh(newClient); var records = session.Query <AuditRecord>() .Where(l => l.Service == newClient && l.ObjectId == user.Id) .ToList(); Assert.That(user.Client.Id, Is.EqualTo(newClient.Id)); Assert.That(newClient.Users.Count, Is.EqualTo(2)); Assert.That(oldClient.Users.Count, Is.EqualTo(0)); Assert.That(records.Count, Is.EqualTo(3), records.Implode()); Assert.That(records.Implode(), Is.StringContaining("Перемещение пользователя от")); }
public void Move_last_user_to_another_client() { var oldClient = DataMother.CreateTestClientWithAddressAndUser(); var oldUser = oldClient.Users[0]; var address = oldClient.Addresses[0]; oldUser.AvaliableAddresses = new List <Address>(); address.AvaliableForUsers.Add(oldUser); var newClient = DataMother.CreateTestClientWithAddressAndUser(); controller.MoveUserOrAddress(newClient.Id, oldUser.Id, address.Id, newClient.Orgs().First().Id, false); controller.SendMails(); session.Flush(); session.Refresh(oldClient); session.Refresh(newClient); session.Refresh(oldUser); Assert.That(oldUser.Client.Id, Is.EqualTo(newClient.Id)); Assert.That(newClient.Users.Count, Is.EqualTo(2)); Assert.That(oldClient.Users.Count, Is.EqualTo(0)); Assert.That(newClient.Addresses.Count, Is.EqualTo(1)); Assert.That(oldClient.Addresses.Count, Is.EqualTo(1)); Assert.That(oldClient.Status, Is.EqualTo(ClientStatus.On)); Assert.That(Emails.FirstOrDefault(m => m.Subject.Contains("Перемещение пользователя")), Is.Not.Null, "не могу найти уведомление о перемещении"); }
public void Inventory() { var client = DataMother.CreateTestClientWithAddressAndUser(); var supplier = DataMother.CreateSupplier(); DataMother.CreateTestDocument(supplier, client); controller.Inventory(client.Users[0].Id); }
public void Search_from_main_page() { var client = DataMother.CreateTestClientWithAddressAndUser(); Open(); browser.TextField(Find.ById("filter_SearchText")).TypeText(client.Users[0].Login); ClickButton("Найти"); CheckThatIsUserPage(browser, client); }
public void Setup() { client = DataMother.CreateTestClientWithAddressAndUser(); payer = client.Payers.First(); payer.Name += payer.Id; session.Update(payer); Open(payer); browser.WaitUntilContainsText("Плательщик", 2); AssertText("Плательщик"); }
public void Delete_client() { var client = DataMother.CreateTestClientWithAddressAndUser(); var clientId = client.Id; var payerId = client.Payers[0].Id; client.Delete(session); Reopen(); Assert.That(session.Get <Client>(clientId), Is.Null); Assert.That(session.Get <Payer>(payerId), Is.Null); }
public void Search_by_contact_phone() { var client = DataMother.CreateTestClientWithAddressAndUser(); var phone = String.Format("{0}-123456", client.Id.ToString().RightSlice(4)); client.Users[0].AddContactGroup(); client.Users[0].ContactGroup.AddContact(new Contact(ContactType.Phone, phone)); FlushAndCommit(); Search(SearchUserBy.ByContacts, phone); CheckThatIsUserPage(browser, client); }
public void Search_by_contact_email() { var client = DataMother.CreateTestClientWithAddressAndUser(); var mail = String.Format("test{0}@test.test", client.Id); client.Users[0].AddContactGroup(); client.Users[0].ContactGroup.AddContact(new Contact(ContactType.Email, mail)); FlushAndCommit(); Search(SearchUserBy.ByContacts, mail); CheckThatIsUserPage(browser, client); }
public void ForMiniMailClientTest() { var client = DataMother.CreateTestClientWithAddressAndUser(); session.SaveOrUpdate(client); var searchString = client.Id + "@client.docs.analit.net"; filter.SearchText = searchString; var result = filter.Find(); Assert.That(result.Count, Is.EqualTo(1)); }
public void ForMiniMailRegionTest() { var client = DataMother.CreateTestClientWithAddressAndUser(); session.SaveOrUpdate(client); var searchString = client.HomeRegion.ShortAliase + "@docs.analit.net"; filter.SearchText = searchString; var result = filter.Find(); Assert.That(result.Count, Is.GreaterThanOrEqualTo(1)); }
public void SetUp() { session.CreateSQLQuery(@" update ordersendrules.smart_order_rules set AssortimentPriceCode = null; delete from usersettings.pricesdata;") .ExecuteUpdate(); supplier = DataMother.CreateSupplier(); session.Save(supplier); client = DataMother.CreateTestClientWithAddressAndUser(); session.Save(client); var intersectionOne = session.Query <Intersection>().Where(i => i.Price == supplier.Prices.First() && i.Client == client).ToList(); foreach (var intersection in intersectionOne) { intersection.AvailableForClient = false; session.Save(intersection); } Flush(); var twoClient = DataMother.CreateTestClientWithAddressAndUser(); session.Save(twoClient); session.Flush(); var intersections = session.Query <Intersection>().Where(i => i.Client == twoClient).ToList(); foreach (var intersection in intersections) { intersection.SupplierClientId = "123"; intersection.SupplierPaymentId = "123"; intersection.AvailableForClient = true; intersection.PriceMarkup = 0.5; foreach (var addressIntersection in intersection.Addresses) { addressIntersection.SupplierDeliveryId = "123"; session.Save(addressIntersection); } session.Save(intersection); } Flush(); filter = new ClientConditionsMonitoringFilter { Session = session, ClientId = client.Id }; }
public void Autosearch_by_contact_phone() { var client = DataMother.CreateTestClientWithAddressAndUser(); client.Users[0].AddContactGroup(); client.Users[0].ContactGroup.AddContact(new Contact(ContactType.Phone, String.Format("{0}-124578", client.Id.ToString().Substring(0, 4)))); FlushAndCommit(); browser.TextField(Find.ById("filter_SearchText")).TypeText(String.Format("{0}-124578", client.Id.ToString().Substring(0, 4))); ClickButton("Поиск"); CheckThatIsUserPage(browser, client); }
private void Create_loaded_document_logs_unparsed_document(out Client client, out Supplier supplier, out DocumentReceiveLog documentLogEntity, out UpdateLogEntity updateLogEntity) { client = DataMother.CreateTestClientWithAddressAndUser(); supplier = DataMother.CreateSupplier(); Save(supplier); documentLogEntity = DataMother.CreateTestDocumentLog(supplier, client); updateLogEntity = DataMother.CreateTestUpdateLogEntity(client); session.SaveOrUpdate(updateLogEntity); documentLogEntity.SendUpdateLogEntity = updateLogEntity; Save(documentLogEntity); }
public void UserAndAddresseTest() { var client = DataMother.CreateTestClientWithAddressAndUser(); Open("ManagerReports"); Click("зарегистрированные пользователи и адреса"); browser.FindElementById(client.Id.ToString()).Click(); AssertText(string.Format("Клиент: {0}", client.Name)); foreach (var user in client.Users) { AssertText(string.Format("{0} - ({1})", user.Name, user.Id)); } }
public void Search_by_person_name() { var client = DataMother.CreateTestClientWithAddressAndUser(); var person = String.Format("testPerson{0}", client.Id); client.Users[0].AddContactGroup(); session.Save(client.Users[0].ContactGroup); client.Users[0].ContactGroup.AddPerson(person); FlushAndCommit(); Search(SearchUserBy.ByPersons, person); CheckThatIsUserPage(browser, client); }
public void SetUp() { client = DataMother.CreateTestClientWithAddressAndUser(); payer = client.Payers.First(); account = DataMother.Report(payer); report = account.Report; session.Save(account); payer.Recipient = session.Query <Recipient>().First(); payer.Reports.Add(report); Open(payer); AssertText("Плательщик"); }
public void Setup() { client = DataMother.CreateTestClientWithAddressAndUser(); user = client.Users.First(); updateLog = new UpdateLogEntity(user) { AppVersion = 1000, Addition = "Test update", Commit = true, }; Save(updateLog); Open("Logs/UpdateLog?userId={0}", user.Id); AssertText("История обновлений"); }
public void After_change_payer_update_payment_sum() { var client = DataMother.CreateTestClientWithAddressAndUser(); client.Users.Each(u => u.Accounting.Accounted()); var oldPayer = client.Payers.First(); var newPayer = DataMother.CreatePayer(); session.SaveOrUpdate(newPayer); client.ChangePayer(session, newPayer, newPayer.JuridicalOrganizations.First()); session.SaveOrUpdate(client); Assert.That(oldPayer.PaymentSum, Is.EqualTo(0)); Assert.That(newPayer.PaymentSum, Is.EqualTo(800)); }
public void Change_client_payer() { var client = DataMother.CreateTestClientWithAddressAndUser(); var payer = DataMother.CreatePayer(); session.SaveOrUpdate(payer); client.ChangePayer(session, payer, payer.JuridicalOrganizations.First()); session.SaveOrUpdate(client); Assert.That(client.Payers, Is.EquivalentTo(new[] { payer })); Assert.That(client.Users[0].Payer, Is.EqualTo(payer)); var address = client.Addresses[0]; Assert.That(address.Payer, Is.EqualTo(payer)); Assert.That(address.LegalEntity, Is.EqualTo(payer.JuridicalOrganizations[0])); }
public void Disabled_if_user_disabled() { var client = DataMother.CreateTestClientWithAddressAndUser(); var user = client.Users[0]; user.Enabled = false; Save(user); Flush(); filter.SearchBy = SearchUserBy.ByUserId; filter.SearchText = user.Id.ToString(); var result = filter.Find(); Assert.That(result.Count, Is.EqualTo(1), result.Implode()); Assert.That(result[0].SelfDisabled, Is.True); }
public void Setup() { var supplier = DataMother.CreateSupplier(); client = DataMother.CreateTestClientWithAddressAndUser(); user = client.Users[0]; user.AvaliableAddresses.Add(client.Addresses[0]); order = new ClientOrder(user, supplier.Prices[0]); var product = new Product(session.Load <Catalog>(DataMother.CreateCatelogProduct())); var line = new OrderLine(order, product, 100, 1); Save(supplier, order, product, line); }
public void Setup() { client = DataMother.CreateTestClientWithAddressAndUser(); payer = client.Payers.First(); payer.Name += payer.Id; session.Save(payer); client.AddAddress(new Address { Client = client, Value = "test address for billing", }); session.Save(client); foreach (var address in client.Addresses) { address.Enabled = false; session.Save(address); } }
public void UpdatePricesForClientTest() { var region = session.Query <Region>().First(); var supplier = DataMother.CreateSupplier(); session.Save(supplier); var client = DataMother.CreateTestClientWithAddressAndUser(); session.Save(client); var intersection = session.Query <Intersection>().First(i => i.Client == client && i.Price.PriceType != PriceType.Vip); intersection.AgencyEnabled = false; intersection.AvailableForClient = false; session.Save(intersection); var vipPrice = supplier.AddPrice("vip", PriceType.Vip); session.Save(vipPrice); var vipIntersection = new Intersection { Client = client, Region = region, Price = vipPrice, Org = client.GetLegalEntity().First(), AgencyEnabled = false, AvailableForClient = false }; session.Save(vipIntersection); session.CreateSQLQuery(@"delete from customers.userprices").ExecuteUpdate(); client.UpdatePricesForClient(session); session.Refresh(intersection); Assert.IsTrue(intersection.AgencyEnabled); Assert.IsTrue(intersection.AvailableForClient); session.Refresh(vipIntersection); vipIntersection = session.Get <Intersection>(vipIntersection.Id); Assert.IsTrue(vipIntersection.AgencyEnabled); Assert.IsFalse(vipIntersection.AvailableForClient); var usePricesCount = session.CreateSQLQuery(@" select count(*) from customers.userprices u where u.UserId = :userId ") .SetParameter("userId", client.Users[0].Id) .UniqueResult <long?>(); var intCount = session.Query <Intersection>().Count(i => i.Client == client); Assert.AreEqual(usePricesCount, intCount); }
public void FirstTableIndicateTest() { var client = DataMother.CreateTestClientWithAddressAndUser(); var user2 = client.AddUser(session, "testUser"); var user = client.Users[0]; user.SubmitOrders = true; user.IgnoreCheckMinOrder = true; user.AllowDownloadUnconfirmedOrders = true; session.Save(user); session.Save(user2); Open(); browser.TextField(Find.ById("filter_SearchText")).TypeText(client.Name); ClickButton("Найти"); var tr = browser.Table(Find.ByClass("DataTable")).TableRows[1]; Assert.That(tr.ClassName, Is.StringContaining("first-table")); Assert.That(tr.ClassName, Is.StringContaining("allow-download-unconfirmed-orders")); }
public void Search_by_address() { var client = DataMother.CreateTestClientWithAddressAndUser(); var payer = client.Payers.First(); var address = client.Addresses.First(); address.Value = address.Value + " " + address.Id; session.Save(address); session.Save(client); session.Flush(); var items = new PayerFilter(session) { SearchText = address.Value, SearchBy = SearchBy.Address }.Find(); Assert.That(items.Count, Is.EqualTo(1)); Assert.That(items[0].PayerId, Is.EqualTo(payer.Id)); }
public void Setup() { client = DataMother.CreateTestClientWithAddressAndUser(); payer = client.Payers.First(); payer.Name += payer.Id; session.SaveOrUpdate(payer); client.AddAddress("test address for billing"); user = client.Users[0]; address = client.Addresses[0]; session.SaveOrUpdate(client); _supplier = DataMother.CreateSupplier(); _supplier.Payer = payer; session.Save(_supplier); Open(payer); WaitForText("Плательщик"); AssertText("Плательщик"); }