Пример #1
0
        public async Task Test_RegisterUser_With_Single_Interested_Locality()
        {
            accountManagerMock = new Mock<AccountManager>(userStoreMock.Object);

            IdentityResult identityResult = new IdentityResult(null);
            accountManagerMock.Setup(x => x.CreateAsync(It.IsAny<User>())).ReturnsAsync(identityResult);

            var accountContext = new AccountContext(
                dbContextMock.Object,
                mailServiceMock.Object,
                accountManagerMock.Object,
                blobServiceMock.Object,
                jobManagerMock.Object);

            var registerModel = new UserRegistrationModel()
            {
                UserName = "******",
                Type = IdentityTypes.USER,
                Password = "******",
                ConfirmPassword = "******",
                Email = "*****@*****.**",
                PhoneNumber = "+88017100000",
                InterestedLocalities = new List<string>() {
                    "TestLocality"
                }
            };

            var result = await accountContext.RegisterUser(registerModel);

            Assert.NotNull(result.User);
            Assert.AreEqual("testUsername", result.User.UserName);
            Assert.AreEqual(IdentityTypes.USER, result.User.Type);
            Assert.AreEqual("*****@*****.**", result.User.Email);
            Assert.AreEqual(false, result.User.EmailConfirmed);
            Assert.AreEqual("+88017100000", result.User.PhoneNumber);
            Assert.AreEqual(false, result.User.PhoneNumberConfirmed);
            Assert.NotNull(result.User.Profile);
            Assert.AreEqual(typeof(UserProfile), result.User.Profile.GetType());
            Assert.NotNull((result.User.Profile as UserProfile).InterestedLocalities);
            Assert.AreEqual(1, (result.User.Profile as UserProfile).InterestedLocalities.Count);
            Assert.AreEqual("TestLocality", (result.User.Profile as UserProfile).InterestedLocalities.First());
        }
Пример #2
0
        public async Task Test_NotifyUserCreationByMail()
        {
            accountManagerMock = new Mock<AccountManager>(userStoreMock.Object);

            mailServiceMock.Setup(x => x.SendWelcomeMail(
                It.IsAny<SendWelcomeEmailRequest>())).ReturnsAsync(
                new SendEmailResponse(HttpStatusCode.OK));

            var accountContext = new AccountContext(
                dbContextMock.Object,
                mailServiceMock.Object,
                accountManagerMock.Object,
                blobServiceMock.Object,
                jobManagerMock.Object);

            Environment.SetEnvironmentVariable("Its.Configuration.Settings.Precedence", "local|production");

            var userMock = new Mock<User>(new RegistrationModelBase() { UserName = "******" });

            var result = await accountContext.NotifyUserCreationByMail(userMock.Object);
            Assert.IsNotNull(result);
            Assert.AreEqual(HttpStatusCode.OK, result.StatusCode);
        }