/// <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);
        }
Exemple #2
0
        public void should_execute_parameterized_select_statement()
        {
            var inMemoryDatabase = new InMemoryDatabase();

            inMemoryDatabase.Insert <Product>(new List <Product>
            {
                new Product()
            });

            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("SELECT * FROM Product where ProductId = @Id")));

            var parameterizedSelectStatement = new ParameterizedSelectStatement();

            parameterizedSelectStatement.Execute(inMemoryDatabase.OpenConnection(), loggerMock.Object);
        }