Beispiel #1
0
        public void LoadConfig_WhenIsNull_ShouldThrowArgumentNullException()
        {
            // arrange
            var            fileManagerMoq = new Mock <IFileHelper>();
            var            model          = new ModelStub(fileManagerMoq.Object);
            EConfiguration configuration  = null;

            // act
            model.LoadConfig(configuration);
        }
Beispiel #2
0
        public void LoadConfig_WhenConfigurationContentIsEmptyOrNull_ShouldThrowArgumentNullException()
        {
            // arrange
            var fileManagerMoq = new Mock <IFileHelper>();
            var model          = new ModelStub(fileManagerMoq.Object);
            var configuration  = new EConfiguration()
            {
                Name    = "file",
                Content = ""
            };

            fileManagerMoq.Setup(
                fm => fm.WriteAllText(It.Is <string>(s => s.ToLower() == "C:\\Windows\\system32\\drivers\\etc\\hosts".ToLower()),
                                      It.Is <string>(s => s == configuration.Content)))
            .Verifiable();

            // act
            model.LoadConfig(configuration);

            // assert
            fileManagerMoq.Verify();
        }
Beispiel #3
0
        public void LoadConfig_WhenValidConfigIsProvided_ShouldReplaceWindowsHostsFile()
        {
            // arrange
            var fileManagerMoq = new Mock <IFileHelper>();
            var model          = new ModelStub(fileManagerMoq.Object);
            var configuration  = new EConfiguration()
            {
                Name    = "file",
                Content = "#File content \\n 192.28.129.100\tsomepage.com"
            };

            fileManagerMoq.Setup(
                fm => fm.WriteAllText(It.Is <string>(p => p.ToLower() == "C:\\Windows\\system32\\drivers\\etc\\hosts".ToLower()),
                                      configuration.Content))
            .Verifiable();

            // act
            model.LoadConfig(configuration);

            // assert
            fileManagerMoq.Verify();
        }