public void Can_delete_subcription() { var customer = new Account { Id = Guid.NewGuid() }; var package = new cr953_package { Id = Guid.NewGuid() } .Set(e => e.cr953_monthlyprice, 100); var packageSummary = new cr953_packagesummary { Id = Guid.NewGuid() } .Set(e => e.cr953_customerid, customer.ToEntityReference()) .Set(e => e.cr953_totalamount, 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, 1) .Set(e => e.cr953_total, 100); var test = new TestEvent <cr953_subscription>(target, customer, package, packageSummary); test.DeleteEventCommand <CalculatePackageSummariesOnSubscriptionChange>(target.ToEntityReference()); Assert.True(test.Db.Event.Updated.Any()); var updated = test.Db.Event.Updated[0].ToEntity <cr953_packagesummary>(); Assert.Equal(packageSummary.Id, updated.Id); Assert.Equal(customer.Id, updated.Get(e => e.cr953_customerid).Id); Assert.Equal(0, updated.GetValue(e => e.cr953_totalamount)); }
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)); }