コード例 #1
0
        public void Can_add_summary_package()
        {
            var customer = new Account {
                Id = Guid.NewGuid()
            }.
                Set(e => e.Name, "Temmy");
            var package = new cr953_package {
                Id = Guid.NewGuid()
            }
            .Set(e => e.cr953_monthlyprice, 100);

            var target =
                new cr953_subscription {
                Id = Guid.NewGuid()
            }
            .Set(e => e.cr953_customerid, customer.ToEntityReference())
            .Set(e => e.cr953_packageid, package.ToEntityReference())
            .Set(e => e.cr953_qty, 2);
            var test = new TestEvent <cr953_subscription>(customer, package);

            test.CreateEventCommand <CalculatePackageSummariesOnSubscriptionChange>(target);

            Assert.True(test.Db.Event.Created.Any());
            var added = test.Db.Event.Created[0].ToEntity <cr953_packagesummary>();

            Assert.Equal(200, added.GetValue(e => e.cr953_totalamount));
            Assert.Equal(customer.Id, added.Get(e => e.cr953_customerid).Id);
            Assert.Equal("Temmy Summary", added.Get(e => e.cr953_name));
        }
コード例 #2
0
        public void Can_execute_command_other_early_bound_generator()
        {
            var account = new Account {
                Id = Guid.NewGuid()
            }.Set(e => e.StateCode, Account.OptionSets.StateCode.Active);

            var test = new TestEvent <Account>(account);

            test.CreateEventCommand <AccountCommand>(null);

            Assert.NotNull(test.Db.Event.Deleted);
            Assert.Equal(account.Id, test.Db.Event.Deleted[0].Id);

            Assert.NotNull(test.Db.Event.Created);

            Assert.NotNull(test.Db.Event.Updated);
            Assert.Equal(test.Db.Event.Created[0].Id, test.Db.Event.Updated[0].Id);
        }
コード例 #3
0
        public void Can_execute_command_on_create()
        {
            var order = new new_order(Guid.NewGuid());

            var target = new new_orderdetail(Guid.NewGuid())
                         .Set(e => e.new_orderid, order.ToEntityReference())
                         .Set(e => e.new_quantity, 2)
                         .Set(e => e.new_priceperitem, 1500);

            var test = new TestEvent <new_orderdetail>(order);

            test.CreateEventCommand <CalculateTotalPrice>(target);
            var summaryRef = target.Get(e => e.new_orderdetailsummaryid);

            Assert.NotNull(summaryRef);
            var summary = test.Db.Event.Created[0].ToEntity <new_orderdetailsummary>();

            Assert.Equal(3000m, summary.Get(e => e.new_totalprice).Value);
        }
コード例 #4
0
        public void Can_execute_command_on_create()
        {
            var order = new Entity("new_order", Guid.NewGuid());

            var target = new Entity("new_orderdetail", Guid.NewGuid())
            {
                ["new_orderid"]      = order.ToEntityReference(),
                ["new_quantity"]     = 2,
                ["new_priceperitem"] = new Money(1500)
            };

            var test = new TestEvent(order);

            test.CreateEventCommand <CalculateTotalPrice>(target);
            var summaryRef = target.Get <EntityReference>("new_orderdetailsummaryid");

            Assert.NotNull(summaryRef);
            var summary = test.Db.Event.Created[0];

            Assert.Equal(3000m, summary.Get <Money>("new_totalprice").Value);
        }
コード例 #5
0
        public void Can_execute_command_for_retrieve()
        {
            var order        = new new_order(Guid.NewGuid()).Set(e => e.new_name, "TEST");
            var orderDetail1 = new new_orderdetail(Guid.NewGuid())
                               .Set(e => e.new_orderid, order.ToEntityReference())
                               .Set(e => e.new_priceperitem, 100)
                               .Set(e => e.new_quantity, 10);

            var orderDetail2 = new new_orderdetail(Guid.NewGuid())
                               .Set(e => e.new_orderid, order.ToEntityReference())
                               .Set(e => e.new_priceperitem, 10)
                               .Set(e => e.new_quantity, 10);

            var orderDetailSummary = new new_orderdetailsummary(Guid.NewGuid());

            var test = new TestEvent <new_orderdetailsummary>(order, orderDetail1, orderDetail2);

            test.CreateEventCommand <RetrieveTotalPrice>(orderDetailSummary);

            Assert.Equal(1100m, orderDetailSummary.GetValue(e => e.new_totalprice));
        }