Exemplo n.º 1
0
        public void BodyParameterReqestedThenReadFile()
        {
            FileMailTemplate reader = new FileMailTemplate(_fileSystem)
            {
                Name = _templateName,
                Path = _correctPath
            };

            string result = reader.Body;

            Assert.Equal(_fileContent, result);
            Mock.Get(_fileSystem).Verify(f => f.File.ReadAllText(_correctPath), Times.Once);
        }
Exemplo n.º 2
0
        public Class()
        {
            Mock.Get(_fileSystem).Setup(f => f.File.Exists(_correctPath)).Returns(true);
            Mock.Get(_fileSystem).Setup(f => f.File.ReadAllText(_correctPath)).Returns(_fileContent);
            Mock.Get(_fileSystem)
            .Setup(f => f.Path.Combine(It.IsAny <string>(), It.IsAny <string>()))
            .Returns((string a, string b) => { return(Path.Combine(a, b)); });
            Mock.Get(_fileSystem)
            .Setup(f => f.Path.Combine(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>()))
            .Returns((string a, string b, string c) => { return(Path.Combine(a, b, c)); });
            Mock.Get(_fileSystem)
            .Setup(f => f.Path.Combine(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>()))
            .Returns((string a, string b, string c) => { return(Path.Combine(a, b, c)); });

            _template = new FileMailTemplate(_fileSystem);
        }
Exemplo n.º 3
0
        public void StoreInMemoryEnabledThenReadFileOnce()
        {
            FileMailTemplate reader = new FileMailTemplate(_fileSystem)
            {
                Name          = _templateName,
                Path          = _correctPath,
                StoreInMemory = true
            };

            for (int i = 0; i < 10; i++)
            {
                string result = reader.Body;
                Assert.Equal(_fileContent, result);
            }

            Mock.Get(_fileSystem).Verify(f => f.File.ReadAllText(_correctPath), Times.Once);
        }
Exemplo n.º 4
0
        public void StoreInMemoryDisabledThenReadFileAtRead()
        {
            FileMailTemplate reader = new FileMailTemplate(_fileSystem)
            {
                Name          = _templateName,
                Path          = _correctPath,
                StoreInMemory = false
            };
            int readCount = 10;

            for (int i = 0; i < readCount; i++)
            {
                string result = reader.Body;
                Assert.Equal(_fileContent, result);
            }

            Mock.Get(_fileSystem).Verify(f => f.File.ReadAllText(_correctPath), Times.Exactly(readCount));
        }
Exemplo n.º 5
0
        public void AfterCreationFileUnableReadThenNullBodyReturned()
        {
            string path    = "new path";
            string content = "new content";

            Mock.Get(_fileSystem).Setup(f => f.File.Exists(path)).Returns(true);
            Mock.Get(_fileSystem).Setup(f => f.File.ReadAllText(_correctPath)).Returns(content);
            Mock.Get(_fileSystem).Setup(f => f.File.Exists(path)).Returns(true);
            Mock.Get(_fileSystem).Setup(f => f.File.ReadAllText(_correctPath)).Throws(new Exception());
            FileMailTemplate reader = new FileMailTemplate(_fileSystem)
            {
                Name = _templateName,
                Path = _correctPath
            };

            string result = reader.Body;

            Assert.Null(result);
        }
Exemplo n.º 6
0
 public void ItExists()
 {
     FileMailTemplate reader = new FileMailTemplate();
 }