Ejemplo n.º 1
0
        public void DeleteInvoiceCallsRepositoryRemove()
        {
            //// Arrange
            Guid key = Guid.NewGuid();

            int removedId = 0;

            int     id      = 1;
            Invoice invoice = CreateFakeInvoice(id, key);

            var MockInvoiceService = new Mock <IInvoiceService>();

            MockInvoiceService.Setup(cs => cs.Delete(invoice, It.IsAny <bool>())).Callback <IInvoice, bool>((p, b) => removedId = p.Id);
            MockInvoiceService.Setup(cs => cs.GetById(1)).Returns(invoice);

            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.Delete(id);

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