本文整理汇总了C#中CommonConcepts.Test.CommonTestExecutionContext类的典型用法代码示例。如果您正苦于以下问题:C# CommonTestExecutionContext类的具体用法?C# CommonTestExecutionContext怎么用?C# CommonTestExecutionContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CommonTestExecutionContext类属于CommonConcepts.Test命名空间,在下文中一共展示了CommonTestExecutionContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: CascadeDelete
public void CascadeDelete()
{
using (var executionContext = new CommonTestExecutionContext())
{
var repository = new Common.DomRepository(executionContext);
var pid1 = Guid.NewGuid();
var pid2 = Guid.NewGuid();
var pid3 = Guid.NewGuid();
var cid11 = Guid.NewGuid();
var cid12 = Guid.NewGuid();
var cid21 = Guid.NewGuid();
var cid31 = Guid.NewGuid();
executionContext.SqlExecuter.ExecuteSql(new[]
{
"DELETE FROM TestEntity.Child",
"DELETE FROM TestEntity.BaseEntity",
"INSERT INTO TestEntity.BaseEntity (ID, Name) SELECT '" + pid1 + "', '1'",
"INSERT INTO TestEntity.BaseEntity (ID, Name) SELECT '" + pid2+ "', '2'",
"INSERT INTO TestEntity.BaseEntity (ID, Name) SELECT '" + pid3 + "', '3'",
"INSERT INTO TestEntity.Child (ID, Name, ParentID) SELECT '" + cid11 + "', '11', '" + pid1 + "'",
"INSERT INTO TestEntity.Child (ID, Name, ParentID) SELECT '" + cid12 + "', '12', '" + pid1 + "'",
"INSERT INTO TestEntity.Child (ID, Name, ParentID) SELECT '" + cid21 + "', '21', '" + pid2 + "'",
"INSERT INTO TestEntity.Child (ID, Name, ParentID) SELECT '" + cid31 + "', '31', '" + pid3 + "'",
});
Assert.AreEqual("11, 12, 21, 31", TestUtility.DumpSorted(repository.TestEntity.Child.All(), item => item.Name));
repository.TestEntity.BaseEntity.Delete(new [] { new TestEntity.BaseEntity { ID = pid1 }, new TestEntity.BaseEntity { ID = pid2 } });
Assert.AreEqual("31", TestUtility.DumpSorted(repository.TestEntity.Child.All(), item => item.Name));
}
}
开发者ID:koav,项目名称:Rhetos,代码行数:34,代码来源:EntityTest.cs
示例2: CRUD
public void CRUD()
{
using (var executionContext = new CommonTestExecutionContext())
{
var repository = new Common.DomRepository(executionContext);
var unitTestClaims = repository.Common.Claim.Query().Where(c => c.ClaimResource.StartsWith("unittest_")).ToList();
Console.WriteLine("Delete old: " + TestUtility.DumpSorted(unitTestClaims, c => c.ClaimResource + "." + c.ClaimRight) + ".");
repository.Common.Claim.Delete(unitTestClaims);
IClaimRepository cr = repository.Common.Claim;
var c1 = new Claim("unittest_c1", "c11");
var c2 = new Claim("unittest_c2", "c22");
var c3 = new Claim("unittest_c3", "c33");
cr.SaveClaims(new[] { c1, c2, c3 }, new ICommonClaim[] {}, new ICommonClaim[] {});
var loaded = cr.LoadClaims().Where(c => c.ClaimResource.StartsWith("unittest_")).ToList();
loaded.Sort((cl1, cl2) => cl1.ClaimResource.CompareTo(cl2.ClaimResource));
Assert.AreEqual("c11, c22, c33", TestUtility.Dump(loaded, c => c.ClaimRight));
loaded[0].ClaimRight = loaded[0].ClaimRight.ToUpper();
var c4 = new Claim("unittest_c4", "c44");
cr.SaveClaims(new[] { c4 }, new[] { loaded[0] }, new[] { loaded[1] });
loaded = cr.LoadClaims().Where(c => c.ClaimResource.StartsWith("unittest_")).ToList();
loaded.Sort((cl1, cl2) => cl1.ClaimResource.CompareTo(cl2.ClaimResource));
Assert.AreEqual("C11, c33, c44", TestUtility.Dump(loaded, c => c.ClaimRight));
}
}
开发者ID:koav,项目名称:Rhetos,代码行数:28,代码来源:ClaimRepositoryTest.cs
示例3: Update_Index3
public void Update_Index3()
{
using (var executionContext = new CommonTestExecutionContext())
{
executionContext.SqlExecuter.ExecuteSql(new[]
{
"DELETE FROM TestUnique.E;",
"DELETE FROM TestUnique.R;"
});
var repository = new Common.DomRepository(executionContext);
var helper = new EntityHelper(executionContext, repository);
var r1 = new TestUnique.R { S = "r1" };
var r2 = new TestUnique.R { S = "r2" };
repository.TestUnique.R.Insert(new[] { r1, r2 });
var id1 = Guid.NewGuid();
helper.Insert("a", 1, r1);
helper.Insert("b", 2, r2, id1);
helper.Update("c", 2, r2, id1);
helper.UpdateShouldFail("a", 1, r1, id1);
}
}
开发者ID:koav,项目名称:Rhetos,代码行数:25,代码来源:UniqueTest.cs
示例4: DeleteModifiedPersistentObject
public void DeleteModifiedPersistentObject()
{
using (var executionContext = new CommonTestExecutionContext())
{
executionContext.SqlExecuter.ExecuteSql(new[] { "DELETE FROM TestLockItems.Simple;" });
var repository = new Common.DomRepository(executionContext);
{
var s3Lock = new TestLockItems.Simple { ID = Guid.NewGuid(), Name = "s3_lock" };
repository.TestLockItems.Simple.Insert(new[] { s3Lock });
AssertData("s3_lock", repository);
executionContext.NHibernateSession.Clear();
AssertData("s3_lock", repository);
}
{
var s3Persistent = repository.TestLockItems.Simple.All().Single();
s3Persistent.Name = "abc";
TestUtility.ShouldFail(() => repository.TestLockItems.Simple.Delete(new[] { s3Persistent }),
"Name contains lock mark");
AssertData("s3_lock", repository);
executionContext.NHibernateSession.Clear();
AssertData("s3_lock", repository);
}
}
}
开发者ID:koav,项目名称:Rhetos,代码行数:28,代码来源:LockItemsTest.cs
示例5: ComputeForNewBaseItems_InvalidCommand
public void ComputeForNewBaseItems_InvalidCommand()
{
using (var executionContext = new CommonTestExecutionContext())
{
var repository = new Common.DomRepository(executionContext);
var d1ID = Guid.NewGuid();
var d2ID = Guid.NewGuid();
executionContext.SqlExecuter.ExecuteSql(new[]
{
"DELETE FROM Test9.Document;",
"DELETE FROM Test9.DocumentCreationInfo;",
"INSERT INTO Test9.Document (ID, Name) SELECT '" + d1ID + "', 'd1'",
"INSERT INTO Test9.Document (ID, Name) SELECT '" + d2ID + "', 'd2'",
"INSERT INTO Test9.DocumentCreationInfo (ID, Rank) SELECT '" + d1ID + "', 1",
"INSERT INTO Test9.DocumentCreationInfo (ID, Rank) SELECT '" + d2ID + "', 2",
});
Assert.AreEqual("d1:1, d2:2", ReportDocumentCreationInfo(repository), "initial");
var documents = repository.Test9.Document;
TestUtility.ShouldFail(() => documents.Insert(new[] { new Test9.Document { ID = d1ID, Name = "d1" } }), "existing");
Assert.AreEqual("d1:1, d2:2", ReportDocumentCreationInfo(repository), "creation info of previously inserted documents shoud not be changed");
// TODO: Instead of using the wrapper 'Save' function to check data validations, we should handle insert/update/delete events (NHibernate event listener) for faster and more reliable validations.
TestUtility.ShouldFail(() => documents.Update(new[] { new Test9.Document { ID = Guid.NewGuid(), Name = "d3" } }));
Assert.AreEqual("d1:1, d2:2", ReportDocumentCreationInfo(repository), "creation info of previously inserted documents shoud not be changed");
}
}
开发者ID:koav,项目名称:Rhetos,代码行数:30,代码来源:PersistedDataStructureTest.cs
示例6: SqlDependsOnSqlIndex
public void SqlDependsOnSqlIndex()
{
using (var executionContext = new CommonTestExecutionContext())
{
var features = new Dictionary<string, string>
{
{ "base", "DataStructureInfo TestSqlWorkarounds.DependencyBase" },
{ "baseA", "PropertyInfo TestSqlWorkarounds.DependencyBase.A" },
{ "baseB", "PropertyInfo TestSqlWorkarounds.DependencyBase.B" },
{ "baseBAIndex", "SqlIndexMultipleInfo TestSqlWorkarounds.DependencyBase.'B A'" },
{ "depA", "SqlObjectInfo TestSqlWorkarounds.DependencyA" },
{ "depB", "SqlObjectInfo TestSqlWorkarounds.DependencyB" },
{ "depAll", "SqlObjectInfo TestSqlWorkarounds.DependencyAll" }
};
Dictionary<Guid, string> featuresById = features
.Select(f => new { Name = f.Key, Id = ReadConceptId(f.Value, executionContext) })
.ToDictionary(fid => fid.Id, fid => fid.Name);
var deployedDependencies = ReadConceptDependencies(featuresById.Keys, executionContext)
.Select(dep => featuresById[dep.Item1] + "-" + featuresById[dep.Item2]);
var expectedDependencies = // Second concept depends on first concept.
"base-baseA, base-baseB," // Standard properties depend on their entity.
+ "base-baseBAIndex, baseA-baseBAIndex, baseB-baseBAIndex," // Standard index depends on its properties.
+ "baseA-depA,"
+ "baseB-depB, baseBAIndex-depB," // SqlDependsOnSqlIndex should be automatically included when depending on its first property.
+ "baseA-depAll, baseB-depAll,"
+ "baseBAIndex-depAll"; // SqlDependsOnSqlIndex should be automatically included when depending on its entity.
Assert.AreEqual(
TestUtility.DumpSorted(expectedDependencies.Split(',').Select(s => s.Trim()).Where(s => !string.IsNullOrEmpty(s))),
TestUtility.DumpSorted(deployedDependencies));
}
}
开发者ID:koav,项目名称:Rhetos,代码行数:35,代码来源:SqlWorkaroundsTest.cs
示例7: ActivePropertyValueDoesNotHaveToBeDefinedOnUpdate
public void ActivePropertyValueDoesNotHaveToBeDefinedOnUpdate()
{
using (var executionContext = new CommonTestExecutionContext())
{
var id1 = Guid.NewGuid();
var id2 = Guid.NewGuid();
var id3 = Guid.NewGuid();
executionContext.SqlExecuter.ExecuteSql(new[] {
"DELETE FROM TestDeactivatable.BasicEnt",
"INSERT INTO TestDeactivatable.BasicEnt (ID, Name) VALUES (" + SqlUtility.QuoteGuid(id1) + ", 'a')",
"INSERT INTO TestDeactivatable.BasicEnt (ID, Name, Active) VALUES (" + SqlUtility.QuoteGuid(id2) + ", 'b', 0)",
"INSERT INTO TestDeactivatable.BasicEnt (ID, Name) VALUES (" + SqlUtility.QuoteGuid(id3) + ", 'c')"
});
var repository = new Common.DomRepository(executionContext);
var e1 = new BasicEnt { ID = id1, Name = "a2", Active = false };
var e2 = new BasicEnt { ID = id2, Name = "b2" };
var e3 = new BasicEnt { ID = id3, Name = "c2" };
repository.TestDeactivatable.BasicEnt.Update(new[] { e1, e2, e3});
var afterUpdate = repository.TestDeactivatable.BasicEnt.All();
Assert.AreEqual(
"a2 False, b2 False, c2 True",
TestUtility.DumpSorted(afterUpdate, item => item.Name + " " + item.Active));
}
}
开发者ID:koav,项目名称:Rhetos,代码行数:25,代码来源:DeactivatableTest.cs
示例8: ComputeForNewBaseItems
public void ComputeForNewBaseItems()
{
using (var executionContext = new CommonTestExecutionContext())
{
var repository = new Common.DomRepository(executionContext);
var d1ID = Guid.NewGuid();
executionContext.SqlExecuter.ExecuteSql(new[]
{
"DELETE FROM Test9.Document;",
"DELETE FROM Test9.DocumentCreationInfo;",
"INSERT INTO Test9.Document (ID, Name) SELECT '" + d1ID + "', 'd1'"
});
Assert.AreEqual("", ReportDocumentCreationInfo(repository), "initial");
repository.Test9.DocumentCreationInfo.Recompute();
Assert.AreEqual("d1:1", ReportDocumentCreationInfo(repository), "initial recalc");
var documents = repository.Test9.Document;
var d2ID = Guid.NewGuid();
documents.Insert(new[] { new Test9.Document { ID = d2ID, Name = "d2" } });
Assert.AreEqual("d1:1, d2:2", ReportDocumentCreationInfo(repository), "autorecompute after new");
var d3ID = Guid.NewGuid();
var d4ID = Guid.NewGuid();
documents.Insert(new[] { new Test9.Document { ID = d3ID, Name = "d3" }, new Test9.Document { ID = d4ID, Name = "d4" } });
Assert.AreEqual("d1:1, d2:2, d3:4, d4:4", ReportDocumentCreationInfo(repository), "autorecompute after new2");
documents.Save(null, new[] { new Test9.Document { ID = d1ID, Name = "d1x" } }, new[] { new Test9.Document { ID = d3ID } });
Assert.AreEqual("d1x:1, d2:2, d4:4", ReportDocumentCreationInfo(repository), "autorecompute after update&delete");
}
}
开发者ID:koav,项目名称:Rhetos,代码行数:33,代码来源:PersistedDataStructureTest.cs
示例9: CreatedColumns
public void CreatedColumns()
{
using (var executionContext = new CommonTestExecutionContext())
{
var sql = @"SELECT
OBJECT_NAME(object_id) + '.' + name
FROM
sys.columns
WHERE
object_id IN (OBJECT_ID('TestCloning.Clone1'), OBJECT_ID('TestCloning.Clone2'), OBJECT_ID('TestCloning.Clone3'))
ORDER BY
1";
var expected =
@"Clone1.ID
Clone1.Start
Clone2.ID
Clone2.Name
Clone2.ParentID
Clone2.Start
Clone3.Code
Clone3.ID
Clone3.Name
Clone3.ParentID
Clone3.Start
";
var actual = new StringBuilder();
executionContext.SqlExecuter.ExecuteReader(sql, reader => actual.AppendLine(reader.GetString(0)));
Assert.AreEqual(expected, actual.ToString());
}
}
开发者ID:koav,项目名称:Rhetos,代码行数:32,代码来源:CloningTest.cs
示例10: UpdateLockedData
public void UpdateLockedData()
{
using (var executionContext = new CommonTestExecutionContext())
{
executionContext.SqlExecuter.ExecuteSql(new[] { "DELETE FROM TestLockItems.Simple;" });
var repository = new Common.DomRepository(executionContext);
var s1 = new TestLockItems.Simple { ID = Guid.NewGuid(), Name = "s1", Count = -1 };
var s2 = new TestLockItems.Simple { ID = Guid.NewGuid(), Name = "s2", Count = 1 };
repository.TestLockItems.Simple.Insert(new[] { s1, s2 });
AssertData("s1, s2", repository);
foreach (var e in new[] { s1, s2 })
e.Name = e.Name + "x";
AssertData("s1, s2", repository);
TestUtility.ShouldFail(() => repository.TestLockItems.Simple.Update(new[] { s1 }), "Name is locked if count negative.");
TestUtility.ShouldFail(() => repository.TestLockItems.Simple.Update(new[] { s2, s1 }), "Name is locked if count negative.");
TestUtility.ShouldFail(() => repository.TestLockItems.Simple.Update(new[] { s1, s2 }), "Name is locked if count negative.");
AssertData("s1, s2", repository);
repository.TestLockItems.Simple.Update(new[] { s2 });
AssertData("s1, s2x", repository);
}
}
开发者ID:koav,项目名称:Rhetos,代码行数:26,代码来源:LockPropertyTest.cs
示例11: UpdateLockedDataReference
public void UpdateLockedDataReference()
{
using (var executionContext = new CommonTestExecutionContext())
{
executionContext.SqlExecuter.ExecuteSql(new[] { "DELETE FROM TestLockItems.Simple;" });
var repository = new Common.DomRepository(executionContext);
Guid[] guids = new Guid[] { Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid() };
var s1 = new TestLockItems.Simple { ID = guids[0], Name = "s1", Count = -1 };
var s2 = new TestLockItems.Simple { ID = guids[1], Name = "s2", Count = 1 };
var t1 = new TestLockItems.Simple2 { ID = guids[2], Name = "t1", TestReference = s1, Count = -1 };
var t2 = new TestLockItems.Simple2 { ID = guids[3], Name = "t2", TestReference = s1, Count = 1 };
repository.TestLockItems.Simple.Insert(new[] { s1, s2 });
AssertData("s1, s2", repository);
repository.TestLockItems.Simple2.Insert(new[] { t1, t2 });
AssertDataSimple2("t1, t2", repository);
foreach (var e in new[] { t1, t2 })
e.TestReference = s1;
repository.TestLockItems.Simple2.Update(new[] { t1 });
AssertDataSimple2("t1, t2", repository);
foreach (var e in new[] { t1, t2 })
e.TestReference = s2;
TestUtility.ShouldFail(() => repository.TestLockItems.Simple2.Update(new[] { t1 }), "TestReference is locked if count negative.");
TestUtility.ShouldFail(() => repository.TestLockItems.Simple2.Update(new[] { t2, t1 }), "TestReference is locked if count negative.");
TestUtility.ShouldFail(() => repository.TestLockItems.Simple2.Update(new[] { t1, t2 }), "TestReference is locked if count negative.");
AssertDataSimple2("t1, t2", repository);
repository.TestLockItems.Simple2.Update(new[] { t2 });
AssertDataSimple2("t1, t2", repository);
}
}
开发者ID:koav,项目名称:Rhetos,代码行数:35,代码来源:LockPropertyTest.cs
示例12: DomRepositoryHasModuleRepositories
public void DomRepositoryHasModuleRepositories()
{
using (var executionContext = new CommonTestExecutionContext())
{
var repository = new Common.DomRepository(executionContext);
Assert.IsNotNull(repository.TestDataStructure);
}
}
开发者ID:koav,项目名称:Rhetos,代码行数:8,代码来源:ModuleRepositioryTest.cs
示例13: EmptyValuesAreAllowed
public void EmptyValuesAreAllowed()
{
using (var executionContext = new CommonTestExecutionContext())
{
var repository = new Common.DomRepository(executionContext);
var entity = new Simple { StringFrom200To249 = null };
repository.TestRegex.Simple.Insert(new[] { entity });
}
}
开发者ID:koav,项目名称:Rhetos,代码行数:9,代码来源:RegExMatchTest.cs
示例14: ShouldThowUserExceptionOnInsert
public void ShouldThowUserExceptionOnInsert()
{
using (var executionContext = new CommonTestExecutionContext())
{
var repository = new Common.DomRepository(executionContext);
var entity = new SimpleMaxLength { StringLessThan10Chars = "More than 10 characters." };
repository.TestLengthLimit.SimpleMaxLength.Insert(new[] { entity });
}
}
开发者ID:koav,项目名称:Rhetos,代码行数:9,代码来源:MaxLengthTest.cs
示例15: NormallyInsertInteger
public void NormallyInsertInteger()
{
using (var executionContext = new CommonTestExecutionContext())
{
var repository = new Common.DomRepository(executionContext);
var entity = new SimpleInteger { Value = 1 };
repository.TestMaxValue.SimpleInteger.Insert(new[] { entity });
}
}
开发者ID:koav,项目名称:Rhetos,代码行数:9,代码来源:MaxValueTest.cs
示例16: ShouldThowUserExceptionOnUpdate
public void ShouldThowUserExceptionOnUpdate()
{
using (var executionContext = new CommonTestExecutionContext())
{
var repository = new Common.DomRepository(executionContext);
var entity = new SimpleMinLength { StringMoreThan2Chars = "." };
repository.TestLengthLimit.SimpleMinLength.Update(new[] { entity });
}
}
开发者ID:koav,项目名称:Rhetos,代码行数:9,代码来源:MinLengthTest.cs
示例17: NormallyInsertDateTime
public void NormallyInsertDateTime()
{
using (var executionContext = new CommonTestExecutionContext())
{
var repository = new Common.DomRepository(executionContext);
var entity = new SimpleDateTime { Value = new DateTime(2013, 7, 5, 12, 33, 1) };
repository.TestMaxValue.SimpleDateTime.Insert(new[] { entity });
}
}
开发者ID:koav,项目名称:Rhetos,代码行数:9,代码来源:MaxValueTest.cs
示例18: NormallyInsertDecimal
public void NormallyInsertDecimal()
{
using (var executionContext = new CommonTestExecutionContext())
{
var repository = new Common.DomRepository(executionContext);
var entity = new SimpleDecimal { Value = (decimal)2.30 };
repository.TestMaxValue.SimpleDecimal.Insert(new[] { entity });
}
}
开发者ID:koav,项目名称:Rhetos,代码行数:9,代码来源:MaxValueTest.cs
示例19: ShouldThowUserExceptionOnInsert
public void ShouldThowUserExceptionOnInsert()
{
using (var executionContext = new CommonTestExecutionContext())
{
var repository = new Common.DomRepository(executionContext);
var entity = new SimpleRange { FromValue = 1, ToValue = 0 };
repository.TestRange.SimpleRange.Insert(new[] { entity });
}
}
开发者ID:koav,项目名称:Rhetos,代码行数:9,代码来源:RangeTest.cs
示例20: ShouldInsertNormallyJustOneDate
public void ShouldInsertNormallyJustOneDate()
{
using (var executionContext = new CommonTestExecutionContext())
{
var repository = new Common.DomRepository(executionContext);
var entity = new DateRangeWithoutDef { FromDate = DateTime.Today };
var entity2 = new DateRangeWithoutDef { ToDate = DateTime.Today };
repository.TestRange.DateRangeWithoutDef.Insert(new[] { entity, entity2 });
}
}
开发者ID:koav,项目名称:Rhetos,代码行数:10,代码来源:RangeTest.cs
注:本文中的CommonConcepts.Test.CommonTestExecutionContext类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论