public void you_can_check_order_status()
        {
            var result = new OrderRepository(Internet, Settings.BaseUrl).Status(NewOrder.Key);

            Assert.AreEqual(NewOrder.Key, result.Key, "Unexpected key returned");
            Assert.AreEqual(NewOrder.HasShipped, result.HasShipped, "Unexpected value for whether or not it has shipped");
            Assert.AreEqual(NewOrder.Events.First().Name, result.Events.First().Name, "Unexpected value for the first returned event");
        }
        public void you_can_get_a_product_made()
        {
            var shippingOptions = new ShippingOptionsRepository(Internet, Settings.BaseUrl).For(ExampleAddress, ExampleShippingInfo);
            var command = new OrderRepository(Internet, Settings.BaseUrl);

            var theFirstShippingOption = shippingOptions.Options[0];
            var reference = Guid.NewGuid().ToString();

            var order = command.Create(reference, theFirstShippingOption, ExampleShippingAddress, ExampleShippingInfo);

            Assert.AreEqual(ExampleProduct.Key, order.Products.First().Key, "Unexpected key returned");
            Assert.AreEqual("order_received", order.Events.First().Name, "Expected the returned order to have an order_created event");
        }
        public void to_get_a_product_made_you_must_supply_a_unique_reference()
        {
            var shippingOptions = new ShippingOptionsRepository(Internet, Settings.BaseUrl).For(ExampleAddress, ExampleShippingInfo);
            var command = new OrderRepository(Internet, Settings.BaseUrl);

            var theFirstShippingOption = shippingOptions.Options[0];
            var duplicateReference = Guid.NewGuid().ToString();

            Assert.DoesNotThrow(() =>
                command.Create(duplicateReference, theFirstShippingOption, ExampleShippingAddress, ExampleShippingInfo),
                "The first time a reference is used the order should be created successfully"
            );

            var theError = Assert.Throws<Exception>(() =>
                command.Create(duplicateReference, theFirstShippingOption, ExampleShippingAddress, ExampleShippingInfo)
            );

            Assert.That(theError.Message, Is.StringContaining("'Ref' must be unique"));
        }
        private Order CreateANewOrder()
        {
            var command = new OrderRepository(Internet, Settings.BaseUrl);

            var reference = Guid.NewGuid().ToString();

            return command.Create(reference, AnyShippingOption(), ExampleShippingAddress, ExampleShippingInfo);
        }
        public void you_can_get_the_list_of_orders()
        {
            var result = new OrderRepository(Internet, Settings.BaseUrl).FindAll();

            AssertTheOrderIsReturned(result, NewOrder.Reference);
        }
        public void you_can_get_a_single_order()
        {
            var result = new OrderRepository(Internet, Settings.BaseUrl).Find(NewOrder.Key);

            Assert.AreEqual(NewOrder.Key, result.Key, "Unexpected key returned");
        }
        private Order CreateANewOrder(Product product)
        {
            var command = new OrderRepository(Internet, Settings.BaseUrl);

            var reference = Guid.NewGuid().ToString();

            var shippingInfo = new ProductShippingInfo() { Key = product.Key, Quantity = 1};

            return command.Create(reference, AnyShippingOption(shippingInfo), ExampleShippingAddress, shippingInfo);
        }