Exemplo n.º 1
0
        public void SetUp()
        {
            _logger = Substitute.For <ILogger>();
            var fileProvider = Substitute.For <IFileProvider>();
            var provider     = new FileTemplateProvider(_logger, fileProvider);

            fileProvider.Exists(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, TemplateKey)).Returns(false);

            _contents = provider.GetContentsFor(TemplateKey, null);
        }
Exemplo n.º 2
0
        public UserServiceTests()
        {
            _ctx = Substitute.ForPartsOf <UsersContext>();

            var options = Options.Create <AppSettings>(new AppSettings()
            {
                Secret = "aasdas_afassqyqw"
            });

            var templateProvider = new FileTemplateProvider();

            var mailProvider = new MailProvider(templateProvider);

            _userService = new UserService(options, _ctx, Substitute.For <IMailingService>(), mailProvider);
        }
        public void given_file_exists_for_custom_path_when_getting_content_for_then_should_return_content()
        {
            const string customPath   = "customPath";
            var          logger       = Substitute.For <ILogger>();
            var          fileProvider = Substitute.For <IFileProvider>();
            var          provider     = new FileTemplateProvider(logger, fileProvider, customPath);

            const string expectedContent = "This is the expected content.";
            const string templateKey     = "myTemplate";

            fileProvider.Exists(Path.Combine(customPath, templateKey)).Returns(true);
            fileProvider.ReadAllText(Path.Combine(customPath, templateKey)).Returns(expectedContent);

            var contents = provider.GetContentsFor(templateKey, null);

            contents.Should().Be(expectedContent);
        }
        public void given_file_exists_when_getting_content_for_then_should_return_content()
        {
            var logger       = Substitute.For <ILogger>();
            var fileProvider = Substitute.For <IFileProvider>();
            var provider     = new FileTemplateProvider(logger, fileProvider);

            const string templateKey     = "myTemplate";
            const string expectedContent = "This is the expected content.";

            var filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, templateKey);

            fileProvider.Exists(filePath).Returns(true);
            fileProvider.ReadAllText(filePath).Returns(expectedContent);

            var contents = provider.GetContentsFor(templateKey, null);

            contents.Should().Be(expectedContent);
        }
Exemplo n.º 5
0
        public MailProviderTests()
        {
            ITemplateProvider templateProvider = new FileTemplateProvider();

            _mailProvider = new MailProvider(templateProvider);
        }