Esempio n. 1
0
        /// <summary>
        /// unit test for addition and deletion ip addresses
        /// </summary>
        /// <returns></returns>
        public async Task AddIpAddress()
        {
            var             test     = CreateTest("Test 1");
            string          userName = "******";
            ApplicationUser user     = new ApplicationUser()
            {
                Email = userName, UserName = userName
            };
            await _userManager.CreateAsync(user);

            var applicationUser = await _userManager.FindByEmailAsync(user.Email);

            await _testRepository.CreateTestAsync(test, applicationUser.Id);

            var testIp = new TestIpAddress();

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

            await _testRepository.UpdateTestByIdAsync(test);

            Assert.Equal(1, test.TestIpAddress.Count);
            await _testRepository.DeleteIpAddressAsync(testIp.Id);

            Assert.Equal(0, test.TestIpAddress.Count);
        }
Esempio n. 2
0
        public async Task <IActionResult> DeleteIpAsync([FromRoute] int id)
        {
            await _testRepository.DeleteIpAddressAsync(id);

            return(Ok());
        }