public void GetSeedAgreementsByYears_LiveService() { var mockService = new Mock <IAgreementService>(); var listSeedAssuranceInYear = new List <SeedAssurance>() { new SeedAssurance { HarvestYear = 2015 }, new SeedAssurance { HarvestYear = 2015, }, new SeedAssurance { HarvestYear = 2016 } }; mockService.Setup(x => x.GetSeedAgreementList(supplier, ticket)).Returns(listSeedAssuranceInYear.ToArray()); var service = mockService.Object; var repo = new AgreementRepository(service, null); var result = repo.GetSeedAgreementsByYears(supplier); var resultAsEnumerable = result as IGrouping <int, SeedAssurance>[] ?? result.ToArray(); Assert.AreEqual(2, resultAsEnumerable.Count()); Assert.AreEqual(null, resultAsEnumerable.SingleOrDefault(x => x.Key == 2014)); Assert.AreEqual(2, resultAsEnumerable.Single(x => x.Key == 2015).Count()); Assert.AreEqual(1, resultAsEnumerable.Single(x => x.Key == 2016).Count()); }
public void Any_EmptyCollection_ReturnsFalse() { using (var repository = new AgreementRepository(new TestDbContext())) { var result = repository.Any(); var expected = false; Assert.AreEqual(expected, result); } }
public frmMain() { _agreementRepository = new AgreementRepository(); InitializeComponent(); txtDateTime.Text = DateTime.Now.ToString(); txtUsername.Text = System.Security.Principal.WindowsIdentity.GetCurrent().Name; btnClose.Visible = false; chkAgree.Visible = true; rtbSecurityAwareness.LoadFile("Security Awareness.rtf"); this.Load += Form1_Load; }
public void GetSeedAgreementsByYears_NullService() { var mockService = new Mock <IAgreementService>(); mockService.Setup(x => x.GetSeedAgreementList(supplier, ticket)).Returns(new SeedAssurance[0]); var service = mockService.Object; var repo = new AgreementRepository(service, null); var result = repo.GetSeedAgreementsByYears(supplier); Assert.AreEqual(0, result.Count()); }
public async Task GetFarmSamplesListAsyn_NullService() { var mockService = new Mock <IAgreementService>(); mockService.Setup(w => w.GetFarmSampleListAsync(string.Empty, string.Empty, string.Empty)).Returns(Task.FromResult((FarmSample[])null)); var service = mockService.Object; var repo = new AgreementRepository(service, null); var result = await repo.GetFarmSamplesListAsync(supplier, string.Empty); Assert.AreEqual(0, result.Length); }
public void GetAgreementsListByYears_NullService() { var mockService = new Mock <IAgreementService>(); mockService.Setup(w => w.GetAgreementList(string.Empty, string.Empty)).Returns(new Agreement[0]); var service = mockService.Object; var repo = new AgreementRepository(service, null); var list = repo.GetAgreementsListByYears(string.Empty); Assert.AreEqual(0, list.Count()); }
public void SelectWithSpecification_EmptyCollection_ReturnsFalse() { string number = "12-xx-78"; Agreement agreement = TestDbContextHelper.AddAgreement(number); using (var repository = new AgreementRepository(new TestDbContext())) { var specification = new NumberSpecification(number); var result = repository.Select(specification); Assert.IsNotNull(result); } }
public UnitOfWork(EffortlessContext context) { _context = context; Users = new UserRepository(_context); Addresses = new AddressRepository(_context); Agreements = new AgreementRepository(_context); Appointments = new AppointmentRepository(_context); Departments = new DepartmentRepository(_context); Companies = new CompanyRepository(_context); Privileges = new PrivilegeRepository(_context); Roles = new RoleRepository(_context); RolePrivileges = new RolePrivilegeRepository(_context); WorkPeriods = new WorkPeriodRepository(_context); UserRoles = new UserRoleRepository(_context); UserWorkPeriods = new UserWorkPeriodRepository(_context); }
public async Task GetFarmSamplesListAsyn_LiveService() { var mockService = new Mock <IAgreementService>(); var expectedPriceHeding = new FarmSample[1] { new FarmSample { } }; mockService.Setup(w => w.GetFarmSampleListAsync(supplier, string.Empty, ticket)).Returns(Task.FromResult(expectedPriceHeding)); var service = mockService.Object; var repo = new AgreementRepository(service, null); var result = await repo.GetFarmSamplesListAsync(supplier, string.Empty); Assert.AreEqual(1, result.Length); }
public void GetDryAgreements_LiveService() { var mockService = new Mock <IAgreementService>(); var listExpectedDryAgreements = new List <DryAgreement>() { new DryAgreement(), new DryAgreement() }; mockService.Setup(w => w.GetDryAgreementList(supplier, ticket)).Returns(listExpectedDryAgreements.ToArray); var service = mockService.Object; var repo = new AgreementRepository(service, null); var resultAsList = repo.GetDryAgreements(supplier); Assert.AreEqual(2, resultAsList.Count()); }
public void GetAgreementsListByYears_LiveService() { var mockService = new Mock <IAgreementService>(); var listExpectedAgreement = ListAgreementsInYears; mockService.Setup(w => w.GetAgreementList(supplier, ticket)).Returns(listExpectedAgreement.ToArray); var service = mockService.Object; var repo = new AgreementRepository(service, null); var resultAsList = repo.GetAgreementsListByYears(supplier); var resultAsEnumerable = resultAsList as IGrouping <int, Agreement>[] ?? resultAsList.ToArray(); Assert.AreEqual(2, resultAsEnumerable.Count()); Assert.AreEqual(null, resultAsEnumerable.SingleOrDefault(x => x.Key == 2014)); Assert.AreEqual(2, resultAsEnumerable.Single(x => x.Key == 2015).Count()); Assert.AreEqual(1, resultAsEnumerable.Single(x => x.Key == 2016).Count()); }
private static void Main(string[] args) { var db = new DatabaseContext("test"); var documentRepository = new IndicationDocumentRepository(db); var scaleRepository = new MeterScaleRepostitory(db, documentRepository); var meterRepository = new MeterRepository(db, scaleRepository); var channelRepository = new ChannelRepository(db, meterRepository); var constRepository = new ConstantFlowRepository(db); var tariffRepostitory = new TariffGroupRepository(db, constRepository, channelRepository); var unitRepostitory = new UnitRepository(db, tariffRepostitory); var repostitory = new AgreementRepository(db, unitRepostitory); foreach (var agreement in repostitory.GetAll()) { //при all не поднимаем с бд схему var calc = repostitory.Get(agreement.Id); Console.WriteLine($"{agreement.Name} {calc.СalculationPeriod(new DateTime(2018, 4, 1), new DateTime(2018, 3, 1), new DateTime(2018, 4, 1))}"); } Console.ReadKey(); }
public void Should_Get_Agreement_By_Customer_Type_Successfully() { using (IUnitOfWork unitOfWork = new UnitOfWork(Singleton.SessionFactoryProvider)) { unitOfWork.BeginTransaction(); var customer = Singleton.TestDataProvider.CreateNewRandomCustomer(); customer.Type = CustomerType.ImpulseCustomers; unitOfWork.Session.SaveOrUpdate(customer); var agreement = Singleton.TestDataProvider.CreateNewRandomAgreementForCustomer(customer); unitOfWork.Session.SaveOrUpdate(agreement); unitOfWork.Session.Flush(); IAgreementRepository agreementRepository = new AgreementRepository(unitOfWork); var list = agreementRepository.GetAgreementsByCustomerType(CustomerType.ImpulseCustomers); Assert.IsNotNull(list); Assert.IsTrue(list.Contains(agreement)); } }
public void Should_Get_Agreement_By_Customer_Type_Successfully() { using (IUnitOfWork unitOfWork = new UnitOfWork(Singleton.SessionFactoryProvider)) { unitOfWork.BeginTransaction(); var customer = Singleton.TestDataProvider.CreateNewRandomCustomer(); customer.Type = CustomerType.ImpulseCustomers; unitOfWork.Session.SaveOrUpdate(customer); var agreement = Singleton.TestDataProvider.CreateNewRandomAgreementForCustomer(customer); unitOfWork.Session.SaveOrUpdate(agreement); unitOfWork.Session.Flush(); IAgreementRepository agreementRepository = new AgreementRepository(unitOfWork); var list = agreementRepository.GetAgreementsByCustomerType(CustomerType.ImpulseCustomers); Assert.IsNotNull(list); Assert.IsTrue(list.Contains(agreement)); } }
public void BulkInsertInTempTable_JoinAgreementOnIdentityTable_ReturnAgreement() { int agreementId = TestDbContextHelper.AddAgreement().Id; using (var dbContext = new TestDbContext()) { var repository = new TemporaryTableRepository(dbContext); var collection = new List <int> { agreementId, 0, -1, -2, -3 }; var query = repository.BulkInsertInTempTable(collection); var queryResult = query.ToList(); Assert.IsTrue(queryResult.Count == 5); var agreementRepository = new AgreementRepository(dbContext); var agreements = agreementRepository.QueryableSelect().Join(query, agreement => agreement.Id, identity => identity.Id, (agreement, identity) => agreement).ToList(); Assert.IsTrue(agreements.Count == 1); } }
public void PushtoDatabase(int columns, int rows, Worksheet worksheet) { Dictionary <string, int> columnNamesWithIndex = new Dictionary <string, int>(); for (int i = 1; i <= columns; i++) { columnNamesWithIndex.Add(worksheet.Cells[i][1].Value.ToString(), i); } var addressMapper = new AddressMapper(); var addressRepository = new AddressRepository(); var personMapper = new PersonMapper(); var personRepository = new PersonRepository(); var financialStateMapper = new FinancialStateMapper(); var financialStateRepository = new FinancialStateRepository(); var agrementMapper = new AgreementMapper(); var agreementRepository = new AgreementRepository(); var peselVerifier = new PeselVerifier(); for (int i = 2; i <= rows; i++) { var addressObject = addressMapper.MapAdress(worksheet, i, columnNamesWithIndex); var addressId = addressRepository.PushAddressesToDb(addressObject); var personObject = personMapper.MapPerson(worksheet, i, columnNamesWithIndex, addressId); var validPesel = peselVerifier.VerifyPesel(personObject.NationalIdentificationNumber); // validPesel -tutaj mam wartosc true albo false dla kazdego z peseli // dla ktorego robie walidacje w osobnej metodzie var personId = personRepository.PushPeopleToDb(personObject); var financialStateObject = financialStateMapper.MapFinancialState(worksheet, i, columnNamesWithIndex); var financialStateId = financialStateRepository.PushFinancialStatesToDb(financialStateObject); var agreementObject = agrementMapper.MapAgreement(worksheet, i, columnNamesWithIndex, personId, financialStateId); agreementRepository.PushAgreementsToDb(agreementObject); } }