public void GetPropertyValueShouldReturnProperValueForProperty() { var name = "Test"; var entity = new TestEntity { Name = name }; var result = ObjectExtensions.GetPropertyValue(entity, "Name"); Assert.AreEqual(name, result); }
public void SetPropertyValueShouldSetTheProperty() { var name = "Test"; var entity = new TestEntity(); ObjectExtensions.SetPropertyValue(entity, "Name", name); var result = entity.Name; Assert.AreEqual(name, result); }
public void EntityWithPropertyRequirementsMetMustBeValid() { var entity = new TestEntity(); entity.Name = "Test"; entity.Number = 10; entity.Date = DateTime.Now; bool result = entity.IsValid; Assert.IsTrue(result); }
public static TestEntity GetEntity() { var entity = new TestEntity(); entity.Name = "Test"; entity.Number = 5; entity.Value = 2.5; entity.Date = DateTime.Now.Date; entity.IsActive = true; return entity; }
public void EntityWithoutPropertyRequirementsMustBeInvalid() { var entity = new TestEntity(); bool result = entity.IsValid; Assert.IsFalse(result); }
public static List<TestEntity> GetEntityList() { List<TestEntity> list = new List<TestEntity>(); var entity = new TestEntity(); entity.Id = 1; entity.Name = "Rutger"; entity.Number = 5; entity.Value = 2.5; entity.Price = 2.75m; entity.Date = DateTime.Now.Date; entity.IsActive = true; list.Add(entity); entity = new TestEntity(); entity.Id = 2; entity.Name = "Sanne"; entity.Number = 10; entity.Value = 5; entity.Price = 3.40m; entity.Date = DateTime.Now.AddDays(5).Date; entity.IsActive = false; list.Add(entity); entity = new TestEntity(); entity.Id = 3; entity.Name = "Magnus"; entity.Number = 15; entity.Value = 7.5; entity.Price = 4.80m; entity.Date = DateTime.Now.AddDays(10).Date; entity.IsActive = true; list.Add(entity); entity = entity = new TestEntity(); entity.Id = 4; entity.Name = "Dagmar"; entity.Number = 20; entity.Value = 10; entity.Price = 5.95m; entity.Date = DateTime.Now.AddDays(15).Date; entity.IsActive = false; list.Add(entity); entity = entity = new TestEntity(); entity.Id = 5; entity.Name = "Sam"; entity.Number = 25; entity.Value = 12.5; entity.Price = 6.50m; entity.Date = DateTime.Now.AddDays(20).Date; entity.IsActive = true; list.Add(entity); entity = entity = new TestEntity(); entity.Id = 6; entity.Name = "Sien"; entity.Number = 30; entity.Value = 15; entity.Price = 7.70m; entity.Date = DateTime.Now.AddDays(25).Date; entity.IsActive = false; list.Add(entity); return list; }
public void HasPropertyShouldReturnTrueWhenTheEntityHasAProperty() { var entity = new TestEntity(); var result = ObjectExtensions.HasProperty(entity, "Name"); Assert.AreEqual(true, result); }
public void HasPropertyShouldReturnFalseWhenTheEntityDoesNotHaveAProperty() { var entity = new TestEntity(); var result = ObjectExtensions.HasProperty(entity, "NotExist"); Assert.AreEqual(false, result); }
public void QueryWithRelationsShouldReturnEntitiesWithRelations() { var source = new TestDataSource(); int id = 0; var customField = new TestCustomField { Name = "Test", FieldType = CustomFieldType.String, GroupId = Guid.NewGuid() }; source.Save(customField); source.SaveChanges(); var entity = new TestEntity { Name = "Test generated 1", Number = 1, CustomFields = new List<TestCustomFieldValue> { new TestCustomFieldValue { StringValue = "Test", Culture = "en", CustomField = customField, CustomFieldId = customField.Id } } }; source.Save(entity); source.SaveChanges(); id = entity.Id; var newSource = new TestDataSource(); var result = newSource.Query<TestEntity>().Include(c => c.CustomFields).First(t => t.Id == id); Assert.IsNotNull(result.CustomFields); Assert.AreEqual("Test", result.CustomFields.First().StringValue); newSource.Delete(result); newSource.SaveChanges(); }