public void FactoryGetDirectActivityGeneric()
        {
            // Don't handle dispose as it'll try and connect to a SQL server that may not be there.
            var direct = ActivityFactory.NewDirectActivity <TestActivity>(_dummyConnectionString);

            // We have default stuff
            ActivityCheckCommon(direct);
        }
        public void FactoryGetDirectActivityWithId()
        {
            var activityId = Guid.NewGuid().ToString();
            var activity   = (TestActivity)ActivityFactory.NewDirectActivity(typeof(TestActivity), _dummyConnectionString, activityId);

            ActivityCheckCommon(activity);

            Assert.AreEqual(activityId, activity.ActivityId);
        }
        public void FactoryGetDirectActivityGenericWithId()
        {
            var activityId = Guid.NewGuid().ToString();

            // Don't handle dispose as it'll try and connect to a SQL server that may not be there.
            var direct = ActivityFactory.NewDirectActivity <TestActivity>(_dummyConnectionString, activityId);

            ActivityCheckCommon(direct);

            Assert.AreEqual(activityId, direct.ActivityId, "ActivityId is not as supplied.");
        }
Example #4
0
        /// <summary>
        /// Fulfil a previous request
        /// </summary>
        /// <param name="correlationToken">Correlation token from <see cref="ReceiveRequest(int)"/></param>
        /// <param name="quantity">Number of units to fulfill</param>
        public void FulfilRequests(string correlationToken, int quantity)
        {
            // Grab an instance of our fulfilment activity using a factory
            using (FulfilledRequests request = ActivityFactory.NewDirectActivity <FulfilledRequests>(_connectionString))
            {
                // Populate our business data
                request.DateSent = DateTime.Now;
                request.Quantity = quantity;

                // Trigger the BAM infrastructure to commit this record to the db
                request.BeginActivity();
                // Additionally, link this activity to the previous actvitiy we had
                request.AddReferenceToAnotherActivity("Received Requests", correlationToken);
                request.CommitActivity();
                request.EndActivity();
            }
        }
Example #5
0
        /// <summary>
        /// Receive a request to process some units
        /// </summary>
        /// <param name="units">Number of units requested</param>
        /// <returns>Correlation token</returns>
        public string ReceiveRequest(int units)
        {
            // Grab an instance of our received activity using a factory to request a Direct event stream
            using (ReceivedRequests request = ActivityFactory.NewDirectActivity <ReceivedRequests>(_connectionString))
            {
                // Populate our business data
                request.Units        = units;
                request.DataReceived = DateTime.Now;

                // Trigger the BAM infrastructure to commit this record to the db
                request.BeginActivity();
                request.CommitActivity();
                request.EndActivity();

                // Return the generated activity ID as a token for later relationships
                return(request.ActivityId);
            }
        }
        public void FactoryGetDirectActivity()
        {
            var activity = (TestActivity)ActivityFactory.NewDirectActivity(typeof(TestActivity), _dummyConnectionString);

            ActivityCheckCommon(activity);
        }