Skip to content

Instantly share code, notes, and snippets.

View markwoodhall's full-sized avatar
🏠
Working from home

Mark Woodhall markwoodhall

🏠
Working from home
View GitHub Profile
namespace MSub.Domain.Tests.Subscriptions.for_Subscription
{
[TestFixture]
public class when_renewing_a_recurring_monthly_subscription : given.a_recurring_monthly_subscription_and_future_renewal_date
{
bool raisedSubscriptionRenewedEvent = false;
[TestFixtureSetUp]
public void because_of()
namespace MSub.Domain.Tests.Subscriptions.for_Subscription.given
{
public class a_recurring_monthly_subscription_and_future_renewal_date
{
protected ISubscription Subscription = new SubscriptionFactory().CreateSubscription(
SubscriptionType.Recurring, SubscriptionLength.Monthly, "Product-Ref"
);
protected DateTime RenewalDate = DateTime.Now.AddMonths(2);
public IFluentValidationBuilder<T> Then(Action execute, ExecuteThread options = ExecuteThread.Current)
{
var conditionsCopy = Conditions.ToList();
Func<T, bool> derived = f =>
{
if (conditionsCopy.All(c => _expressionBuilder.Invoke(_expressionBuilder.Compile(c.Condition), _fluentValidation.GetTarget())))
{
if (options == ExecuteThread.Current)
{
execute();
class OrderWorkflow
{
readonly IFluentWorkflowBuilder<OrderStatus> _workflow;
public OrderWorkflow(OrderStatus orderStatus)
{
_workflow = new FluentWorkflowFactory().CreateFor(orderStatus);
}
public IFluentWorkflowBuilder<OrderStatus> Configure()
validator
.When(f => f.Check(u => u.Age).IsLessThan(18))
.Check(u => u.ParentalConsent).IsEqualTo(true)
.Check(u => u.AgreedToTerms).IsEqualTo(true)
.When(f => f.Check(u => u.Age).IsGreaterThan(18))
.Check(u => u.AgreedToTerms).IsNotEqualTo(true);
@markwoodhall
markwoodhall / gist:4ac2789bc57981e52c11
Last active August 29, 2015 14:02
Assuming that watch-fn is a blocking call, for example, to a HTTP endpoint. This function can 'watch' the results and when they are different to the last iteration put them on a channel for consumers. Is there a better way to do this, I feel like I could use a go block instead of a future but believe there can be issues using a go block for bloc…
(defn- watch
[client watch-fn channel {:keys [wait]
:or {wait 500}}]
(let [keep-watching? (atom true)
f (future
(loop [last-value {}]
(let [latest (watch-fn)]
(if (and (not= last-value {})
(not= last-value latest))
(go (>! channel latest)))
(defproject ravendb-test "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.5.1"]
[clj-ravendb "0.4.0"]])
(require '[clj-ravendb.client :refer :all])
(def northwind (client "http://localhost:8080" "northwind"))
{
:replicated? false
:master-only-writes? true
:address "http://localhost:8080/Databases/northwind"
:replications ()
}