예제 #1
0
        public void ShouldReturnSnack()
        {
            List <Snack> result = new List <Snack>();

            result.Add(new Snack(1, "Hamburguer", 12));

            Mock <ISnackRepository> snackRepoMock = new Mock <ISnackRepository>();

            snackRepoMock.Setup(x => x.ListAll()).Returns(result);

            ISnackService service = new SnackService(snackRepoMock.Object);

            List <Snack> retorno = service.ListAll();

            Assert.Equal(result[0].Name, retorno[0].Name);
            Assert.True(retorno.Count == 1);

            snackRepoMock.VerifyAll();
        }
예제 #2
0
        public void shouldCreateNewInvoice()
        {
            List <Snack> result = new List <Snack>();

            result.Add(new Snack(1, "Hamburguer", 12));

            Mock <ISnackRepository> snackRepoMock = new Mock <ISnackRepository>();

            snackRepoMock.Setup(x => x.ListAll()).Returns(result);

            ISnackService snackService = new SnackService(snackRepoMock.Object);

            List <Snack> retorno = snackService.ListAll();

            IInvoiceService invoiceService = new InvoiceService();
            var             newInvoice     = invoiceService.createInvoice(retorno);

            Assert.Contains(retorno[0], newInvoice.snacks);
        }