当前位置: 首页>>代码示例>>C#>>正文


C# TestUser类代码示例

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


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


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