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); }
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); }
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(); }
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); }
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); }
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); }
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); }
public SnackServiceTest() { _snackRepositoryMock = new Mock <ISnackRepository>(); _discountRepositoryMock = new Mock <IDiscountRepository>(); _snackService = new SnackService(_snackRepositoryMock.Object, _discountRepositoryMock.Object); }
public SnackServiceTest() { this.ingredientService = new IngredientService(); this.skackService = new SnackService(ingredientService); }
public HomeController(ILoggerFactory loggerFactory, SnaAPIService snackService) : base() { this.Logger = loggerFactory.CreateLogger("Nerdy.Controllers.Home"); this.SnackService = snackService; }
public SnacksController(SnackService service) { _service = service; }