Ejemplo n.º 1
0
        private ICountriesOperations CreateTarget()
        {
            var countries = new CsvCountrieFileParser()
                            .Read(@"Countries.csv");

            return(new CountriesOperationsWithQueryable(countries));
        }
        private ICountriesOperations CreateTarget()
        {
            var countries = new CsvCountrieFileParser()
                            .Read(@"Countries.csv");

            return(new CountriesOperationsDB(session));
        }
Ejemplo n.º 3
0
        public void WhenReadingFileAndInsertingInDbWeGet245()
        {
            var repo   = new Repository <Country>(session);
            var parser = new CsvCountrieFileParser();

            var target = new CsvFileToDbTransformer(parser, repo);

            target.Execute(@"Countries.csv");

            var count = repo.GetAll().Count;

            Assert.AreEqual(245, count);
        }
Ejemplo n.º 4
0
        public void Initialize()
        {
            sessionFactory = new NhConfig(connectionString).Create();
            session        = sessionFactory.OpenSession();

            using (var command = session.Connection.CreateCommand())
            {
                command.CommandText = "delete Country";
                command.ExecuteNonQuery();
            }

            var repo   = new Repository <Country>(session);
            var parser = new CsvCountrieFileParser();

            var target = new CsvFileToDbTransformer(parser, repo);

            target.Execute(@"Countries.csv");
        }
        public void WhenInsertingAllIntoTableAllCountriesAreInTable()
        {
            var parser       = new CsvCountrieFileParser();
            var dbOperations = new NhRepository <Country>(session);

            var target = CreateTarget(parser, dbOperations);

            target.SaveCountriesInDatabase(@"Countries.csv");

            var expected = parser.Read(@"Countries.csv");

            var actural = dbOperations.GetAll();

            Assert.AreEqual(expected.Count, actural.Count);

            for (int i = 0; i < expected.Count; i++)
            {
                expected[i].AssertAreSame(actural[i]);
            }
        }
 private CountriesFromFieToDatabase CreateTarget(CsvCountrieFileParser parser, NhRepository <Country> dbOperations)
 {
     return(new CountriesFromFieToDatabase(parser, dbOperations));
 }