public QueueTypeControllerTest(CustomWebApplicationFactory <Startup> factory) { _factory = factory; _context = new InMemoryDbContextFactory().GetPriorityQueueDbContext(); _context.QueueType.RemoveRange(_context.QueueType); _queueTypeRepository = new QueueTypeRepository(_context); _queueTypeService = new QueueTypeService(_queueTypeRepository); _controller = new QueueTypeController(_queueTypeService); _client = factory.CreateClient(new WebApplicationFactoryClientOptions()); }
private void TestExceptions() { var mockException = new Mock <IQueueTypeRepository>(); mockException.Setup(x => x.FindAll()).Throws(new Exception()); mockException.Setup(x => x.FindById(It.IsAny <int>())).Throws(new Exception()); mockException.Setup(x => x.Create(It.IsAny <QueueType>())).Throws(new Exception()); mockException.Setup(x => x.Update(It.IsAny <QueueType>())).Throws(new Exception()); mockException.Setup(x => x.Delete(It.IsAny <QueueType>())).Throws(new Exception()); var queueTypeRepository = mockException.Object; var queueTypeService = new QueueTypeService(queueTypeRepository); Assert.Throws <Exception>(() => queueTypeService.FindAll()); Assert.Throws <Exception>(() => queueTypeService.FindById(1)); Assert.Throws <Exception>(() => queueTypeService.Update(new QueueType())); Assert.Throws <Exception>(() => queueTypeService.Create(new QueueType())); Assert.Throws <Exception>(() => queueTypeService.Delete(new QueueType())); }
private void TestDelete() { var queueTypeService = new QueueTypeService(_queueTypeRepository); Assert.Equal(_queueTypes[0], queueTypeService.Delete(new QueueType())); }
private void TestFindById() { var queueTypeService = new QueueTypeService(_queueTypeRepository); Assert.Equal(_queueTypes[0], queueTypeService.FindById(1)); }
private void TestFindAll() { var queueTypeService = new QueueTypeService(_queueTypeRepository); Assert.Equal(_queueTypes, queueTypeService.FindAll()); }