public async Task ShouldGetTicketTypeById() { CreateTicketTypes(); TicketTypeService ticketTypeService = new TicketTypeService(_dbContext, _mainEventProvider); TicketTypeController ticketTypeController = new TicketTypeController(ticketTypeService); ActionResult <TicketTypeVm> result1 = await ticketTypeController.GetTicketTypeAsync(1); TicketTypeVm returnedTicketType1 = (TicketTypeVm)((OkObjectResult)result1.Result).Value; Assert.AreEqual(1, returnedTicketType1.Id); Assert.AreEqual("Test ticket type", returnedTicketType1.DescriptionName); Assert.AreEqual(10, returnedTicketType1.BasePrice); Assert.AreEqual(20, returnedTicketType1.AmountAvailable); ActionResult <TicketTypeVm> result2 = await ticketTypeController.GetTicketTypeAsync(2); TicketTypeVm returnedTicketType2 = (TicketTypeVm)((OkObjectResult)result2.Result).Value; Assert.AreEqual(2, returnedTicketType2.Id); Assert.AreEqual(_descrName1, returnedTicketType2.DescriptionName); Assert.AreEqual(_basePrice1, returnedTicketType2.BasePrice); Assert.AreEqual(_amountAvailable1, returnedTicketType2.AmountAvailable); }
public async Task <List <TicketIssueLevel_TicketTypeDTO> > FilterListTicketType([FromBody] TicketIssueLevel_TicketTypeFilterDTO TicketIssueLevel_TicketTypeFilterDTO) { if (!ModelState.IsValid) { throw new BindException(ModelState); } TicketTypeFilter TicketTypeFilter = new TicketTypeFilter(); TicketTypeFilter.Skip = 0; TicketTypeFilter.Take = 20; TicketTypeFilter.OrderBy = TicketTypeOrder.Id; TicketTypeFilter.OrderType = OrderType.ASC; TicketTypeFilter.Selects = TicketTypeSelect.ALL; TicketTypeFilter.Id = TicketIssueLevel_TicketTypeFilterDTO.Id; TicketTypeFilter.Name = TicketIssueLevel_TicketTypeFilterDTO.Name; TicketTypeFilter.Code = TicketIssueLevel_TicketTypeFilterDTO.Code; TicketTypeFilter.StatusId = TicketIssueLevel_TicketTypeFilterDTO.StatusId; TicketTypeFilter.StatusId.Equal = StatusEnum.ACTIVE.Id; List <TicketType> TicketTypes = await TicketTypeService.List(TicketTypeFilter); List <TicketIssueLevel_TicketTypeDTO> TicketIssueLevel_TicketTypeDTOs = TicketTypes .Select(x => new TicketIssueLevel_TicketTypeDTO(x)).ToList(); return(TicketIssueLevel_TicketTypeDTOs); }
public async Task ShouldCreateTicketType() { TicketTypeService ticketTypeService = new TicketTypeService(_dbContext, _mainEventProvider); TicketTypeController ticketTypeController = new TicketTypeController(ticketTypeService); CreateTicketTypes(); ActionResult <List <TicketTypeListVm> > resultAr = await ticketTypeController.GetTicketTypesAsync(); List <TicketTypeListVm> result = resultAr.Value; Assert.AreEqual(2, result.Count); string descrName3 = "Description name 3"; int basePrice3 = 30; int amountAvailable3 = 250; TicketTypeVm ticketTypeVm = new TicketTypeVm { DescriptionName = descrName3, BasePrice = basePrice3, AmountAvailable = amountAvailable3 }; await ticketTypeController.CreateTicketTypeAsync(ticketTypeVm); ActionResult <List <TicketTypeListVm> > newResultAr = await ticketTypeController.GetTicketTypesAsync(); List <TicketTypeListVm> newResult = newResultAr.Value; Assert.AreEqual(3, newResult.Count); Assert.That(newResult, Has.Exactly(1).Matches <TicketTypeListVm>(ticketType => ticketType.Id == 3 && ticketType.DescriptionName == descrName3 && ticketType.BasePrice == basePrice3 && ticketType.AmountAvailable == amountAvailable3)); }
public async Task ShouldUpdateTicketType() { CreateTicketTypes(); string newdescrName = "New descr name"; int newBasePrice = 80; int newAmmount = 350; TicketTypeService ticketTypeService = new TicketTypeService(_dbContext, _mainEventProvider); TicketTypeController ticketTypeController = new TicketTypeController(ticketTypeService); TicketTypeVm ticketTypeVm = new TicketTypeVm { Id = 1, DescriptionName = newdescrName, BasePrice = newBasePrice, AmountAvailable = newAmmount }; await ticketTypeController.UpdateTicketTypeAsync(ticketTypeVm); // Check that only one has been changed TicketType ticketType1 = _dbContext.TicketTypes.Find(1); Assert.AreEqual(newdescrName, ticketType1.DescriptionName); Assert.AreEqual(newBasePrice, ticketType1.BasePrice); Assert.AreEqual(newAmmount, ticketType1.AmountAvailable); TicketType ticketType2 = _dbContext.TicketTypes.Find(2); Assert.AreEqual(_descrName1, ticketType2.DescriptionName); Assert.AreEqual(_basePrice1, ticketType2.BasePrice); Assert.AreEqual(_amountAvailable1, ticketType2.AmountAvailable); }
public TicketFacadeService( TicketTypeService ticketTypeService, EnterpriseUserService enterpriseUserService, TicketService ticketService) { _ticketTypeService = ticketTypeService; _enterpriseUserService = enterpriseUserService; _ticketService = ticketService; }
public void Initialize() { var ticketTypes = GetFakeData(); _dbContextMock = new DbContextMock <DatabaseContext>(DummyOptions); var dbSetMock = _dbContextMock.CreateDbSetMock(x => x.TicketTypes, ticketTypes); var repository = new TicketTypeRepository(_dbContextMock.Object); _service = new TicketTypeService(repository); }
public CreateModel( ShowTimeService showTimeService, TicketTypeService ticketTypeService, UserService userService, TicketService ticketService) { this.showTimeService = showTimeService; this.ticketService = ticketService; this.userService = userService; this.ticketTypeService = ticketTypeService; }
public BookTicketModel( TicketService ticketService, ShowTimeService showTimeService, TicketTypeService ticketTypeService, UserService userService ) { this.ticketService = ticketService; this.showTimeService = showTimeService; this.ticketTypeService = ticketTypeService; this.userService = userService; }
public async Task ShouldGetTicketTypesForEvent() { CreateTicketTypes(); TicketTypeService ticketTypeService = new TicketTypeService(_dbContext, _mainEventProvider); TicketTypeController ticketTypeController = new TicketTypeController(ticketTypeService); ActionResult <List <TicketTypeListVm> > result = await ticketTypeController.GetTicketTypesForEventAsync(1); List <TicketTypeListVm> returnedTicketTypes = (List <TicketTypeListVm>)((OkObjectResult)result.Result).Value; Assert.AreEqual(_descrName1, returnedTicketTypes[1].DescriptionName); Assert.AreEqual(_basePrice1, returnedTicketTypes[1].BasePrice); Assert.AreEqual(_amountAvailable1, returnedTicketTypes[1].AmountAvailable); }
public async Task ShouldGetTicketTypes() { CreateTicketTypes(); TicketTypeService ticketTypeService = new TicketTypeService(_dbContext, _mainEventProvider); TicketTypeController ticketTypeController = new TicketTypeController(ticketTypeService); ActionResult <List <TicketTypeListVm> > resultAr = await ticketTypeController.GetTicketTypesAsync(); List <TicketTypeListVm> result = resultAr.Value; Assert.AreEqual(_descrName1, result[1].DescriptionName); Assert.AreEqual(_basePrice1, result[1].BasePrice); Assert.AreEqual(_amountAvailable1, result[1].AmountAvailable); }
public TicketTypeServiceTests() { var mockRepository = new Mock <IRepository <TicketType, int> >(); var mockUnitOfWork = new Mock <IUnitOfWork>(); fakeTicketTypes = new List <TicketType> { new TicketType { Id = 5, TypeName = "Test1", Coefficient = 2.3M, DurationHours = 12, IsPersonal = true }, new TicketType { Id = 7, TypeName = "Test2", Coefficient = 2.4M, DurationHours = 13, IsPersonal = false }, new TicketType { Id = int.MaxValue, TypeName = "Test2", Coefficient = 2.4M, DurationHours = 13, IsPersonal = false } }; ticketTypeDto = new TicketTypeDto { Id = 3, TypeName = "TestDTO", Coefficient = 2.6M, DurationHours = 16, IsPersonal = false }; mockRepository.Setup(m => m.GetAll()).Returns(fakeTicketTypes.AsQueryable); mockRepository.Setup(m => m.Get(It.IsAny <int>())) .Returns <int>(id => fakeTicketTypes.Single(t => t.Id == id)); mockRepository.Setup(r => r.Create(It.IsAny <TicketType>())) .Callback <TicketType>(t => fakeTicketTypes.Add(ticketType = t)); mockRepository.Setup(r => r.Update(It.IsAny <TicketType>())) .Callback <TicketType>(t => ticketType = t); mockRepository.Setup(x => x.Delete(It.IsAny <int>())) .Callback <int>(id => fakeTicketTypes.Remove(fakeTicketTypes.Single(t => t.Id == id))); mockUnitOfWork.Setup(m => m.TicketTypes).Returns(mockRepository.Object); ticketTypeService = new TicketTypeService(mockUnitOfWork.Object); }
public async Task ShouldDeleteTicketType() { CreateTicketTypes(); TicketTypeService ticketTypeService = new TicketTypeService(_dbContext, _mainEventProvider); TicketTypeController ticketTypeController = new TicketTypeController(ticketTypeService); TicketTypeVm ticketTypeVm = new TicketTypeVm { Id = 1 }; await ticketTypeController.DeleteTicketTypeAsync(ticketTypeVm); // Check that we have deleted only the first, but not the other TicketType ticketType1 = _dbContext.TicketTypes.Find(1); Assert.IsNull(ticketType1); TicketType ticketType2 = _dbContext.TicketTypes.Find(2); Assert.IsNotNull(ticketType2); }
public TicketTypeController(TicketTypeService ticketTypeService) { _ticketTypeService = ticketTypeService; }
public IndexModel(TicketTypeService service) { this.service = service; }
public UpdateModel(TicketTypeService service) { this.service = service; }
public TicketTypesController(TicketTypeService service) { _service = service; }