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


C# Versioning.Company类代码示例

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


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

示例1: CanReadDocumentWhichWasNotSecured

		public void CanReadDocumentWhichWasNotSecured()
		{
			var company = new Company
			{
				Name = "Hibernating Rhinos"
			};
			using (var s = store.OpenSession())
			{
				s.Store(new AuthorizationUser
				{
					Id = UserId,
					Name = "Ayende Rahien",
				});

				s.Store(company);

				// by not specifying that, we say that anyone can read this
				//s.SetAuthorizationFor(company, new DocumentAuthorization());

				s.SaveChanges();
			}

			using (var s = store.OpenSession())
			{
				s.SecureFor(UserId, "Company/Bid");

				Assert.NotNull(s.Load<Company>(company.Id));
			}
		}
开发者ID:JPT123,项目名称:ravendb,代码行数:29,代码来源:Reading.cs

示例2: Will_limit_replication_history_size_on_items_marked_with_not_for_replication

		public void Will_limit_replication_history_size_on_items_marked_with_not_for_replication()
		{
			var store1 = CreateStore();

			using (var session = store1.OpenSession())
			{
				var entity = new Company {Name = "Hibernating Rhinos"};
				session.Store(entity);
				session.Advanced.GetMetadataFor(entity)["Raven-Not-For-Replication"] = "true";
				session.SaveChanges();
			}

			for (int i = 0; i < 100; i++)
			{
				using (var session = store1.OpenSession())
				{
					var company = session.Load<Company>(1);
					company.Name = i%2 == 0 ? "a" : "b";
					session.SaveChanges();
				}
			}

			using (var session = store1.OpenSession())
			{
				var company = session.Load<Company>(1);
				var ravenJArray = session.Advanced.GetMetadataFor(company).Value<RavenJArray>(Constants.RavenReplicationHistory);
				Assert.Equal(50, ravenJArray.Length);
			}

		}
开发者ID:arelee,项目名称:ravendb,代码行数:30,代码来源:SimpleReplication.cs

示例3: WillAbortDeleteIfUserDoesNotHavePermissions

		public void WillAbortDeleteIfUserDoesNotHavePermissions()
		{
			var company = new Company
			{
				Name = "Hibernating Rhinos"
			};
			using (var s = store.OpenSession())
			{
				s.Store(new AuthorizationUser
				{
					Id = UserId,
					Name = "Ayende Rahien",
				});

				s.Store(company);

				s.SetAuthorizationFor(company, new DocumentAuthorization());// deny everyone

				s.SaveChanges();
			}

			using (var s = store.OpenSession())
			{
				s.SecureFor(UserId, "Company/Rename");

				Assert.Throws<InvalidOperationException>(() => s.Advanced.DatabaseCommands.Delete(company.Id, null));
			}
		}
开发者ID:jtmueller,项目名称:ravendb,代码行数:28,代码来源:Deleting.cs

示例4: CannotReadDocumentWithoutPermissionToIt

		public void CannotReadDocumentWithoutPermissionToIt()
		{
			var company = new Company
			{
				Name = "Hibernating Rhinos"
			};
			using (var s = store.OpenSession())
			{
				s.Store(new AuthorizationUser
				{
					Id = UserId,
					Name = "Ayende Rahien",
				});

				s.Store(company);

				s.SetAuthorizationFor(company, new DocumentAuthorization());// deny everyone

				s.SaveChanges();
			}

			using (var s = store.OpenSession())
			{
				s.SecureFor(UserId, "Company/Bid");

				var readVetoException = Assert.Throws<ReadVetoException>(() => s.Load<Company>(company.Id));

				Assert.Equal(@"Document could not be read because of a read veto.
The read was vetoed by: Raven.Bundles.Authorization.Triggers.AuthorizationReadTrigger
Veto reason: Could not find any permissions for operation: Company/Bid on companies/1 for user Authorization/Users/Ayende.
No one may perform operation Company/Bid on companies/1
", readVetoException.Message);
			}
		}
开发者ID:JPT123,项目名称:ravendb,代码行数:34,代码来源:Reading.cs

示例5: BugWhenSavingDocumentWithPreviousAuthorization_WithQuery

        public void BugWhenSavingDocumentWithPreviousAuthorization_WithQuery()
        {
            var company = new Company
            {
                Name = "Hibernating Rhinos"
            };
            using (var s = store.OpenSession())
            {
                s.Store(new AuthorizationUser
                {
                    Id = UserId,
                    Name = "Ayende Rahien",
                });

                s.Store(company);

                s.SetAuthorizationFor(company, new DocumentAuthorization
                {
                    Permissions =
                                       {
                                               new DocumentPermission
                                               {
                                                       User = UserId,
                                                       Allow = true,
                                                       Operation = "Company/Bid"
                                               }
                                       }
                });

                s.SaveChanges();
            }

            for (int i = 0; i < 15; i++)
            {
                using (var s = store.OpenSession())
                {
                    s.SecureFor(UserId, "Company/Bid");

                    var c = s.Query<Company>().Customize(x => x.WaitForNonStaleResults()).First();
                    c.Name = "other " + i;

                    s.SaveChanges();
                }

            }

            using (var s = store.OpenSession())
            {
                s.SecureFor(UserId, "Company/Bid");

                var load = s.Load<Company>(company.Id);
                Assert.NotNull(load);
                Assert.Equal("other 14", load.Name);
            }
        }
开发者ID:vinone,项目名称:ravendb,代码行数:55,代码来源:LoadingSavedInfo.cs

示例6: BugWhenUpdatingUserRolesQuery

		public void BugWhenUpdatingUserRolesQuery()
		{
			var company = new Company
			{
				Name = "Hibernating Rhinos"
			};
			using (var s = store.OpenSession())
			{
				s.Store(new AuthorizationUser
				{
					Id = UserId,
					Name = "Ayende Rahien",
				});

				s.Store(company);

				s.SetAuthorizationFor(company, new DocumentAuthorization
				{
					Permissions =
                        {
                            new DocumentPermission
                            {
                                Role = "Admins",
                                Allow = true,
                                Operation = "Company/Bid"
                            }
                        }
				});

				s.SaveChanges();
			}

			using (var s = store.OpenSession())
			{
				s.SecureFor(UserId, "Company/Bid");

				Assert.Empty(s.Query<Company>().ToArray());
			}

			using (var s = store.OpenSession())
			{
				var user = s.Load<AuthorizationUser>(UserId);
				user.Roles = new List<string> { "Admins" };
				s.SaveChanges();
			}

			using (var s = store.OpenSession())
			{
				s.SecureFor(UserId, "Company/Bid");

				Assert.NotEmpty(s.Query<Company>().ToArray());
		
			}
		}
开发者ID:nzdunic,项目名称:ravendb,代码行数:54,代码来源:WithChangingOfUser.cs

示例7: CanAskWhateverUserHavePermissions

		public void CanAskWhateverUserHavePermissions()
		{
			var company = new Company
			{
				Name = "Hibernating Rhinos"
			};
			using (var s = store.OpenSession())
			{
				s.Store(new AuthorizationUser
				{
					Id = UserId,
					Name = "Ayende Rahien",
				});

				s.Store(company);

				s.SetAuthorizationFor(company, new DocumentAuthorization
				{
					Permissions =
						{
							new DocumentPermission
							{
								Role = "Admins",
								Allow = true,
								Operation = "Company/Bid"
							}
						}
				});

				s.SaveChanges();
			}

			using (var s = store.OpenSession())
			{
				var isOperationAllowedOnDocument = s.Advanced.IsOperationAllowedOnDocument(UserId, "Company/Bid", "companies/1");
				Assert.False(isOperationAllowedOnDocument.IsAllowed);
				Assert.Equal("Could not find any permissions for operation: Company/Bid on companies/1 for user Authorization/Users/Ayende.\r\nOnly the following may perform operation Company/Bid on companies/1:\r\n\tOperation: Company/Bid, User: , Role: Admins, Allow: True, Priority: 0\r\n",
					isOperationAllowedOnDocument.Reasons[0]);
			}

			using (var s = store.OpenSession())
			{
				var user = s.Load<AuthorizationUser>(UserId);
				user.Roles = new List<string> { "Admins" };
				s.SaveChanges();
			}

			using (var s = store.OpenSession())
			{
				var isOperationAllowedOnDocument = s.Advanced.IsOperationAllowedOnDocument(UserId, "Company/Bid", "companies/1");
				Assert.True(isOperationAllowedOnDocument.IsAllowed);
				Assert.Equal(new[] { "Operation: Company/Bid, User: , Role: Admins, Allow: True, Priority: 0" }, isOperationAllowedOnDocument.Reasons.ToArray());
			}
		}
开发者ID:shiranGinige,项目名称:ravendb,代码行数:54,代码来源:CanAskAuthQuestions.cs

示例8: Will_automatically_set_metadata

        public void Will_automatically_set_metadata()
        {
            var company = new Company {Name = "Company Name"};
            using (var session = documentStore.OpenSession())
            {
                session.Store(company);
                session.SaveChanges();
            }

            using (var session = documentStore.OpenSession())
            {
                var company2 = session.Load<Company>(company.Id);
                var metadata = session.Advanced.GetMetadataFor(company2);
                Assert.Equal("Current", metadata.Value<string>("Raven-Document-Revision-Status"));
                Assert.Equal(1, metadata.Value<int>("Raven-Document-Revision"));
            }
        }
开发者ID:nzdunic,项目名称:ravendb,代码行数:17,代码来源:Versioning.cs

示例9: Will_automatically_craete_duplicate_on_first_insert

		public void Will_automatically_craete_duplicate_on_first_insert()
		{
			var company = new Company {Name = "Company Name"};
			using (var session = documentStore.OpenSession())
			{
				session.Store(company);
				session.SaveChanges();
			}

			using (var session = documentStore.OpenSession())
			{
				var company2 = session.Load<Company>(company.Id + "/revisions/1");
				var metadata = session.Advanced.GetMetadataFor(company2);
				Assert.Equal(company.Name, company2.Name);
				Assert.Equal("Historical", metadata.Value<string>("Raven-Document-Revision-Status"));
			}
		}
开发者ID:neiz,项目名称:ravendb,代码行数:17,代码来源:Versioning.cs

示例10: StoreAndLoad

		public void StoreAndLoad()
		{
			const string CompanyName = "Company Name";
			var company = new Company { Name = CompanyName };
			using (var session = documentStore.OpenSession())
			{
				session.Store(company);
				session.SaveChanges();
			}

			using (var session = documentStore.OpenSession())
			{
				Assert.Equal(CompanyName, session.Load<Company>(1).Name);
			}

			AssertPlainTextIsNotSavedInDatabase_ExceptIndexes(CompanyName);
		}
开发者ID:arelee,项目名称:ravendb,代码行数:17,代码来源:Crud.cs

示例11: Can_add_entity_with_expiry_then_read_it_before_it_expires

		public void Can_add_entity_with_expiry_then_read_it_before_it_expires()
		{
			var company = new Company {Name = "Company Name"};
			var expiry = DateTime.UtcNow.AddMinutes(5);
			using (var session = documentStore.OpenSession())
			{
				session.Store(company);
				session.Advanced.GetMetadataFor(company)["Raven-Expiration-Date"] = new RavenJValue(expiry);
				session.SaveChanges();
			}

			using (var session = documentStore.OpenSession())
			{
				var company2 = session.Load<Company>(company.Id);
				Assert.NotNull(company2);
				var metadata = session.Advanced.GetMetadataFor(company2);
				Assert.Equal(expiry.ToString(), metadata.Value<DateTime>("Raven-Expiration-Date").ToString());
			}
		}
开发者ID:neiz,项目名称:ravendb,代码行数:19,代码来源:Expiration.cs

示例12: GivingPermissionToRoleOnTagAssociatedWithRoleWillAllow

        public void GivingPermissionToRoleOnTagAssociatedWithRoleWillAllow()
        {
            var company = new Company
            {
                Name = "Hibernating Rhinos"
            };
            using (var s = store.OpenSession())
            {
                s.Store(new AuthorizationUser
                {
                    Id = userId,
                    Name = "Ayende Rahien",
                    Roles = { "Authorization/Roles/Managers" }
                });

                s.Store(new AuthorizationRole
                {
                    Id = "Authorization/Roles/Managers",
                    Permissions =
						{
							new OperationPermission
							{
								Allow = true,
								Operation = operation,
								Tag = "Fortune 500"
							}
						}
                });

                s.Store(company);

                s.SetAuthorizationFor(company, new DocumentAuthorization
                {
                    Tags = { "Fortune 500" }
                });

                s.SaveChanges();
            }

            var jsonDocument = server.Database.Get(company.Id, null);
            var isAllowed = authorizationDecisions.IsAllowed(userId, operation, company.Id, jsonDocument.Metadata, null);
            Assert.True(isAllowed);
        }
开发者ID:nzdunic,项目名称:ravendb,代码行数:43,代码来源:CanHandleAuthQuestions.cs

示例13: After_expiry_passed_document_will_be_physically_deleted

        public void After_expiry_passed_document_will_be_physically_deleted()
        {
            var company = new Company
            {
                Id = "companies/1",
                Name = "Company Name"
            };
            var expiry = DateTime.UtcNow.AddMinutes(5);
            using (var session = documentStore.OpenSession())
            {
                session.Store(company);
                session.Advanced.GetMetadataFor(company)["Raven-Expiration-Date"] = new JValue(expiry);
                session.SaveChanges();

                session.Advanced.LuceneQuery<Company>("Raven/DocumentsByExpirationDate")
                    .WaitForNonStaleResults()
                    .ToList();
            }
            ExpirationReadTrigger.GetCurrentUtcDate = () => DateTime.UtcNow.AddMinutes(10);

            using (var session = documentStore.OpenSession())
            {
                session.Store(new Company
                {
                    Id = "companies/2",
                    Name = "Company Name"
                });
                session.SaveChanges(); // this forces the background task to run
            }

            JsonDocument documentByKey = null;
            for (int i = 0; i < 15; i++)
            {
                ravenDbServer.Database.TransactionalStorage.Batch(accessor =>
                {
                    documentByKey = accessor.Documents.DocumentByKey("companies/1", null);
                });
                if (documentByKey == null)
                    return;
                Thread.Sleep(100);
            }
            Assert.False(true, "Document was not deleted");
        }
开发者ID:vinone,项目名称:ravendb,代码行数:43,代码来源:Expiration.cs

示例14: BugWhenSavingDocumentOnDatabase

		public void BugWhenSavingDocumentOnDatabase()
		{
			string database = "test_auth";
			store.DatabaseCommands.EnsureDatabaseExists(database);

			var company = new Company
			{
				Name = "Hibernating Rhinos"
			};
			using (var s = store.OpenSession(database))
			{
				s.Store(new AuthorizationUser
				{
					Id = UserId,
					Name = "Ayende Rahien",
				});

				s.Store(company);

				s.SetAuthorizationFor(company, new DocumentAuthorization
				{
					Permissions =
						{
							new DocumentPermission
							{
								User = UserId,
								Allow = true,
								Operation = "Company/Bid"
							}
						}
				});

				s.SaveChanges();
			}

			using (var s = store.OpenSession(database))
			{
				s.SecureFor(UserId, "Company/Bid");

				Assert.NotNull(s.Load<Company>(company.Id));
			}
		}
开发者ID:neiz,项目名称:ravendb,代码行数:42,代码来源:WhenUsingMultiTenancy.cs

示例15: Can_add_entity_with_expiry_then_read_it_before_it_expires

        public void Can_add_entity_with_expiry_then_read_it_before_it_expires()
        {
            var company = new Company {Name = "Company Name"};
            var expiry = DateTime.UtcNow.AddMinutes(5);
            using (var session = documentStore.OpenSession())
            {
                session.Store(company);
                session.Advanced.GetMetadataFor(company)["Raven-Expiration-Date"] = new JValue(expiry);
                session.SaveChanges();
            }

            using (var session = documentStore.OpenSession())
            {
                var company2 = session.Load<Company>(company.Id);
                Assert.NotNull(company2);
                var metadata = session.Advanced.GetMetadataFor(company2);
                var dateAsJsStr = @"\/Date("+(long)( expiry - new DateTime(1970,1,1) )[email protected]")\/";
                Assert.Equal(dateAsJsStr, metadata.Value<string>("Raven-Expiration-Date"));
            }
        }
开发者ID:VirtueMe,项目名称:ravendb,代码行数:20,代码来源:Expiration.cs


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