Example #1
0
        /// <summary>
        /// Initializes a new instance of the  <see cref="SqlBulkRepositoryFacts"/> class.
        /// </summary>
        public SqlBulkRepositoryFacts()
        {
            this.fixture = new Fixture();

            this.bulkCopy          = Substitute.For <IBulkCopy>();
            this.connectionFactory = Substitute.For <IDbConnectionFactory>();

            this.columnMappings = new Dictionary <string, string>()
            {
                { "Id", "Id" },
                { "Name", "Name" },
                { "Created", "Created" }
            };

            this.bulkRepository = new SqlBulkRepository <FakeEntity>(
                (c, o) => this.bulkCopy,
                TestTableName,
                this.connectionFactory,
                this.columnMappings);

            this.data    = this.fixture.CreateMany <FakeEntity>();
            this.context = Substitute.For <ITaskContext>();
        }
Example #2
0
        /// <summary>
        /// Builds a task used to load the date dimension.
        /// </summary>
        /// <returns>A task used to load the date dimension.</returns>
        public ITask Build()
        {
            var dateTarget = new SqlBulkRepository <DateValue>(
                "dbo.DimDate",
                this.targetFactory,
                new Dictionary <string, string>()
            {
                { "Key", "DateKey" },
                { "Value", "FullDateAlternateKey" },
                { "DayNumberOfWeek", "DayNumberOfWeek" },
                { "EnglishDayNameOfWeek", "EnglishDayNameOfWeek" },
                { "SpanishDayNameOfWeek", "SpanishDayNameOfWeek" },
                { "FrenchDayNameOfWeek", "FrenchDayNameOfWeek" },
                { "DayNumberOfMonth", "DayNumberOfMonth" },
                { "DayNumberOfYear", "DayNumberOfYear" },
                { "WeekNumberOfYear", "WeekNumberOfYear" },
                { "EnglishMonthName", "EnglishMonthName" },
                { "SpanishMonthName", "SpanishMonthName" },
                { "FrenchMonthName", "FrenchMonthName" },
                { "MonthNumberOfYear", "MonthNumberOfYear" },
                { "CalendarQuarter", "CalendarQuarter" },
                { "CalendarYear", "CalendarYear" },
                { "CalendarSemester", "CalendarSemester" },
                { "FiscalQuarter", "FiscalQuarter" },
                { "FiscalYear", "FiscalYear" },
                { "FiscalSemester", "FiscalSemester" }
            });

            var dateSource = DateSource.GetDateSequence(new DateTime(2005, 01, 01), new DateTime(2010, 12, 31));

            return(new SimpleDataflowTask <DateTime, DateValue>(
                       "Load date dimension",
                       dateSource,
                       s => new DateValue(s),
                       dateTarget));
        }
Example #3
0
        /// <summary>
        /// Initializes a new instance of the  <see cref="SqlBulkRepositoryFacts"/> class.
        /// </summary>
        public SqlBulkRepositoryFacts()
        {
            this.fixture = new Fixture();

            this.bulkCopy = Substitute.For<IBulkCopy>();
            this.connectionFactory = Substitute.For<IDbConnectionFactory>();

            this.columnMappings = new Dictionary<string, string>()
            {
                { "Id", "Id" },
                { "Name", "Name" },
                { "Created", "Created" }
            };

            this.bulkRepository = new SqlBulkRepository<FakeEntity>(
                (c, o) => this.bulkCopy,
                TestTableName,
                this.connectionFactory,
                this.columnMappings);

            this.data = this.fixture.CreateMany<FakeEntity>();
            this.context = Substitute.For<ITaskContext>();
        }
Example #4
0
        /// <summary>
        /// Sets up the target repository.
        /// </summary>
        /// <param name="tableName">Name of the table.</param>
        /// <param name="connectionFactory">The connection factory.</param>
        /// <param name="columnMappings">The column mappings.</param>
        /// <returns>This <c>SimpleDataflowBuilder</c> instance for fluent calls.</returns>
        public SimpleDataflowBuilder <T> BulkLoad(string tableName, IDbConnectionFactory connectionFactory, IDictionary <string, string> columnMappings)
        {
            this.target = new SqlBulkRepository <T>(tableName, connectionFactory, columnMappings);

            return(this);
        }
Example #5
0
        /// <summary>
        /// Builds a task used to load the date dimension.
        /// </summary>
        /// <returns>A task used to load the date dimension.</returns>
        public ITask Build()
        {
            var dateTarget = new SqlBulkRepository<DateValue>(
                "dbo.DimDate",
                this.targetFactory,
                new Dictionary<string, string>()
                {
                    { "Key", "DateKey" },
                    { "Value", "FullDateAlternateKey" },
                    { "DayNumberOfWeek", "DayNumberOfWeek" },
                    { "EnglishDayNameOfWeek", "EnglishDayNameOfWeek" },
                    { "SpanishDayNameOfWeek", "SpanishDayNameOfWeek" },
                    { "FrenchDayNameOfWeek", "FrenchDayNameOfWeek" },
                    { "DayNumberOfMonth", "DayNumberOfMonth" },
                    { "DayNumberOfYear", "DayNumberOfYear" },
                    { "WeekNumberOfYear", "WeekNumberOfYear" },
                    { "EnglishMonthName", "EnglishMonthName" },
                    { "SpanishMonthName", "SpanishMonthName" },
                    { "FrenchMonthName", "FrenchMonthName" },
                    { "MonthNumberOfYear", "MonthNumberOfYear" },
                    { "CalendarQuarter", "CalendarQuarter" },
                    { "CalendarYear", "CalendarYear" },
                    { "CalendarSemester", "CalendarSemester" },
                    { "FiscalQuarter", "FiscalQuarter" },
                    { "FiscalYear", "FiscalYear" },
                    { "FiscalSemester", "FiscalSemester" }
                });

            var dateSource = DateSource.GetDateSequence(new DateTime(2005, 01, 01), new DateTime(2010, 12, 31));

            return new SimpleDataflowTask<DateTime, DateValue>(
                "Load date dimension",
                dateSource,
                s => new DateValue(s),
                dateTarget);
        }