Example #1
0
        public void CheckCorrectWindowsHostsLocationFile()
        {
            //Arrange & Act
            _systemLevelModification = new SystemLevelModification(true);

            //Assert
            _systemLevelModification.GetHostFileLocation().Should().EndWith(@"system32\drivers\etc\hosts");
        }
Example #2
0
        public void CheckRewriteCorrectWindowsHostsLocationFile()
        {
            //Arrange & Act
            string newHostFileLocation = @"C:\temp\hosts";

            _systemLevelModification = new SystemLevelModification(true, newHostFileLocation);

            //Assert
            _systemLevelModification.GetHostFileLocation().Should().Be(newHostFileLocation);
        }
Example #3
0
        public void CheckCorrectHostFileWasCreated()
        {
            //Arrange
            string newHostFileLocation = $"{TempFolder.Name}{@"\hosts"}";

            _systemLevelModification = new SystemLevelModification(true, newHostFileLocation);

            //Act
            bool hostFileExistsBefore = _systemLevelModification.HostFileExists();

            _systemLevelModification.CreateNewHostFile();
            bool hostFileExistsAfter = _systemLevelModification.HostFileExists();

            //Assert
            hostFileExistsBefore.Should().BeFalse();
            hostFileExistsAfter.Should().BeTrue();
        }
Example #4
0
        public void CheckHostFileWasReplaced()
        {
            //Arrange
            string newHostFileLocation = $"{TempFolder.Name}{@"\hosts"}";

            _systemLevelModification = new SystemLevelModification(true, newHostFileLocation);
            string newHostFileTwoLocation = $"{TempFolder.Name}{@"\hosts2"}";

            FileModification.WriteFile(newHostFileTwoLocation, "#Test");

            //Act
            _systemLevelModification.CreateNewHostFile();
            string hostFileContentBefore = FileModification.ReadFile(newHostFileLocation);

            _systemLevelModification.ReplaceHostFile(new string[] { $"-newPath={newHostFileTwoLocation.Replace(" ", "%20")}" });
            string hostFileContentAfter = FileModification.ReadFile(newHostFileLocation);

            //Assert
            hostFileContentAfter.Should().NotBe(hostFileContentBefore);
        }
Example #5
0
 static void Main(string[] args)
 {
     SystemLevelModification application = new SystemLevelModification();
 }