Beispiel #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,
                new Subject <User>());

            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());
        }