Пример #1
0
 public async Task<IActionResult> Conduct(string link)
 {
     var ipAddress = HttpContext.Request.Headers["X-Forwarded-For"].ToString();
     if (string.IsNullOrEmpty(ipAddress))
         ipAddress = HttpContext.Connection.RemoteIpAddress.ToString();
     if (!string.IsNullOrWhiteSpace(link) && await _testConduct.IsTestLinkExistForTestConductionAsync(link, ipAddress))
     {
         ViewBag.Link = link;
         return View();
     }
     return RedirectToAction("PageNotFound");
 }
Пример #2
0
        public async Task IsTestLinkExistAsyncTest()
        {
            var testObject = await CreateTestAsync();

            var testIp = new DomainModel.Models.Test.TestIpAddress();

            testIp.IpAddress = "127.0.0.1";
            testIp.TestId    = testObject.Id;
            await _trappistDbContext.TestIpAddresses.AddAsync(testIp);

            var userIp = "127.0.0.1";

            testObject.EndDate    = new DateTime(2044, 12, 24);
            testObject.IsLaunched = true;

            var linkExist = await _testConductRepository.IsTestLinkExistForTestConductionAsync(testObject.Link, userIp);

            Assert.True(linkExist);
            testObject.IsPaused = true;
            var linkNotExist = await _testConductRepository.IsTestLinkExistForTestConductionAsync(testObject.Link, userIp);

            Assert.False(linkNotExist);
        }