public void PutInvoiceUpdatesRepository()
        {
            //// Arrange
            Guid key = Guid.NewGuid();
            bool wasCalled = false;
            int id = 1;

            Invoice invoice = CreateFakeInvoice(id, key);

            var MockInvoiceService = new Mock<IInvoiceService>();
            MockInvoiceService.Setup(cs => cs.Save(invoice, It.IsAny<bool>())).Callback(() => wasCalled = true);

            MerchelloContext merchelloContext = GetMerchelloContext(MockInvoiceService.Object);

            InvoiceApiController ctrl = new InvoiceApiController(merchelloContext, tempUmbracoContext);
            ctrl.Request = new HttpRequestMessage();
            ctrl.Request.Properties.Add(HttpPropertyKeys.HttpConfigurationKey, new HttpConfiguration());

            //// Act
            HttpResponseMessage response = ctrl.PutInvoice(invoice);

            //// Assert
            Assert.AreEqual(System.Net.HttpStatusCode.OK, response.StatusCode);

            Assert.True(wasCalled);
        }
        /// <summary>
        /// Test to verify that the proper error response is returned on an error
        /// </summary>
        //[Test]
        public void PutInvoiceReturns500WhenRepositoryUpdateReturnsError()
        {
            //// Arrange
            Guid key = Guid.NewGuid();
            int id = 1;

            Invoice invoice = CreateFakeInvoice(id, key);

            var MockInvoiceService = new Mock<IInvoiceService>();
            MockInvoiceService.Setup(cs => cs.Save(invoice, It.IsAny<bool>())).Throws<InvalidOperationException>();

            MerchelloContext merchelloContext = GetMerchelloContext(MockInvoiceService.Object);

            InvoiceApiController ctrl = new InvoiceApiController(merchelloContext, tempUmbracoContext);
            ctrl.Request = new HttpRequestMessage();
            ctrl.Request.Properties.Add(HttpPropertyKeys.HttpConfigurationKey, new HttpConfiguration());

            //// Act
            HttpResponseMessage response = ctrl.PutInvoice(invoice);

            //// Assert
            Assert.AreEqual(System.Net.HttpStatusCode.NotFound, response.StatusCode);
        }