• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# TestUser类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中TestUser的典型用法代码示例。如果您正苦于以下问题:C# TestUser类的具体用法?C# TestUser怎么用?C# TestUser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



TestUser类属于命名空间,在下文中一共展示了TestUser类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: StoreUserWithOneUniqueConstraint

		public void StoreUserWithOneUniqueConstraint()
		{
			var ravenSession = DocumentStore.OpenSession();

			var testUser1 = new TestUser
				{
					Name = "Test User",
					Username = "[email protected]",
					EmailAddres = null
				};
			ravenSession.Store(testUser1);
			ravenSession.SaveChanges();

			var testUser2 = new TestUser
				{
					Name = "Test User2",
					Username = "[email protected]",
					EmailAddres = null
				};

			//this line throws a null reference exception
			var checkResult = ravenSession.CheckForUniqueConstraints(testUser2);

			Assert.False(checkResult.ConstraintsAreFree());

			ravenSession.Dispose();
		}
开发者ID:WimVergouwe,项目名称:ravendb,代码行数:27,代码来源:viscious.cs


示例2: CreateUser

        public async Task CreateUser()
        {
            // Create a session and user store for this test.
            var session = SessionFactory.OpenSession();
            var userStore = new TestUserStore<TestUser>(session);
            // Create and save a user.
            var user = new TestUser { UserName = "CreateUserTest" };
            using (var transaction = session.BeginTransaction())
            {
                await userStore.CreateAsync(user);
                transaction.Commit();
            }
            // Check the user has an id.
            Assert.IsNotNull(user.Id);

            // Create a new session and user store for this test, so that we actually hit the database and not the cache.
            userStore.Dispose();
            session.Dispose();
            session = SessionFactory.OpenSession();
            userStore = new TestUserStore<TestUser>(session);
            // Load the user.
            TestUser loadUser;
            using (var transaction = session.BeginTransaction())
            {
                loadUser = await userStore.FindByIdAsync(user.Id);
                transaction.Commit();
            }
            // Check we have the same user.
            Assert.AreEqual(user.Id, loadUser.Id);
            Assert.AreEqual(user.UserName, loadUser.UserName);
        }
开发者ID:MatthewRudolph,项目名称:Airy,代码行数:31,代码来源:UserStoreTests.cs


示例3: ComplexTypeReader

        public void ComplexTypeReader()
        {
            var user = new TestUser
            {
                Contact = new Contact { Address = new Address { City = "Tallinn", Country = "Estonia"}, PhoneNumber = "1234567"},
                FirstName = "Max",
                LastName = "Lego",
                Id = Guid.NewGuid()
            };
            var emptyUser = new TestUser();

            using (var ctx = new TestContext())
            {
                var tableMapping = ctx.Db<TestUser>();

                var tableMappings = new Dictionary<Type, IEntityMap>
                {
                    {typeof (TestUser), tableMapping}
                };
                using (var reader = new MappedDataReader<TestUser>(new[] { user, emptyUser }, tableMappings))
                {
                    Assert.AreEqual(9, reader.FieldCount);
                    
                    while (reader.Read())
                    {
                        for (int i = 0; i < reader.FieldCount; ++i)
                        {
                            Console.WriteLine("{0}: {1}", i, reader.GetValue(i));
                        }
                    }
                }
            }
        }
开发者ID:akry1,项目名称:EntityFramework.BulkInsert,代码行数:33,代码来源:MappedDataReaderTest.cs


示例4: OnValidateIdentityRejectsWhenValidateSecurityStampFails

        public async Task OnValidateIdentityRejectsWhenValidateSecurityStampFails()
        {
            var user = new TestUser("test");
            var userManager = MockHelpers.MockUserManager<TestUser>();
            var claimsManager = new Mock<IUserClaimsPrincipalFactory<TestUser>>();
            var identityOptions = new IdentityOptions { SecurityStampValidationInterval = TimeSpan.Zero };
            var options = new Mock<IOptions<IdentityOptions>>();
            options.Setup(a => a.Value).Returns(identityOptions);
            var httpContext = new Mock<HttpContext>();
            var contextAccessor = new Mock<IHttpContextAccessor>();
            contextAccessor.Setup(a => a.HttpContext).Returns(httpContext.Object);
            var signInManager = new Mock<SignInManager<TestUser>>(userManager.Object,
                contextAccessor.Object, claimsManager.Object, options.Object, null);
            signInManager.Setup(s => s.ValidateSecurityStampAsync(It.IsAny<ClaimsPrincipal>())).ReturnsAsync(null).Verifiable();
            var services = new ServiceCollection();
            services.AddSingleton(options.Object);
            services.AddSingleton(signInManager.Object);
            services.AddSingleton<ISecurityStampValidator>(new SecurityStampValidator<TestUser>(options.Object, signInManager.Object));
            httpContext.Setup(c => c.RequestServices).Returns(services.BuildServiceProvider());
            var id = new ClaimsIdentity(identityOptions.Cookies.ApplicationCookieAuthenticationScheme);
            id.AddClaim(new Claim(ClaimTypes.NameIdentifier, user.Id));

            var ticket = new AuthenticationTicket(new ClaimsPrincipal(id),
                new AuthenticationProperties { IssuedUtc = DateTimeOffset.UtcNow },
                identityOptions.Cookies.ApplicationCookieAuthenticationScheme);
            var context = new CookieValidatePrincipalContext(httpContext.Object, ticket, new CookieAuthenticationOptions());
            Assert.NotNull(context.Properties);
            Assert.NotNull(context.Options);
            Assert.NotNull(context.Principal);
            await SecurityStampValidator.ValidatePrincipalAsync(context);
            Assert.Null(context.Principal);
            signInManager.VerifyAll();
        }
开发者ID:xuchrist,项目名称:Identity,代码行数:33,代码来源:SecurityStampValidatorTest.cs


示例5: CT_ET_Validation_OnClient

 public void CT_ET_Validation_OnClient()
 {
     var user = new TestUser();
     var brokenRules = user.Validate();
     Assert.AreEqual(brokenRules.Count, 1);
     Assert.AreEqual(brokenRules[0].Description, "编码 里没有输入值。");
 }
开发者ID:569550384,项目名称:Rafy,代码行数:7,代码来源:EntityTest_Client.cs


示例6: Button1_Click

 protected void Button1_Click(object sender, EventArgs e)
 {
     TestUser user=new TestUser();
     WebFormHelper.GetDataFromForm(this, user);
     FT.DAL.Orm.SimpleOrmOperator.Create(user);
     WebTools.Alert("添加成功!");
     WebTools.CloseSelf(this);
 }
开发者ID:romanu6891,项目名称:fivemen,代码行数:8,代码来源:UserEdit.aspx.cs


示例7: NavigateToUserSettings

 public void NavigateToUserSettings()
 {
     var user = new TestUser();
     AcademyLoginProvider.Instance.LoginUser(user);
     this.LoginPage.WaitForUserName();
     this.LoginPage.Validator.ValidateUserName(user.Username);
     this.SettingsPage.Navigate();
     this.SettingsPage.Validator.UsernameLabel(user.Username);
 }
开发者ID:Team-Griffin-SQA-2015,项目名称:TelerikAcademyCustomTestFramework,代码行数:9,代码来源:SettingsService.cs


示例8: PrepareOneOrderData

        private static Order PrepareOneOrderData(string orderNumber, TestUser creator)
        {
            Order order = new Order();

            order.OrderNumber = orderNumber;

            order.Creator = creator;

            return order;
        }
开发者ID:jerryshi2007,项目名称:AK47Source,代码行数:10,代码来源:DataCollectionTest.cs


示例9: SetTestUser

 public ActionResult SetTestUser()
 {
     TestUser user = new TestUser
     {
         Identity = (User as GeneralUser).Identity,
         Token = (User as GeneralUser).Token
     };
     LoggedinPersonsCache.Current.UpdatePerson(user);
     return RedirectToAction("Index");
 }
开发者ID:geoInnovators,项目名称:webapplicationtest2,代码行数:10,代码来源:TestAuthorizedController.cs


示例10: Init

        public virtual void Init()
        {
            store = new TestUserStore();
            manager = new TestIdentityRebootUserManager(store, 100);

            user = new TestUser()
            {
                UserName = username
            };
            var result = manager.Create(user, password);
            Assert.IsTrue(result.Succeeded);
        }
开发者ID:madaleno,项目名称:BrockAllen.IdentityReboot,代码行数:12,代码来源:IdentityRebootTestBase.cs


示例11: ThenItIsAddedToTheList

        async public Task ThenItIsAddedToTheList()
        {
            var store = new UserStore<TestUser>();

            var user = new TestUser() { Id = "1", UserName = "FStallone" };

            await store.CreateAsync(user);

            var output = await store.FindByIdAsync("1");

            Assert.IsNotNull(output);
            Assert.AreEqual("FStallone", output.UserName);
        }
开发者ID:pottereric,项目名称:BiggyUserStore,代码行数:13,代码来源:WhenAUserIsCreated.cs


示例12: ValidateFailsWithTooShortUserNames

        public async Task ValidateFailsWithTooShortUserNames(string input)
        {
            // Setup
            var manager = MockHelpers.TestUserManager(new NoopUserStore());
            var validator = new UserValidator<TestUser>();
            var user = new TestUser {UserName = input};

            // Act
            var result = await validator.ValidateAsync(manager, user);

            // Assert
            IdentityResultAssert.IsFailure(result, new IdentityErrorDescriber().InvalidUserName(input));
        }
开发者ID:xuchrist,项目名称:Identity,代码行数:13,代码来源:UserValidatorTest.cs


示例13: ET_AutoCollect

        public void ET_AutoCollect()
        {
            //创建对象
            var user = new TestUser();
            var list = user.TestTreeTaskList;
            var taskRoot = list.AddNew();
            var task1 = list.AddNew();
            var task11 = list.AddNew();
            var task111 = list.AddNew();
            var task112 = list.AddNew();
            var task12 = list.AddNew();
            var task2 = list.AddNew();
            var taskRoot2 = list.AddNew();

            //关系
            task1.TreeParent = taskRoot;
            task11.TreeParent = task1;
            task111.TreeParent = task11;
            task112.TreeParent = task11;
            task12.TreeParent = task1;
            task2.TreeParent = taskRoot;

            Assert.AreEqual(taskRoot.AllTimeByAutoCollect, 0);

            task111.AllTimeByAutoCollect += 1;
            Assert.AreEqual(task11.AllTimeByAutoCollect, 1);
            Assert.AreEqual(task1.AllTimeByAutoCollect, 1);
            Assert.AreEqual(taskRoot.AllTimeByAutoCollect, 1);
            Assert.AreEqual(user.TasksTimeByAutoCollect, 1);

            task12.AllTimeByAutoCollect += 1;
            Assert.AreEqual(task1.AllTimeByAutoCollect, 2);
            Assert.AreEqual(taskRoot.AllTimeByAutoCollect, 2);
            Assert.AreEqual(user.TasksTimeByAutoCollect, 2);

            task2.AllTimeByAutoCollect += 1;
            Assert.AreEqual(task1.AllTimeByAutoCollect, 2);
            Assert.AreEqual(taskRoot.AllTimeByAutoCollect, 3);
            Assert.AreEqual(user.TasksTimeByAutoCollect, 3);

            taskRoot2.AllTimeByAutoCollect += 1;
            Assert.AreEqual(user.TasksTimeByAutoCollect, 4);

            task111.AllTimeByAutoCollect -= 1;
            Assert.AreEqual(task11.AllTimeByAutoCollect, 0);
            Assert.AreEqual(task1.AllTimeByAutoCollect, 1);
            Assert.AreEqual(taskRoot.AllTimeByAutoCollect, 2);
            Assert.AreEqual(user.TasksTimeByAutoCollect, 3);
        }
开发者ID:hardCTE,项目名称:Rafy,代码行数:49,代码来源:EntityTest.cs


示例14: TET_Query_DefaultOrderBy_TreeIndex

        public void TET_Query_DefaultOrderBy_TreeIndex()
        {
            var user = new TestUser
            {
                TestTreeTaskList =
                {
                    new TestTreeTask
                    {
                        TreeChildren =
                        {
                            new TestTreeTask
                            {
                                TreeChildren =
                                {
                                    new TestTreeTask(),
                                    new TestTreeTask(),
                                }
                            },
                            new TestTreeTask(),
                        }
                    }
                }
            };

            var repo = RF.Concrete<TestTreeTaskRepository>();
            using (RF.TransactionScope(repo))
            {
                RF.Save(user);

                var list = repo.GetByParentId(user.Id);
                for (int i = 1, c = list.Count; i < c; i++)
                {
                    var item1 = list[i - 1];
                    var item2 = list[i];
                    Assert.IsTrue(string.Compare(item1.TreeIndex, item2.TreeIndex) == -1, "默认应该按照 TreeIndex 正序排列。");
                }

                //按照 Id 排序的功能应该无效。
                var success = false;
                try
                {
                    list = repo.GetAndOrderByIdDesc2();
                    success = true;
                }
                catch { }
                Assert.IsFalse(success, "默认应该按照 TreeIndex 正序排列。");
            }
        }
开发者ID:569550384,项目名称:Rafy,代码行数:48,代码来源:TreeEntityTest.cs


示例15: BindModel

        public object BindModel(ControllerContext controllerContext,
                                ModelBindingContext bindingContext)
        {
            HttpRequestBase request = controllerContext.HttpContext.Request;

            TestUser obj = new TestUser();

            obj.UserName = request.Form["UserName"];
            obj.Company = request.Form["Company"];

            String day = request.Form["day"];
            String month = request.Form["month"];
            String year = request.Form["year"];

            obj.DOB = String.Format("{0}-{1}-{2}", day, month, year);

            return obj;
        }
开发者ID:bitf12a046,项目名称:Learn_ASPMVC-master,代码行数:18,代码来源:MoreComplexUserController.cs


示例16: DefaultAlphaNumericOnlyUserNameValidation

        public async Task DefaultAlphaNumericOnlyUserNameValidation(string userName, bool expectSuccess)
        {
            // Setup
            var manager = MockHelpers.TestUserManager(new NoopUserStore());
            var validator = new UserValidator<TestUser>();
            var user = new TestUser {UserName = userName};

            // Act
            var result = await validator.ValidateAsync(manager, user);

            // Assert
            if (expectSuccess)
            {
                IdentityResultAssert.IsSuccess(result);
            }
            else
            {
                IdentityResultAssert.IsFailure(result);
            }
        }
开发者ID:xuchrist,项目名称:Identity,代码行数:20,代码来源:UserValidatorTest.cs


示例17: VerifyAccountControllerSignIn

        public async Task VerifyAccountControllerSignIn(bool isPersistent)
        {
            var context = new Mock<HttpContext>();
            var auth = new Mock<AuthenticationManager>();
            context.Setup(c => c.Authentication).Returns(auth.Object).Verifiable();
            auth.Setup(a => a.SignInAsync(new IdentityCookieOptions().ApplicationCookieAuthenticationScheme,
                It.IsAny<ClaimsPrincipal>(),
                It.IsAny<AuthenticationProperties>())).Returns(Task.FromResult(0)).Verifiable();
            // REVIEW: is persistant mocking broken
            //It.Is<AuthenticationProperties>(v => v.IsPersistent == isPersistent))).Returns(Task.FromResult(0)).Verifiable();
            var contextAccessor = new Mock<IHttpContextAccessor>();
            contextAccessor.Setup(a => a.HttpContext).Returns(context.Object);
            var services = new ServiceCollection();
            services.AddLogging();
            services.AddSingleton(contextAccessor.Object);
            services.AddIdentity<TestUser, TestRole>();
            services.AddSingleton<IUserStore<TestUser>, InMemoryStore<TestUser, TestRole>>();
            services.AddSingleton<IRoleStore<TestRole>, InMemoryStore<TestUser, TestRole>>();
            
            var app = new ApplicationBuilder(services.BuildServiceProvider());
            app.UseCookieAuthentication();

            // Act
            var user = new TestUser
            {
                UserName = "Yolo"
            };
            const string password = "[email protected]!";
            var userManager = app.ApplicationServices.GetRequiredService<UserManager<TestUser>>();
            var signInManager = app.ApplicationServices.GetRequiredService<SignInManager<TestUser>>();

            IdentityResultAssert.IsSuccess(await userManager.CreateAsync(user, password));

            var result = await signInManager.PasswordSignInAsync(user, password, isPersistent, false);

            // Assert
            Assert.True(result.Succeeded);
            context.VerifyAll();
            auth.VerifyAll();
            contextAccessor.VerifyAll();
        }
开发者ID:xuchrist,项目名称:Identity,代码行数:41,代码来源:ControllerTest.cs


示例18: CanAllowNonAlphaNumericUserName

        public async Task CanAllowNonAlphaNumericUserName(string userName, bool expectSuccess)
        {
            // Setup
            var manager = MockHelpers.TestUserManager(new NoopUserStore());
            manager.Options.User.AllowedUserNameCharacters = null;
            var validator = new UserValidator<TestUser>();
            var user = new TestUser {UserName = userName};

            // Act
            var result = await validator.ValidateAsync(manager, user);

            // Assert
            if (expectSuccess)
            {
                IdentityResultAssert.IsSuccess(result);
            }
            else
            {
                IdentityResultAssert.IsFailure(result);
            }
        }
开发者ID:xuchrist,项目名称:Identity,代码行数:21,代码来源:UserValidatorTest.cs


示例19: TableMapping_ColumnsCount_TableWithComplexType

        public void TableMapping_ColumnsCount_TableWithComplexType()
        {
            using (var ctx = new TestContext())
            {
                var tableMapping = ctx.Db<TestUser>();

                var user = new TestUser
                {
                    FirstName = "fn",
                    LastName = "ln",
                    Contact =
                        new Contact
                        {
                            PhoneNumber = "123456",
                            Address =
                                new Address
                                {
                                    City = "Tallinn",
                                    Country = "Estonia",
                                    County = "Harju",
                                    PostalCode = "-"
                                }
                        }
                };

                Console.WriteLine("TestUser table should contain 8 columns");
                var mappings = new Dictionary<Type, IEntityMap> { { typeof(TestUser), tableMapping } };
                using (var dataTable = DataTableHelper.Create(mappings, new[] {user}))
                {
                    foreach (DataColumn column in dataTable.Columns)
                    {
                        Console.WriteLine(column.ColumnName);
                    }

                    Assert.AreEqual(8, dataTable.Columns.Count);
                }
            }
        }
开发者ID:ghost1face,项目名称:EntityFramework.BulkInsert,代码行数:38,代码来源:DataTableHelperTest.cs


示例20: BefriendEachOther

        public bool BefriendEachOther(TestUser user1, TestUser user2)
        {
            if (user1 == null)
            {
                throw new ArgumentNullException("user1");
            }

            if (user2 == null)
            {
                throw new ArgumentNullException("user2");
            }

            using (WebClient webClient = new WebClient())
            {
                string response1 = webClient.DownloadString(string.Format(APICalls.BeFriendUser, user1.Id, user2.Id, APICalls.Methods.Post, user1.AccessToken));

                string response2 = webClient.DownloadString(string.Format(APICalls.BeFriendUser, user2.Id, user1.Id, APICalls.Methods.Post, user2.AccessToken));

                bool call1 = Boolean.Parse(response1);
                bool call2 = Boolean.Parse(response2);

                return call1 && call2;
            }
        }
开发者ID:Cohaesus,项目名称:KAOS,代码行数:24,代码来源:UserClient.cs



注:本文中的TestUser类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# TestValidator类代码示例发布时间:2022-05-24
下一篇:
C# TestType类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap