Exemplo n.º 1
0
        public void RegisterForMaternitySales_IsMale_ShouldFireRuleViolationEvent()
        {
            var rulesViolated = false;
            DomainEvent.Register<RuleViolationEvent>(e => rulesViolated = true);
            var customer = new Customer(new Name("John", "Doe"), Gender.Male);
            customer.RegisterForMaternitySale();

            Assert.IsTrue(rulesViolated);
        }
Exemplo n.º 2
0
        public void RegisterForMaternitySales_IsFemale_ShouldRegisterCustomer()
        {
            var isRegistered = false;
            var preferredCustomerService = new Mock<IPreferredCustomerService>();
            this.Container.Configure(c => c.For<IPreferredCustomerService>().Use(preferredCustomerService.Object));
            preferredCustomerService.Setup(s => s.RegisterForMaternitySale(It.IsAny<Customer>())).Callback(() => isRegistered = true);

            var customer = new Customer(new Name("Jane", "Doe"), Gender.Female);
            customer.RegisterForMaternitySale();

            Assert.IsTrue(isRegistered);
        }