예제 #1
0
        public void should_execute_simple_insert_statement()
        {
            var mockRepo   = new MockRepository(MockBehavior.Default);
            var loggerMock = mockRepo.Create <ILogger>();

            loggerMock.Setup(a => a.WriteLine(It.IsAny <string>()))
            .Callback <string>(msg => Assert.IsTrue(
                                   msg.Contains(@"INSERT Person(BusinessEntityId, PersonType, Suffix, FirstName, MiddleName, LastName, Title) 
                                                values(@pBusinessEntityId, @pType, @suffix, @fName, @mName, @lName, @title)") ||
                                   msg.Contains(@"insert BusinessEntity (rowguid, ModifiedDate) Output Inserted.BusinessEntityId values(")
                                   ));

            var simpleInsertStatement = new SimpleInsertStatement();

            simpleInsertStatement.Execute(sqlConnection, loggerMock.Object, new object[] { person });
        }
예제 #2
0
        /// <summary>
        /// Gets the sample.
        /// </summary>
        /// <param name="sampleType">Type of the sample.</param>
        /// <returns></returns>
        public static ISamples GetSample(SampleTypes sampleType)
        {
            ISamples sample = null;

            switch (sampleType)
            {
            case SampleTypes.SimpleSelectStatement:
                sample = new SimpleSelectStatement();
                break;

            case SampleTypes.SimpleSelectStatementWithDynamicEntities:
                sample = new SimpleSelectStatementWithDynamicEntities();
                break;

            case SampleTypes.MultiMappingSingleEntity:
                sample = new MultiMappingSelectStatement();
                break;

            case SampleTypes.MultiMappingChildEntities:
                sample = new MultiMappingOneToManyRelationSelectStatement();
                break;

            case SampleTypes.ParameterizedSelectStatement:
                sample = new ParameterizedSelectStatement();
                break;

            case SampleTypes.MultipleQueries:
                sample = new MultipleQueries();
                break;

            case SampleTypes.SimpleStoredProcedure:
                sample = new SimpleStoredProcedure();
                break;

            case SampleTypes.SimpleInsertStatement:
                sample = new SimpleInsertStatement();
                break;

            default:
                break;
            }

            return(sample);
        }