Beispiel #1
0
        public void Get_WhenCalled_ReturnsInvoice()
        {
            //Act
            var okResult = _controller.Get();

            //Assert
            Assert.IsType <JsonResult>(okResult.Result);
        }
        public async Task Values_Get_Specific()
        {
            // Arrange
            var controller = new InvoiceController(new InvoiceRepository(inv));

            // Act
            var result = await controller.Get();

            // Assert
            var okResult = result.Should().BeOfType <OkObjectResult>().Subject;
            var invoice  = okResult.Value.Should().BeAssignableTo <Invoice>().Subject;

            invoice.Id.Should().Be("");
        }
        public async Task Invoice_Get_All()
        {
            // Arrange
            var controller = new InvoiceController(new InvoiceRepository(this.inv));

            // Act
            var result = await controller.Get();

            // Assert
            var okResult = result.Should().BeOfType <OkObjectResult>().Subject;
            var inv      = okResult.Value.Should().BeAssignableTo <IEnumerable <Invoice> >().Subject;

            inv.Count().Should().Be(50);
        }
Beispiel #4
0
        public void GetById()
        {
            var invoiceStore = MockRepository.GenerateMock <IInvoiceStore>();

            invoiceStore.Stub(istore => istore.FindInvoiceById(1)).Return(new Invoice()
            {
                Id            = 1,
                InvoiceNumber = "INV-0001",
                LineItems     = new List <Invoice.LineItem>
                {
                    new Invoice.LineItem
                    {
                        Description = "Pizza",
                        Count       = 1,
                        PriceEach   = 12.99f,
                        LineTotal   = 12.99f
                    }
                }
            });

            InvoiceController ic = new InvoiceController(invoiceStore);
            Invoice           i  = ic.Get(1);
        }