Example #1
0
        public void CreateOrder_TwoInsertMethods_InsertMethodAreBeingExecuted()
        {
            var orderDataContext     = new OrderDataContext();
            var orderCommands        = new Mock <IOrderCommands>();
            var sqlConnectionFactory = new Mock <ISqlConnectionFactory>();
            var sqlConnection        = new Mock <IDbConnection>();
            var dbTransaction        = new Mock <IDbTransaction>();

            sqlConnection.Setup(e => e.BeginTransaction()).Returns(dbTransaction.Object);
            sqlConnectionFactory.Setup(e => e.GetSqlConnection(It.IsAny <string>())).Returns(sqlConnection.Object);
            OrderDataContext.SqlConnectionFactory = sqlConnectionFactory.Object;
            orderDataContext.OrderCommands        = orderCommands.Object;
            var order = new Order();


            orderDataContext.CreateOrder(order);


            orderCommands.Verify(e => e.AddOrder(It.IsAny <Order>(), It.IsAny <IDbConnection>()), Times.Exactly(1));
            orderCommands.Verify(e => e.AddOrderItems(It.IsAny <Order>(), It.IsAny <IDbConnection>()), Times.Exactly(1));
        }
Example #2
0
 public void CreateOrder(Order order)
 {
     _dbContext.CreateOrder(order);
 }