Beispiel #1
0
        public void GetConfig_WhenValidFileIsProvided_ShouldReturnSingleConfiguration()
        {
            // arrange
            var expectedConfiguration = new EConfiguration()
            {
                Name = "file", Content = "TestContent"
            };

            var fileManagerMoq = new Mock <IFileHelper>();
            var model          = new ModelStub(fileManagerMoq.Object);

            fileManagerMoq.Setup(
                fm => fm.Exists(It.IsAny <string>())).Returns(true);

            fileManagerMoq.Setup(
                fm => fm.ReadAllText(It.IsAny <string>()))
            .Returns("TestContent").Verifiable();


            // act
            var configuration = model.ReadExternalConfig("D:\\file.host");

            // assert
            Assert.AreEqual(configuration, expectedConfiguration);
        }
Beispiel #2
0
        public void GetConfig_WhenNotExistingFileIsProvided_ShouldThrowFileNotFoundException()
        {
            // arrange
            var fileManagerMoq = new Mock <IFileHelper>();
            var model          = new ModelStub(fileManagerMoq.Object);

            fileManagerMoq.Setup(
                fm => fm.Exists(It.IsAny <string>())).Returns(false);

            // act
            var configuration = model.ReadExternalConfig("D:\\file.host");
        }