Exemplo n.º 1
0
        public void ADD_ShouldReturnSnackAdded()
        {
            //Arrange
            int x     = 7;
            var snack = new Snack()
            {
                SnackId = x, Name = "M&M", Size = "Small", Cost = 3.50
            };
            var options = new DbContextOptionsBuilder <CinemaDbContext>()
                          .UseInMemoryDatabase(databaseName: "ADD_ShouldReturnSnackAdded")
                          .UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking)
                          .Options;

            var context = new CinemaDbContext(options);

            SeedSnacks(context);

            var service = new SnackService(context);

            //Act
            var result = service.Add(snack);


            //Assert
            Assert.True(result);
        }
Exemplo n.º 2
0
        public void UPDATE_ShouldReturnNewName()
        {
            //Arrange
            var x     = 6;
            var Snack = new Snack {
                SnackId = 7, Name = "Pizza", Size = "Large", Cost = 14.50
            };

            var options = new DbContextOptionsBuilder <CinemaDbContext>()
                          .UseInMemoryDatabase(databaseName: "UPDATE_ShouldReturnNewName")
                          .Options;

            var context = new CinemaDbContext(options);

            SeedSnacks(context);

            var service = new SnackService(context);

            //Act
            var result = service.Update(x, Snack);


            //Assert
            Assert.Equal(result.Name, Snack.Name);
        }
Exemplo n.º 3
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();
        }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
0
        public void GETALL_ShouldReturnAllSnacks()
        {
            //Arrange
            var options = new DbContextOptionsBuilder <CinemaDbContext>()
                          .UseInMemoryDatabase(databaseName: "GETALL_ShouldReturnAllSnacks")
                          .UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking)
                          .Options;

            var context = new CinemaDbContext(options);

            SeedSnacks(context);

            var service = new SnackService(context);

            //Act
            var result = service.SelectAll().ToList();


            //Assert
            Assert.Equal(6, result.Count);
        }
Exemplo n.º 6
0
        public void GET_ShouldReturnSnackById2()
        {
            //Arrange
            int x       = 5;
            var options = new DbContextOptionsBuilder <CinemaDbContext>()
                          .UseInMemoryDatabase(databaseName: "GET_ShouldReturnSnackById5")
                          .UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking)
                          .Options;

            var context = new CinemaDbContext(options);

            SeedSnacks(context);

            var service = new SnackService(context);

            //Act
            var result = service.Select(x);


            //Assert
            Assert.Equal(result.SnackId, x);
        }
Exemplo n.º 7
0
        public void DELETE_ShouldReturnOneSnackLess()
        {
            //Arrange
            int x       = 1;
            var options = new DbContextOptionsBuilder <CinemaDbContext>()
                          .UseInMemoryDatabase(databaseName: "DELETE_ShouldReturnOneSnackLess")
                          .Options;


            var context = new CinemaDbContext(options);

            SeedSnacks(context);

            var service = new SnackService(context);


            //Act
            var result = service.Delete(x);


            //Assert
            Assert.True(result);
        }
Exemplo n.º 8
0
 public SnackServiceTest()
 {
     _snackRepositoryMock    = new Mock <ISnackRepository>();
     _discountRepositoryMock = new Mock <IDiscountRepository>();
     _snackService           = new SnackService(_snackRepositoryMock.Object, _discountRepositoryMock.Object);
 }
Exemplo n.º 9
0
 public SnackServiceTest()
 {
     this.ingredientService = new IngredientService();
     this.skackService      = new SnackService(ingredientService);
 }
Exemplo n.º 10
0
 public HomeController(ILoggerFactory loggerFactory, SnaAPIService snackService) : base()
 {
     this.Logger       = loggerFactory.CreateLogger("Nerdy.Controllers.Home");
     this.SnackService = snackService;
 }
Exemplo n.º 11
0
 public SnacksController(SnackService service)
 {
     _service = service;
 }