예제 #1
0
        public async Task Can_addByUrlAsync_responseCompany()
        {
            //Arrange
            await using var context = new ApplicationDb(ContextOptions);
            var browsingContextServiceMock = new Mock <IBrowsingContextService>();
            var logger = Mock.Of <ILogger <CompanyController> >();
            var backgroundTaskQueueMock = new BackgroundCompaniesQueue(10);

            browsingContextServiceMock
            .Setup(service => service.OpenPageAsync("https://prom.ua/c3502019-toppoint-tvoj-internet.html"))
            .ReturnsAsync(await MockOpenPageAsync());

            var controller = new CompanyController(context, null, new BrowsingContextService(), logger,
                                                   backgroundTaskQueueMock, null);

            //Act
            var result = await controller.AddByUrlAsync("https://prom.ua/c3502019-toppoint-tvoj-internet.html");

            var okResult = result as OkObjectResult;

            //Assert
            Assert.NotNull(okResult);
            Assert.Equal(StatusCodes.Status200OK, okResult.StatusCode);

            var okResultValue = okResult.Value as ResponseCompany;

            Assert.NotNull(okResultValue);

            Assert.Equal("3502019", okResultValue.ExternalId);
        }