Example #1
0
        public void a_production_is_streamable_if_released()
        {
            var p = _productions.Insert(new { Title = "Test", Slug = "Test", Price = 12.00, Status = "released" });
            var c = _customers.Insert(new { Email = "*****@*****.**", First = "Test", Last = "User", StreamUntil = DateTime.Today.AddDays(2) });

            Assert.True(DigitalRights.CanStream(c, p));
        }
Example #2
0
        public void a_production_is_not_downloadable_if_not_released()
        {
            var p = _productions.Insert(new { Title = "Test", Slug = "Test", Price = 12.00 });
            var c = _customers.Insert(new { Email = "*****@*****.**", First = "Test", Last = "User" });

            Assert.IsFalse(DigitalRights.CanDownload(c, p));
        }
Example #3
0
        public void a_production_is_downloadable_if_released_and_user_eligible()
        {
            var p = _productions.Insert(new { Title = "Test", Slug = "Test", Price = 12.00, Status = "released" });
            var c = _customers.Insert(new { Email = "*****@*****.**", First = "Test", Last = "User", DownloadUntil = DateTime.Today.AddDays(1) });

            Assert.True(DigitalRights.CanDownload(c, p));
        }
Example #4
0
 public void monthly_order_should_bump_users_stream()
 {
     customer.StreamUntil = DateTime.Today.AddYears(-1);
     Assert.False(DigitalRights.CanStream(customer, production));
     MonthlyOrder();
     DigitalRights.AuthorizeOrder(customer, order);
     Assert.Greater(DateTime.Today.AddDays(25), customer.StreamUntil);
     Assert.True(DigitalRights.CanStream(customer, production));
 }
Example #5
0
 public void customer_cant_download_and_stream_if_production_revoked()
 {
     AssignRights();
     Assert.True(DigitalRights.CanDownload(customer, production));
     Assert.True(DigitalRights.CanStream(customer, production));
     DigitalRights.Revoke(customer, production);
     Assert.False(DigitalRights.CanDownload(customer, production));
     Assert.False(DigitalRights.CanStream(customer, production));
 }
Example #6
0
 public void production_order_should_allow_access_forever()
 {
     //reset
     Massive.DB.Current.Execute("DELETE FROM Customers_Productions");
     Assert.False(DigitalRights.CanDownload(customer, production));
     Assert.False(DigitalRights.CanStream(customer, production));
     ProductOrder();
     DigitalRights.AuthorizeOrder(customer, order);
     Assert.True(DigitalRights.CanDownload(customer, production));
     Assert.True(DigitalRights.CanStream(customer, production));
 }
Example #7
0
 public void yearly_order_should_bump_users_stream()
 {
     //reset
     customer.StreamUntil   = DateTime.Today.AddYears(-2);
     customer.DownloadUntil = DateTime.Today.AddYears(-2);
     Assert.False(DigitalRights.CanDownload(customer, production));
     Assert.False(DigitalRights.CanStream(customer, production));
     AnnualOrder();
     DigitalRights.AuthorizeOrder(customer, order);
     Assert.Greater(DateTime.Today.AddMonths(11), customer.StreamUntil);
     Assert.Greater(DateTime.Today.AddMonths(11), customer.DownloadUntil);
     Assert.True(DigitalRights.CanDownload(customer, production));
     Assert.True(DigitalRights.CanStream(customer, production));
 }
Example #8
0
        public ActionResult Receiver()
        {
            try {
                //this is a ping from Shopify, record the order...
                var     json     = this.ReadJson();
                var     newOrder = System.Web.Helpers.Json.Decode(json);
                dynamic order    = _orders.CreateFromPing(newOrder);

                //tell Customers we just received an Order
                var customer = _customers.OrderReived(order);

                //Give them rights to the bits...
                DigitalRights.AuthorizeOrder(customer, order);
            } catch (Exception x) {
                Logger.LogFatal(x);

                //rethrow
                throw x;
            }
            //if all worked out, return a 200
            //if something failed we've logged it - and Shopify will keep sending until we return 200...
            return(Content("OK"));
        }
Example #9
0
 public void customer_can_download_and_stream_if_production_authorized()
 {
     AssignRights();
     Assert.True(DigitalRights.CanDownload(customer, production));
     Assert.True(DigitalRights.CanStream(customer, production));
 }
Example #10
0
 public void customer_cannot_download_if_stream_date_invalid()
 {
     customer.DownloadUntil = DateTime.Today.AddDays(-30);
     Assert.False(DigitalRights.CanDownload(customer, production));
 }
Example #11
0
 public void customer_can_stream_if_stream_date_valid()
 {
     customer.StreamUntil = DateTime.Today.AddDays(30);
     Assert.True(DigitalRights.CanStream(customer, production));
 }
Example #12
0
 void AssignRights()
 {
     DigitalRights.Authorize(customer, production);
 }