public async Task WhenOrderIsActivateMembership_MemberShipIsActivated() { var order = new Order() { OrderType = OrderType.MembershipPurchase }; var activateMembershipItem = new MembershipItem() { Category = ItemCategory.Membership, Name = Constants.ItemNames.MembershipActivation, DefaultUnitPrice = 5, MembershipEmail = "*****@*****.**", MembershipId = Guid.NewGuid() }; var upgradeMembershipItem = new MembershipItem() { Category = ItemCategory.Membership, Name = Constants.ItemNames.MembershipUpgrade, DefaultUnitPrice = 5, MembershipEmail = "*****@*****.**", MembershipId = Guid.NewGuid(), MembershipClass = MembershipClass.Golden }; order.Add(activateMembershipItem, 1); order.Add(upgradeMembershipItem, 1); var sut = new MembershipPurchaseHandler(membershipRepositoryMock.Object, this.emailClientMock.Object); await sut.ProcessAsync(order); this.membershipRepositoryMock.Verify(x => x.ActivateMembership(activateMembershipItem.MembershipId), Times.Once); this.membershipRepositoryMock.Verify(x => x.UpgradeMembership(upgradeMembershipItem.MembershipId, upgradeMembershipItem.MembershipClass), Times.Once); }
public async Task WhenOrderMembershipEmailIsMissing_Throws() { var order = new Order() { OrderType = OrderType.MembershipPurchase }; var activateMembershipItem = new MembershipItem() { Category = ItemCategory.Membership, Name = Constants.ItemNames.MembershipActivation, DefaultUnitPrice = 5, MembershipEmail = string.Empty, MembershipId = Guid.NewGuid() }; order.Add(activateMembershipItem, 1); var sut = new MembershipPurchaseHandler(membershipRepositoryMock.Object, this.emailClientMock.Object); await Assert.ThrowsExceptionAsync <ArgumentNullException>(async() => await sut.ProcessAsync(order)); }