public void Test_GetEntitiesByPropertyValue_Exclusion() { using (LogGroup logGroup = LogGroup.Start("Testing exclusion with the GetEntities by property value function.", NLog.LogLevel.Debug)) { EntityOne e1 = new EntityOne(); e1.Name = "Test E1"; //FilterGroup filterGroup = new FilterGroup(); //filterGroup.Operator PropertyFilter filter = (PropertyFilter)DataAccess.Data.CreateFilter(typeof(PropertyFilter)); filter.Operator = FilterOperator.Equal; filter.PropertyName = "Name"; filter.PropertyValue = "Another Name"; DataAccess.Data.Saver.Save(e1); IEntity[] found = DataAccess.Data.Indexer.GetEntities <EntityOne>("Name", "Another Name"); Assert.IsNotNull(found, "Null array returned."); if (found != null) { Assert.AreEqual(0, found.Length, "Entities weren't properly excluded."); } } }
public void Test_GetEntitiesByParameterDictionary_Exclude() { using (LogGroup logGroup = LogGroup.Start("Testing the GetEntities<T>(IDictionary<string, object>) function to ensure it excludes entities properly.", NLog.LogLevel.Debug)) { EntityOne e1 = new EntityOne(); e1.Name = "Test E1"; DataAccess.Data.Saver.Save(e1); Dictionary <string, object> parameters = new Dictionary <string, object>(); parameters.Add("Name", "Test E2"); EntityOne[] found = (EntityOne[])DataAccess.Data.Indexer.GetEntities <EntityOne>(parameters); Assert.IsNotNull(found, "The return value is null."); if (found != null) { Assert.AreEqual(0, found.Length, "Entities weren't properly excluded."); } DataAccess.Data.Deleter.Delete(e1); } }
public void Test_GetMirrorPropertyName_Single_Implicit_Sync() { EntityOne e1 = new EntityOne(); string mirrorPropertyName = EntitiesUtilities.GetMirrorPropertyName(e1, e1.GetType().GetProperty("SingleReferenceProperty")); Assert.AreEqual(String.Empty, mirrorPropertyName, "The mirror property name wasn't determined correctly."); }
public void Test_IsMultipleReference_False() { EntityOne e1 = new EntityOne(); PropertyInfo property = e1.GetType().GetProperty("SingleReferenceProperty"); Assert.IsFalse(EntitiesUtilities.IsMultipleReference(e1.GetType(), property), "Returned true when it should have returned false."); }
public void Test_GetMethod_MismatchArgument() { EntityOne e = new EntityOne(); e.ID = Guid.NewGuid(); MethodInfo method = Reflector.GetMethod(e, "DoSomething", new Type[] { typeof(string) }, new Type[] { typeof(IEntity) }); Assert.IsNull(method); }
public void Test_ParametersMatch_InvalidCount() { EntityOne e = new EntityOne(); e.ID = Guid.NewGuid(); MethodInfo method = e.GetType().GetMethod("DoSomething"); Type[] expectedParameters = new Type[] {}; bool match = Reflector.ParametersMatch(method, method.GetGenericArguments(), expectedParameters); Assert.IsFalse(match); }
public void Should_use_the_right_map() { var source = new EntityOne { Two = new EntityTwo { Ones = new List<EntityOne> { new EntityOne { Two = new EntityTwo { Ones = new List<EntityOne>() } } } } }; Mapper.Map<EntityOne, DtoOne>(source).ShouldBeType<DtoOne>(); Mapper.Map<EntityOne, DtoThree>(source).ShouldBeType<DtoThree>(); }
public void Test_ParametersMatch() { EntityOne e = new EntityOne(); e.ID = Guid.NewGuid(); MethodInfo method = e.GetType().GetMethod("DoSomething"); MethodInfo cMethod = method.MakeGenericMethod(typeof(IEntity)); Type[] expectedParameters = new Type[] { typeof(IEntity) }; bool match = Reflector.ParametersMatch(cMethod, cMethod.GetGenericArguments(), expectedParameters); Assert.IsTrue(match); }
public void Test_ArgumentsMatch_InvalidType() { EntityOne e = new EntityOne(); e.ID = Guid.NewGuid(); MethodInfo method = e.GetType().GetMethod("DoSomething"); MethodInfo cMethod = method.MakeGenericMethod(typeof(IEntity)); Type[] expectedArguments = new Type[] {typeof(string)}; Type[] arguments = cMethod.GetGenericArguments(); bool match = Reflector.ArgumentsMatch(cMethod, expectedArguments); Assert.IsFalse(match); }
public void Test_ArgumentsMatch_Direct() { EntityOne e = new EntityOne(); e.ID = Guid.NewGuid(); Type[] typeArguments = new Type[] {typeof(IEntity)}; MethodInfo method = e.GetType().GetMethod("DoSomething"); MethodInfo cMethod = method.MakeGenericMethod(typeArguments); Type[] expectedArguments = new Type[] {typeof(IEntity)}; bool match = Reflector.ArgumentsMatch(cMethod, expectedArguments); Assert.IsTrue(match); }
public void Test_ArgumentsMatch_InvalidType() { EntityOne e = new EntityOne(); e.ID = Guid.NewGuid(); MethodInfo method = e.GetType().GetMethod("DoSomething"); MethodInfo cMethod = method.MakeGenericMethod(typeof(IEntity)); Type[] expectedArguments = new Type[] { typeof(string) }; Type[] arguments = cMethod.GetGenericArguments(); bool match = Reflector.ArgumentsMatch(cMethod, expectedArguments); Assert.IsFalse(match); }
public void Test_ArgumentsMatch_Assignable() { EntityOne e = new EntityOne(); e.ID = Guid.NewGuid(); Type[] typeArguments = new Type[] { typeof(IEntity) }; MethodInfo method = e.GetType().GetMethod("DoSomething"); MethodInfo cMethod = method.MakeGenericMethod(typeArguments); Type[] expectedArguments = new Type[] { typeof(EntityTwo) }; bool match = Reflector.ArgumentsMatch(cMethod, expectedArguments); Assert.IsTrue(match); }
public void Should_use_the_right_map() { var source = new EntityOne { Two = new EntityTwo { Ones = new List <EntityOne> { new EntityOne { Two = new EntityTwo { Ones = new List <EntityOne>() } } } } }; Mapper.Map <EntityOne, DtoOne>(source).ShouldBeOfType <DtoOne>(); Mapper.Map <EntityOne, DtoThree>(source).ShouldBeOfType <DtoThree>(); }
public virtual void Test_GetEntitiesByPropertyValue() { using (LogGroup logGroup = LogGroup.Start("Testing data retrieval with the GetEntities by property value function.", NLog.LogLevel.Debug)) { EntityOne e1 = new EntityOne(); e1.Name = "Test E1"; DataAccess.Data.Saver.Save(e1); IEntity[] found = DataAccess.Data.Indexer.GetEntities <EntityOne>("Name", e1.Name); Assert.IsNotNull(found, "Null array returned."); if (found != null) { Assert.AreEqual(1, found.Length, "No results found."); } } }
public virtual void Test_GetEntitiesByPropertyValue() { using (LogGroup logGroup = LogGroup.Start("Testing data retrieval with the GetEntities by property value function.", NLog.LogLevel.Debug)) { EntityOne e1 = new EntityOne(); e1.Name = "Test E1"; DataAccess.Data.Saver.Save(e1); IEntity[] found = DataAccess.Data.Indexer.GetEntities<EntityOne>("Name", e1.Name); Assert.IsNotNull(found, "Null array returned."); if (found != null) Assert.AreEqual(1, found.Length, "No results found."); } }
public void Test_GetMirrorPropertyName_Single_Implicit_Sync() { EntityOne e1 = new EntityOne(); string mirrorPropertyName = EntitiesUtilities.GetMirrorPropertyName(e1, e1.GetType().GetProperty("SingleReferenceProperty")); Assert.AreEqual(String.Empty, mirrorPropertyName, "The mirror property name wasn't determined correctly."); }
public void Test_IsMultipleReference_False() { EntityOne e1 = new EntityOne(); PropertyInfo property = e1.GetType().GetProperty("SingleReferenceProperty"); Assert.IsFalse(EntitiesUtilities.IsMultipleReference(e1.GetType(), property), "Returned true when it should have returned false."); }
public void Test_GetMethod() { EntityOne e = new EntityOne(); e.ID = Guid.NewGuid(); MethodInfo method = Reflector.GetMethod(e, "DoSomething", new Type[]{typeof(IEntity)}, new Type[] {typeof(IEntity)}); Assert.IsNotNull(method); }
public void Test_GetEntitiesByParameterDictionary_Exclude() { using (LogGroup logGroup = LogGroup.Start("Testing the GetEntities<T>(IDictionary<string, object>) function to ensure it excludes entities properly.", NLog.LogLevel.Debug)) { EntityOne e1 = new EntityOne(); e1.Name = "Test E1"; DataAccess.Data.Saver.Save(e1); Dictionary<string, object> parameters = new Dictionary<string, object>(); parameters.Add("Name", "Test E2"); EntityOne[] found = (EntityOne[])DataAccess.Data.Indexer.GetEntities<EntityOne>(parameters); Assert.IsNotNull(found, "The return value is null."); if (found != null) Assert.AreEqual(0, found.Length, "Entities weren't properly excluded."); DataAccess.Data.Deleter.Delete(e1); } }
public void Test_ParametersMatch_InvalidCount() { EntityOne e = new EntityOne(); e.ID = Guid.NewGuid(); MethodInfo method = e.GetType().GetMethod("DoSomething"); Type[] expectedParameters = new Type[] {}; bool match = Reflector.ParametersMatch(method, method.GetGenericArguments(), expectedParameters); Assert.IsFalse(match); }
public void Test_GetEntitiesByPropertyValue_Exclusion() { using (LogGroup logGroup = LogGroup.Start("Testing exclusion with the GetEntities by property value function.", NLog.LogLevel.Debug)) { EntityOne e1 = new EntityOne(); e1.Name = "Test E1"; //FilterGroup filterGroup = new FilterGroup(); //filterGroup.Operator PropertyFilter filter = (PropertyFilter)DataAccess.Data.CreateFilter(typeof(PropertyFilter)); filter.Operator = FilterOperator.Equal; filter.PropertyName = "Name"; filter.PropertyValue = "Another Name"; DataAccess.Data.Saver.Save(e1); IEntity[] found = DataAccess.Data.Indexer.GetEntities<EntityOne>("Name", "Another Name"); Assert.IsNotNull(found, "Null array returned."); if (found != null) Assert.AreEqual(0, found.Length, "Entities weren't properly excluded."); } }
public void Test_ParametersMatch_Assignable() { EntityOne e = new EntityOne(); e.ID = Guid.NewGuid(); Type[] typeArguments = new Type[]{typeof(IEntity)}; MethodInfo method = e.GetType().GetMethod("DoSomething"); MethodInfo cMethod = method.MakeGenericMethod(typeArguments); Type[] expectedParameters = new Type[] {typeof(EntityTwo)}; bool match = Reflector.ParametersMatch(cMethod, typeArguments, expectedParameters); Assert.IsTrue(match); }