public NewParentCreatedEvent(Parent parent) { if (parent == null) { throw new ArgumentNullException("parent"); } Parent = parent; }
public void SetUp() { parent = new Parent("Mike Hadlow", "*****@*****.**", "pwd"); child = parent.CreateChild("Leo", "leohadlow", "xxx"); somebodyElse = new Parent("John Robinson", "*****@*****.**", "pwd"); somebodyElsesChild = somebodyElse.CreateChild("Jim", "jimrobinson", "yyy"); }
public IEnumerable<Child> GetChildrenOf(Parent parent) { if (parent == null) { throw new ArgumentNullException("parent"); } var childIds = parent.Children.Select(x => x.ChildId).ToArray(); return session.Load<Child>(childIds).AsEnumerable(); }
public void AcceptCashFromParent(Parent parent, decimal amount, string description) { var insufficientFundsMessage = string.Format( "You can not withdraw {0} because {1}'s account only has {2}", amount.ToString("c"), Name, Account.Balance.ToString("c")); WithdrawInternal(parent, amount, description, insufficientFundsMessage); }
public void WithdrawCashFromParent(Parent parent, decimal amount, string description) { var insufficientFundsMessage = string.Format( "You can not withdraw {0} because you only have {1} in your account", amount.ToString("c"), Account.Balance.ToString("c")); WithdrawInternal(parent, amount, description, insufficientFundsMessage); parent.SendMessage(string.Format("{0} would like to withdraw {1}", Name, amount.ToString("c"))); }
public void WithdrawCashFromParent(Parent parent, decimal amount, string description) { var insufficientFundsMessage = string.Format( ResourceMessages.FormatCanNotWithdraw, amount.ToString("c"), Account.Balance.ToString("c")); WithdrawInternal(parent, amount, description, insufficientFundsMessage); parent.SendMessage(string.Format(ResourceMessages.FormatWouldLikeToWithdraw, Name, amount.ToString("c"))); }
public void AcceptCashFromParent(Parent parent, decimal amount, string description) { var insufficientFundsMessage = string.Format( ResourceMessages.FormatCanNotWithdraw2, amount.ToString("c"), Name, Account.Balance.ToString("c")); WithdrawInternal(parent, amount, description, insufficientFundsMessage); }
public void Parent_should_raise_an_event_when_created() { NewParentCreatedEvent newParentCreatedEvent = null; using(DomainEvent.TestWith(e => { newParentCreatedEvent = (NewParentCreatedEvent)e; })) { var parent = new Parent("Dad", "*****@*****.**", "xxx").Initialise(); newParentCreatedEvent.ShouldNotBeNull(); newParentCreatedEvent.Parent.ShouldBeTheSameAs(parent); } }
string GetChildId() { using (var session = store.OpenSession()) { var parent = new Parent("Mike Hadlow", "*****@*****.**", "yyy"); var child = parent.CreateChild("Leo", "leohadlow", "xxx"); session.Store(child); session.SaveChanges(); return child.Id; } }
public void SetUp() { parent = new Parent("Dad", "*****@*****.**", "xxx"); child = parent.CreateChild("Leo", "leohadlow", "yyy"); parent.MakePaymentTo(child, 10.00M); somebodyElsesParent = new Parent("Not Dad", "*****@*****.**", "zzz"); // make sure these tests pass on non en-GB machines Thread.CurrentThread.CurrentCulture = new CultureInfo("en-GB"); DomainEvent.TurnOff(); }
string GetParentId(string name) { string parentId; using (var session = store.OpenSession()) { var parent = new Parent(name: "Mike Hadlow", userName: string.Format("{0}@yahoo.com", name), password: "******"); session.Store(parent); session.SaveChanges(); parentId = parent.Id; } return parentId; }
void WithdrawInternal(Parent parent, decimal amount, string description, string insufficientFundsMessage) { if (parent == null) { throw new ArgumentNullException(ResourceMessages.MissingParentParameter); } if (description == null) { throw new ArgumentNullException(ResourceMessages.MissingDescriptionParameter); } if (!parent.HasChild(this)) { throw new CashWithdrawException(ResourceMessages.NotYourParent); } if (amount > Account.Balance) { throw new CashWithdrawException(insufficientFundsMessage); } Account.AddTransaction(description, -amount); }
void CreateNewParentIfTheyDontAlreadyExist(IAuthenticationResponse response) { var userId = Model.User.UserIdFromUserName(response.ClaimedIdentifier); if (userService.GetUser(userId) != null) return; var parent = new Parent(response.FriendlyIdentifierForDisplay, response.ClaimedIdentifier, "todo"); userService.SaveUser(parent); }
public bool AreNullOrNotRelated(Parent parent, Child child) { if (parent == null || child == null) return true; if (!parent.HasChild(child)) { throw new TardisBankException("'{0}' is not a child of '{1}'", child.UserName, parent.UserName); } return false; }
public void SetUp() { store = NewDocumentStore(); parent = new Parent("Dad", "*****@*****.**", "xxx"); }
public void ParentShouldNotBeActiveWhenCreated() { User parent = new Parent("Dad", "*****@*****.**", "xxx"); parent.IsActive.ShouldBeFalse(); }
public void Child_should_be_active_when_created() { User child = new Parent("Dad", "*****@*****.**", "xxx").CreateChild("Leo", "leoahdlow", "bbb"); child.IsActive.ShouldBeTrue(); }