コード例 #1
0
ファイル: CustomerRules.cs プロジェクト: divyang4481/REM
        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);
        }
コード例 #2
0
ファイル: CustomerFactory.cs プロジェクト: divyang4481/REM
        public Customer CreateCustomer(Name name, Gender gender, bool isPreferred = false)
        {
            var customer = new Customer(name, gender, isPreferred);

            var ruleEngine = RuleEngine<Customer>.CreateTypedRuleEngine();
            ruleEngine.ExecuteRuleSet(customer, "CustomerCreationRules");

            return customer;
        }
コード例 #3
0
ファイル: CustomerRules.cs プロジェクト: divyang4481/REM
        public void Rename_GivenSameName_ShouldFireRuleViolation()
        {
            var rulesViolated = false;
            DomainEvent.Register<RuleViolationEvent>(e => rulesViolated = true);

            var customer = new Customer(new Name("John", "Doe"), Gender.Male);
            customer.Rename(new Name("John", "Doe"));

            Assert.IsTrue(rulesViolated);
        }
コード例 #4
0
ファイル: CustomerRules.cs プロジェクト: divyang4481/REM
        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);
        }