Esempio n. 1
0
        public void GetMailAccount_GivenHasUserAccount_ShouldDecryptUsersPassword()
        {
            // Arrange
            var repo = Substitute.For <IMailAccountRepo>();
            var encryptionService = TestObjects.GetEncryptionService();
            var encryptedPass     = encryptionService.EncryptText("password");
            var account           = new MailAccountBuilder()
                                    .AsValidAccount()
                                    .WithSmtpPassword(encryptedPass)
                                    .WithValidUserAccount()
                                    .WithUserAccountPassword(encryptedPass)
                                    .Build();

            repo.GetMailAccount(1, true).Returns(account);

            var service = Builder.BuildMailAccountService(
                mailAccountRepo: repo,
                encryptionService: encryptionService);

            // Act
            var mailAccount = service.GetMailAccount(1, true).Result;

            // Assert
            Assert.IsNotNull(mailAccount);
            Assert.IsNotNull(mailAccount.User);
            Assert.AreEqual("password", mailAccount.User.Password);
        }
Esempio n. 2
0
        public void GetMailDiskFolderPath_GivenNoOverrides_ShouldReturnDefaultFolder()
        {
            // Arrange
            var mailAccount = new MailAccountBuilder()
                              .AsValidAccount()
                              .WithId(1)
                              .Build();

            var mailClient = Builder.BuildRnMailClient(mailAccount);

            // Act
            var path = mailClient.GetMailDiskFolderPath();

            // Assert
            Assert.IsNotNull(path);
            Assert.AreEqual("c:\\mails\\00001\\", path);
        }
Esempio n. 3
0
        public void GetMailAccount_GivenAccountExists_ShouldReturnIt()
        {
            // Arrange
            var logger      = Substitute.For <IRnLogger>();
            var repo        = Substitute.For <IMailAccountRepo>();
            var service     = Builder.BuildMailAccountService(logger, repo);
            var mailAccount = new MailAccountBuilder().AsValidAccount().WithValidUserAccount().Build();

            repo.GetMailAccount(1).Returns(mailAccount);

            // Act
            var account = service.GetMailAccount(1).Result;

            // Assert
            Assert.IsNotNull(account);
            Assert.AreEqual(account, mailAccount);
        }
Esempio n. 4
0
        public void GetMailDiskFolderPath_GivenPathOverride_ShouldGenerateExpectedPath()
        {
            // Arrange
            var webConfig = Substitute.For <IWebConfig>();

            webConfig
            .GetAppSetting(RnMailClient.DISK_MAIL_FOLDER, Arg.Any <string>())
            .Returns("c:\\dev-mails\\");

            var mailAccount = new MailAccountBuilder()
                              .AsValidAccount()
                              .WithId(1)
                              .Build();

            var mailClient = Builder.BuildRnMailClient(mailAccount, webConfig: webConfig);

            // Acts
            var path = mailClient.GetMailDiskFolderPath();

            // Assert
            Assert.IsNotNull(path);
            Assert.AreEqual("c:\\dev-mails\\00001\\", path);
        }