public void GetTemplate_DoesNotThrowException_IfFileNotFound()
        {
            var pathProvider = MockRepository.GenerateStub<IPathProvider>();
            pathProvider.Stub(p => p.GetPath("Login")).Return("test.htm");

            var provider = new FileSystemTemplateService(pathProvider);

            Assert.DoesNotThrow(() => provider.GetTemplate("Login"));
        }
        public void GetTemplate_GetsFilePathFromPathProvider()
        {
            var pathProvider = MockRepository.GenerateStub<IPathProvider>();
            pathProvider.Stub(p => p.GetPath("Login")).Return("/Login.htm");
            var templateProvider = new FileSystemTemplateService(pathProvider);

            try
            {
                templateProvider.GetTemplate("Login");
            }
            catch (Exception)
            {
                //It will throw due to Login.html not being present.
            }

            pathProvider.AssertWasCalled(p => p.GetPath("Login"));
        }
        public void GetTemplate_ReturnsContentOfFileFromDisk()
        {
            string expected = "file-content";

            var pathProvider = MockRepository.GenerateStub<IPathProvider>();
            pathProvider.Stub(p => p.GetPath("Login")).Return("test.htm");
            using (StreamWriter writer = File.CreateText("test.htm"))
            {
                writer.Write(expected);
                writer.Flush();
                writer.Close();
            }
            var provider = new FileSystemTemplateService(pathProvider);

            string template = provider.GetTemplate("Login");

            Assert.Equal(expected, template);

            File.Delete("test.htm"); //Cleanup
        }
        public void GetTemplate_ReturnsErrorMessage_IfFileNotFound()
        {
            var pathProvider = MockRepository.GenerateStub<IPathProvider>();
            pathProvider.Stub(p => p.GetPath("Login")).Return("test.htm");

            var provider = new FileSystemTemplateService(pathProvider);
            string template = provider.GetTemplate("Login");

            Assert.Contains("Template File 'Login' could not be found at ", template);
        }