本文整理汇总了C#中TestEntity类的典型用法代码示例。如果您正苦于以下问题:C# TestEntity类的具体用法?C# TestEntity怎么用?C# TestEntity使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TestEntity类属于命名空间,在下文中一共展示了TestEntity类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EqualsWithNewObjectsUsesReferenceEquals
public void EqualsWithNewObjectsUsesReferenceEquals()
{
// Arrange
var ent1 = new TestEntity();
var ent2 = new TestEntity();
// Act
bool different = ent1.Equals( ent2 );
bool different2 = ent2.Equals( ent1 );
bool different3 = ent1 == ent2;
bool equal3 = ent1 != ent2;
var ent3 = ent1;
bool equal = ent1.Equals( ent3 );
bool equal2 = ent3.Equals( ent1 );
bool equal4 = ent1 == ent3;
bool different4 = ent1 != ent3;
// Assert
Assert.IsFalse( different );
Assert.IsFalse( different2 );
Assert.IsFalse( different3 );
Assert.IsFalse( different4 );
Assert.IsTrue( equal );
Assert.IsTrue( equal2 );
Assert.IsTrue( equal3 );
Assert.IsTrue( equal4 );
}
示例2: SetEntityId
private static void SetEntityId(TestEntity entity, long id)
{
var idProperty = entity.GetType()
.GetProperty("Id", BindingFlags.Instance | BindingFlags.Public);
var setter = idProperty.SetMethod;
setter.Invoke(entity, new object[] { id });
}
示例3: IntersectTest
public void IntersectTest()
{
var a = new TestEntity(Vector2.Zero, new Vector2(10, 10));
var b = new TestEntity(Vector2.Zero, new Vector2(10, 10));
Assert.IsTrue(a.Intersects(b));
a.Position = new Vector2(9, 9);
Assert.IsTrue(a.Intersects(b));
a.Position = new Vector2(-9, -9);
Assert.IsTrue(a.Intersects(b));
a.Position = new Vector2(-9, 0);
Assert.IsTrue(a.Intersects(b));
a.Position = new Vector2(0, -9);
Assert.IsTrue(a.Intersects(b));
a.Position = new Vector2(-11, -11);
Assert.IsFalse(a.Intersects(b));
a.Position = new Vector2(-11, 0);
Assert.IsFalse(a.Intersects(b));
a.Position = new Vector2(0, -11);
Assert.IsFalse(a.Intersects(b));
a.Position = new Vector2(11, 11);
Assert.IsFalse(a.Intersects(b));
}
示例4: Context
public virtual void Context()
{
Entity = new TestEntity();
Session = Mock<ISession>();
var unitOfWork = CreateUnitOfWorkWithStartedTransaction();
Repository = new NhibernateRepository<TestEntity>(unitOfWork);
}
示例5: When_include_has_no_conflicts_happy_path
public void When_include_has_no_conflicts_happy_path()
{
var entity1 = new TestEntity("INV-0001");
var entity2 = new TestEntity("INV-0002");
EventData[] events =
{
CreateEvent("e1", Include.Insert(entity1)),
CreateEvent("e2", Include.Insert(entity2))
};
var result = Stream.Write(new Stream(partition), events);
var stored = RetrieveTestEntity(entity1.RowKey);
Assert.That(stored, Is.Not.Null);
stored = RetrieveTestEntity(entity2.RowKey);
Assert.That(stored, Is.Not.Null);
Assert.That(result.Includes.Length, Is.EqualTo(2));
Assert.That(result.Includes[0], Is.SameAs(entity1));
Assert.That(result.Includes[0].ETag, Is.Not.Null.Or.Empty);
Assert.That(result.Includes[1], Is.SameAs(entity2));
Assert.That(result.Includes[1].ETag, Is.Not.Null.Or.Empty);
}
示例6: Entity_ConstructorAssignsValues
public void Entity_ConstructorAssignsValues()
{
var guid = Guid.NewGuid();
var entity = new TestEntity(guid);
entity.Id.Should().Be(guid);
}
示例7: GetHashCode_returns_hash_code_of_Id
public void GetHashCode_returns_hash_code_of_Id()
{
var entity = new TestEntity();
long id = 2;
SetEntityId(entity, id);
Assert.AreEqual(id.GetHashCode(), entity.GetHashCode());
}
示例8: GivenValueDoesNotMatchInvalidValue_AndValidationContext_WhenValidate_ThenSucceed
public void GivenValueDoesNotMatchInvalidValue_AndValidationContext_WhenValidate_ThenSucceed()
{
TestEntity toValidate = new TestEntity { Value = "not invalid" };
ValidationContext validationContext = new ValidationContext(toValidate) { DisplayName = "Test Entity Value", MemberName = "Value" };
Target.Validate(toValidate.Value, validationContext);
}
示例9: GetHashCode_uses_hash_code_that_was_generated_pre_id_set
public void GetHashCode_uses_hash_code_that_was_generated_pre_id_set()
{
var entity = new TestEntity();
var hash = entity.GetHashCode();
SetEntityId(entity, 1);
Assert.AreEqual(hash, entity.GetHashCode());
}
示例10: ComparisonAttributeTest
public ComparisonAttributeTest()
{
_validEntity = new TestEntity { FirstProperty = 10, SecondProperty = 10 };
_invalidEntity = new TestEntity {FirstProperty = 10, SecondProperty = 20};
_attribute = new ComparisonAttribute("SecondProperty", ComparisonAttribute.ComparisonCondition.Equal);
_attribute.ErrorMessage = _errorMessage;
}
示例11: Test_UpperCase_BulkInsert
public void Test_UpperCase_BulkInsert()
{
// Use Upper Case Schema Name:
subject = new PostgreSQLCopyHelper<TestEntity>("SAMPLE", "UNIT_TEST")
.MapSmallInt("col_smallint", x => x.SmallInt);
// Try to work with the Bulk Inserter:
var entity0 = new TestEntity()
{
SmallInt = Int16.MinValue
};
var entity1 = new TestEntity()
{
SmallInt = Int16.MaxValue
};
subject.SaveAll(connection, new[] { entity0, entity1 });
var result = connection.GetAll("sample", "unit_test");
// Check if we have the amount of rows:
Assert.AreEqual(2, result.Count);
Assert.IsNotNull(result[0][0]);
Assert.IsNotNull(result[1][0]);
Assert.AreEqual(Int16.MinValue, (Int16)result[0][0]);
Assert.AreEqual(Int16.MaxValue, (Int16)result[1][0]);
}
示例12: Castle
public void Castle()
{
SystemConfig.ConfigFilesAssemblyName = "CodeSharp.Framework.Castles.Test";
SystemConfig.Configure("ConfigFiles")
.Castle()
.BusinessDependency(Assembly.GetExecutingAssembly());
Assert.AreEqual("abc", SystemConfig.Settings["key1"]);
Assert.DoesNotThrow(() => DependencyResolver.Resolve<ILoggerFactory>().Create(this.GetType()).Info("hi"));
Assert.DoesNotThrow(() => DependencyResolver.Resolve<ITestService>());
Assert.DoesNotThrow(() => DependencyResolver.Resolve<NHibernate.ISessionFactory>());
//NH Tests
var e = new TestEntity("abc");
var s = DependencyResolver.Resolve<ITestService>();
s.Create(e);
DependencyResolver.Resolve<Castle.Facilities.NHibernateIntegration.ISessionManager>().OpenSession().Evict(e);
var e2= s.Get(e.ID);
//private setter?
Assert.AreEqual(e.Name, e2.Name);
Assert.AreEqual("abc", e2.Name);
Assert.DoesNotThrow(() => SystemConfig.Cleanup());
}
示例13: EntitiesWithDifferentIdShouldNotBeEqual
public void EntitiesWithDifferentIdShouldNotBeEqual()
{
var entity1 = new TestEntity(Guid.NewGuid());
var entity2 = new TestEntity(Guid.NewGuid());
Assert.IsFalse(entity1.Equals(entity2));
}
示例14: Should_validate
public void Should_validate()
{
var testEntity = new TestEntity();
repository.Expect(x => x.GetById(3)).Return(testEntity);
binder.BindModel(controllerContext, context);
validatingBinder.AssertWasCalled(x => x.UpdateFrom(testEntity, controllerContext.HttpContext.Request.Form, context.ModelState, "foo"));
}
示例15: GivenNumbersEqual_AndAllowEquality_AndValidationContext_WhenValidate_ThenSucceed
public void GivenNumbersEqual_AndAllowEquality_AndValidationContext_WhenValidate_ThenSucceed()
{
TestEntity toValidate = new TestEntity { Value = "10" };
ValidationContext validationContext = new ValidationContext(toValidate) { DisplayName = "Test Entity Value", MemberName = "Value" };
var target = new NumericGreaterThanAttribute("Value") { AllowEquality = true };
target.Validate("10", validationContext);
}