public async Task Get_ServiceLists_items_success() { //Arrange var pageSize = 10; var pageIndex = 1; var expectedItemsInPage = 10; var expectedTotalItems = 20; var serviceListContext = new ServiceListContext(_dbOptions); var settings = new TestServiceListSettings(); var integrationServicesMock = new Mock <IServiceListIntegrationEventService>(); //Act var serviceListController = new ServiceListController(serviceListContext, settings, integrationServicesMock.Object); var actionResult = await serviceListController.ItemsAsync(pageSize, pageIndex); //Assert var okResult = actionResult as OkObjectResult; Assert.IsType <PaginatedItemsViewModel <ServiceListItem> >(okResult.Value); var page = Assert.IsAssignableFrom <PaginatedItemsViewModel <ServiceListItem> >(okResult.Value); Assert.Equal(expectedTotalItems, page.Count); Assert.Equal(pageIndex, page.PageIndex); Assert.Equal(pageSize, page.PageSize); Assert.Equal(expectedItemsInPage, page.Data.Count()); }
public ServiceListPriceChangeIntegrationEventHandler( ServiceListContext ServiceListContext, ILogger <ServiceListPriceChangeIntegrationEventHandler> logger) { _serviceListContext = ServiceListContext; _logger = logger ?? throw new System.ArgumentNullException(nameof(logger)); }
public ServiceListController(ServiceListContext context, IOptionsSnapshot <ServiceListSettings> settings, IServiceListIntegrationEventService catalogIntegrationEventService) { _serviceListContext = context ?? throw new ArgumentNullException(nameof(context)); _catalogIntegrationEventService = catalogIntegrationEventService ?? throw new ArgumentNullException(nameof(catalogIntegrationEventService)); _settings = settings.Value; context.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking; }
public BonsuActivatedIntegrationEventHandler( ServiceListContext ServiceListContext, IServiceListIntegrationEventService catalogIntegrationEventService, ILogger <BonsuActivatedIntegrationEventHandler> logger) { _serviceListContext = ServiceListContext; _catalogIntegrationEventService = catalogIntegrationEventService; _logger = logger ?? throw new System.ArgumentNullException(nameof(logger)); }
public ServiceListControllerTest() { _dbOptions = new DbContextOptionsBuilder <ServiceListContext>() .UseInMemoryDatabase(databaseName: "service-list-in-memory") .Options; using (var dbContext = new ServiceListContext(_dbOptions)) { dbContext.AddRange(GetServiceListItems()); dbContext.SaveChanges(); } }
public ServiceListIntegrationEventService( ILogger <IServiceListIntegrationEventService> logger, IEventBus eventBus, ServiceListContext ServiceListContext, Func <DbConnection, IIntegrationEventLogService> integrationEventLogServiceFactory) { _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _ServiceListContext = ServiceListContext ?? throw new ArgumentNullException(nameof(ServiceListContext)); _integrationEventLogServiceFactory = integrationEventLogServiceFactory ?? throw new ArgumentNullException(nameof(integrationEventLogServiceFactory)); _eventBus = eventBus ?? throw new ArgumentNullException(nameof(eventBus)); _eventLogService = _integrationEventLogServiceFactory(_ServiceListContext.Database.GetDbConnection()); }
public ServiceListService(ServiceListContext dbContext, IOptions <ServiceListSettings> settings, ILogger <ServiceListService> logger) { _settings = settings.Value; _catalogContext = dbContext ?? throw new ArgumentNullException(nameof(dbContext)); _logger = logger; }