public async Task ReturnCorrectTheatre() { var options = Utilities.GetOptions(nameof(DeleteTheatreTest)); var testTheatre02 = new Theatre() { Id = Guid.NewGuid(), Name = "TestName", AboutInfo = "TestAboutInfo", Location = "TestLocation", Phone = "0896663554", }; using (var assertContext = new TheatreContext(options)) { await assertContext.Theatres.AddAsync(testTheatre02); await assertContext.SaveChangesAsync(); } using (var assertContext = new TheatreContext(options)) { var sut = new TheatreService(assertContext); var result = await sut.DeleteTheatreAsync(testTheatre02.Id); Assert.IsInstanceOfType(result, typeof(Theatre)); Assert.AreEqual(testTheatre02.Id, result.Id); Assert.AreEqual(testTheatre02.Name, result.Name); Assert.AreEqual(testTheatre02.AboutInfo, result.AboutInfo); Assert.AreEqual(testTheatre02.Location, result.Location); Assert.AreEqual(testTheatre02.Phone, result.Phone); } }
public TheatrePlaysViewModel() { Title = "Театр"; PlayTreshold = 4; pageNumber = 1; theatreService = new TheatreService(); TheatrePlays = new ObservableCollection <TheatrePlay>(); FilteredPlays = new ObservableCollection <TheatrePlay>(); LoadPlaysCommand = new Command(async() => await ExecuteLoadPlaysCommand()); PlaysTresholdReachedCommand = new Command(async() => await PlaysTresholdReached()); RefreshPlaysCommand = new Command(async() => { await ExecuteLoadPlaysCommand(); pageNumber = 1; PlayTreshold = 4; IsRefreshing = false; }); MessagingCenter.Subscribe <TheatrePlaysPage, TextChangedEventArgs>(this, "FilterPlays", (obj, e) => { var filterText = e.NewTextValue; var filtered = TheatrePlays.Where(item => item.Title.ToLower().Contains(filterText.ToLower())); if (filtered != null) { FilteredPlays = new ObservableCollection <TheatrePlay>(); FilteredPlays.AddRange(filtered); } else { FilteredPlays = new ObservableCollection <TheatrePlay>(); } }); }
public async Task DeleteTheatreTest() { //Arrange var options = Utilities.GetOptions(nameof(DeleteTheatreTest)); var testTheatre00 = new Theatre() { Id = Guid.NewGuid(), Name = "TestName", AboutInfo = "TestAboutInfo", Location = "TestLocation", Phone = "0896663554", }; using (var assertContext = new TheatreContext(options)) { await assertContext.Theatres.AddAsync(testTheatre00); await assertContext.SaveChangesAsync(); var serviceTest = new TheatreService(assertContext); var result = await serviceTest.DeleteTheatreAsync(testTheatre00.Id); await assertContext.SaveChangesAsync(); } using (var assertContext = new TheatreContext(options)) { var result = await assertContext.Theatres.FirstAsync(); Assert.AreEqual(true, result.IsDeleted); } }
public async Task ValidTheatre() { //Arrange var options = Utilities.GetOptions(nameof(ValidTheatre)); var testTheatre = new Theatre() { Id = Guid.NewGuid(), Name = "TestName", AboutInfo = "TestAboutInfo", Location = "TestLocation", Phone = "0896663554", }; using (var assertContext = new TheatreContext(options)) { var sut = new TheatreService(assertContext); var result = await sut.CreateTheatreAsync(testTheatre); Assert.IsInstanceOfType(result, typeof(Theatre)); Assert.AreEqual(testTheatre.Name, result.Name); Assert.AreEqual(testTheatre.AboutInfo, result.AboutInfo); Assert.AreEqual(testTheatre.Location, result.Location); Assert.AreEqual(testTheatre.Phone, result.Phone); } }
public async Task ThorwWhenNoTheatreFound() { var options = Utilities.GetOptions(nameof(ReturnCorrectTheatre)); var secondId = Guid.NewGuid(); var testTheatre05 = new Theatre() { Id = Guid.NewGuid(), Name = "TestName", AboutInfo = "TestAboutInfo", Location = "TestLocation", Phone = "0896663554", }; using (var assertContext = new TheatreContext(options)) { await assertContext.Theatres.AddAsync(testTheatre05); await assertContext.SaveChangesAsync(); } using (var assertContext = new TheatreContext(options)) { var sut = new TheatreService(assertContext); await Assert.ThrowsExceptionAsync <Exception>(() => sut.GetTheatreAsync(secondId)); } }
public async Task ThrowWhenObjectIsNull() { var options = Utilities.GetOptions(nameof(ValidTheatre)); using (var assertContext = new TheatreContext(options)) { var sut = new TheatreService(assertContext); await Assert.ThrowsExceptionAsync <ArgumentNullException>(() => sut.CreateTheatreAsync(null)); } }
public async Task ReturnTheatres() { var options = Utilities.GetOptions(nameof(ReturnTheatres)); var testId01 = Guid.NewGuid(); var testId02 = Guid.NewGuid(); var testTheatre06 = new Theatre() { Id = testId01, Name = "TestName", AboutInfo = "TestAboutInfo", Location = "TestLocation", Phone = "0896663554", }; var testTheatre07 = new Theatre() { Id = testId02, Name = "TestName", AboutInfo = "TestAboutInfo", Location = "TestLocation", Phone = "0896663554", }; var collection = new List <Theatre> { testTheatre06, testTheatre07 }; using (var assertContext = new TheatreContext(options)) { await assertContext.Theatres.AddAsync(testTheatre06); await assertContext.Theatres.AddAsync(testTheatre07); await assertContext.SaveChangesAsync(); } using (var assertContext = new TheatreContext(options)) { var sut = new TheatreService(assertContext); var result = await sut.GetAllTheatresAsync(); Assert.IsInstanceOfType(result, typeof(ICollection <Theatre>)); Assert.AreEqual(2, result.Count); Assert.AreEqual(testTheatre06.Id, result.First().Id); Assert.AreEqual(testTheatre06.Name, result.First().Name); Assert.AreEqual(testTheatre06.AboutInfo, result.First().AboutInfo); Assert.AreEqual(testTheatre06.Location, result.First().Location); Assert.AreEqual(testTheatre06.Phone, result.First().Phone); Assert.AreEqual(testTheatre07.Id, result.Last().Id); Assert.AreEqual(testTheatre07.Name, result.Last().Name); Assert.AreEqual(testTheatre07.AboutInfo, result.Last().AboutInfo); Assert.AreEqual(testTheatre07.Location, result.Last().Location); Assert.AreEqual(testTheatre07.Phone, result.Last().Phone); } }
public async Task <ActionResult <string> > Get([FromBody] CartViewModel cart) { string response = null; if (cart != null) { var movieValidation = await EventService.ValidateEvent(cart.Session.Event._id, cart.Session.Event.Name); if (!movieValidation) { return(NotFound("Filme Inválido!")); } var theatreValidation = await TheatreService.ValidateTheatre(cart.Session.Theatre._id, cart.Session.Theatre.Name); if (!theatreValidation) { return(NotFound("Cinema Inválido!")); } var promocode = await PromocodeRepository.GetPromocodeByCodeAsync(cart.Promocode); if (promocode == null) { return(NotFound("Promocode Inválido!")); } var promotionValidation = await PromotionService.ValidatePromotionConditions(cart, promocode.PromotionId); if (!promotionValidation) { return("A compra não atende as regras da promoção!"); } var discount = await PromotionService.GetPromotionDiscount(cart, promocode.PromotionId); response = string.Format($"Desconto realizado: R$ {discount}", discount); } else { return(NotFound()); } return(response); }
public async Task ThrowWhenTheatreIsNull() { //Arrange var options = Utilities.GetOptions(nameof(DeleteTheatreTest)); var testTheatre03 = new Theatre() { Id = Guid.NewGuid(), Name = "TestName", AboutInfo = "TestAboutInfo", Location = "TestLocation", Phone = "0896663554", }; using (var assertContext = new TheatreContext(options)) { var sut = new TheatreService(assertContext); await Assert.ThrowsExceptionAsync <ArgumentNullException>(() => sut.DeleteTheatreAsync(testTheatre03.Id)); } }