Skip to content

Commit b15451a

Browse files
committed
Removed references to 'entity' and replaced with 'object'
1 parent ab8b645 commit b15451a

File tree

3 files changed

+35
-35
lines changed

3 files changed

+35
-35
lines changed

NTestDataBuilder/DataBuilder.cs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,22 @@ public interface IDataBuilder<out T> where T : class
1919
}
2020

2121
/// <summary>
22-
/// Base class definining infrastructure for a class that generates objects of type <see cref="TEntity"/>.
22+
/// Base class definining infrastructure for a class that generates objects of type <see cref="TObject"/>.
2323
/// </summary>
24-
/// <typeparam name="TEntity">The type of object this class generates</typeparam>
24+
/// <typeparam name="TObject">The type of object this class generates</typeparam>
2525
/// <typeparam name="TBuilder">The type for this class, yes this is a recursive type definition</typeparam>
26-
public abstract class DataBuilder<TEntity, TBuilder> : IDataBuilder<TEntity>
27-
where TEntity : class
28-
where TBuilder : class, IDataBuilder<TEntity>
26+
public abstract class DataBuilder<TObject, TBuilder> : IDataBuilder<TObject>
27+
where TObject : class
28+
where TBuilder : class, IDataBuilder<TObject>
2929
{
3030
private readonly Dictionary<string, object> _properties = new Dictionary<string, object>();
31-
private ProxyBuilder<TEntity> _proxyBuilder;
31+
private ProxyBuilder<TObject> _proxyBuilder;
3232

3333
/// <summary>
3434
/// Build the object.
3535
/// </summary>
3636
/// <returns>The built object</returns>
37-
public TEntity Build()
37+
public TObject Build()
3838
{
3939
if (_proxyBuilder != null)
4040
{
@@ -50,15 +50,15 @@ public TEntity Build()
5050
/// Build the actual object
5151
/// </summary>
5252
/// <returns>The built object</returns>
53-
protected abstract TEntity BuildObject();
53+
protected abstract TObject BuildObject();
5454

5555
/// <summary>
5656
/// Return an NSubstitute proxy object when .Build() is called rather than a real object.
5757
/// </summary>
5858
/// <returns>The builder so that other method calls can be chained</returns>
5959
public TBuilder AsProxy()
6060
{
61-
_proxyBuilder = new ProxyBuilder<TEntity>(_properties);
61+
_proxyBuilder = new ProxyBuilder<TObject>(_properties);
6262
return this as TBuilder;
6363
}
6464

@@ -67,26 +67,26 @@ public TBuilder AsProxy()
6767
/// This allows you to add any .Returns() values that are more complex than the public properties that are proxied by default.
6868
/// </summary>
6969
/// <param name="proxy">The proxy object</param>
70-
protected virtual void AlterProxy(TEntity proxy) {}
70+
protected virtual void AlterProxy(TObject proxy) {}
7171

7272
/// <summary>
73-
/// Records the given value for the given property from <see cref="TEntity"/>.
73+
/// Records the given value for the given property from <see cref="TObject"/>.
7474
/// </summary>
7575
/// <typeparam name="TValue">The type of the property</typeparam>
7676
/// <param name="property">A lambda expression specifying the property to record a value for</param>
7777
/// <param name="value">The value to record</param>
78-
public void Set<TValue>(Expression<Func<TEntity, TValue>> property, TValue value)
78+
public void Set<TValue>(Expression<Func<TObject, TValue>> property, TValue value)
7979
{
8080
_properties[GetPropertyName(property)] = value;
8181
}
8282

8383
/// <summary>
84-
/// Gets the recorded value for the given property from <see cref="TEntity"/>.
84+
/// Gets the recorded value for the given property from <see cref="TObject"/>.
8585
/// </summary>
8686
/// <typeparam name="TValue">The type of the property</typeparam>
8787
/// <param name="property">A lambda expression specifying the property to retrieve the recorded value for</param>
8888
/// <returns>The recorded value of the property</returns>
89-
public TValue Get<TValue>(Expression<Func<TEntity, TValue>> property)
89+
public TValue Get<TValue>(Expression<Func<TObject, TValue>> property)
9090
{
9191
if (!Has(property))
9292
throw new ArgumentException(
@@ -101,13 +101,13 @@ public TValue Get<TValue>(Expression<Func<TEntity, TValue>> property)
101101
}
102102

103103
/// <summary>
104-
/// Gets the recorded value for the given property from <see cref="TEntity"/> or if no
104+
/// Gets the recorded value for the given property from <see cref="TObject"/> or if no
105105
/// value has been recorded the default value for <see cref="TValue"/>.
106106
/// </summary>
107107
/// <typeparam name="TValue">The type of the property</typeparam>
108108
/// <param name="property">A lambda expression specifying the property to retrieve the recorded value for</param>
109109
/// <returns>The recorded value of the property or teh default value for <see cref="TValue"/> if no value recorded</returns>
110-
public TValue GetOrDefault<TValue>(Expression<Func<TEntity, TValue>> property)
110+
public TValue GetOrDefault<TValue>(Expression<Func<TObject, TValue>> property)
111111
{
112112
return Has(property)
113113
? Get(property)
@@ -126,25 +126,25 @@ public static IListBuilder<TBuilder> CreateListOfSize(int size)
126126
}
127127

128128
/// <summary>
129-
/// Returns whether or not there is currently a value recorded against the given property from <see cref="TEntity"/>.
129+
/// Returns whether or not there is currently a value recorded against the given property from <see cref="TObject"/>.
130130
/// </summary>
131131
/// <typeparam name="TValue">The type of the property</typeparam>
132132
/// <param name="property">A lambda expression specifying the property to retrieve the recorded value for</param>
133133
/// <returns>Whether or not there is a recorded value for the property</returns>
134-
protected bool Has<TValue>(Expression<Func<TEntity, TValue>> property)
134+
protected bool Has<TValue>(Expression<Func<TObject, TValue>> property)
135135
{
136136
return _properties.ContainsKey(GetPropertyName(property));
137137
}
138138

139-
private static string GetPropertyName<TValue>(Expression<Func<TEntity, TValue>> property)
139+
private static string GetPropertyName<TValue>(Expression<Func<TObject, TValue>> property)
140140
{
141141
var memExp = property.Body as MemberExpression;
142142
if (memExp == null)
143143
throw new ArgumentException(
144144
string.Format(
145145
"Given property expression ({0}) didn't specify a property on {1}",
146146
property,
147-
typeof(TEntity).Name
147+
typeof(TObject).Name
148148
),
149149
"property"
150150
);

NTestDataBuilder/DataBuilderExtensions.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,20 @@
55
namespace NTestDataBuilder
66
{
77
/// <summary>
8-
/// Extension methods against the <see cref="DataBuilder{TEntity,TBuilder}"/> class.
8+
/// Extension methods against the <see cref="DataBuilder{TObject,TBuilder}"/> class.
99
/// </summary>
1010
public static class DataBuilderExtensions
1111
{
1212
/// <summary>
1313
/// Builds a list of entities given an NBuilder list expression of data builders.
1414
/// </summary>
1515
/// <typeparam name="TBuilder">The type of the builder being built using NBuilder</typeparam>
16-
/// <typeparam name="TEntity">The type of object being generated</typeparam>
16+
/// <typeparam name="TObject">The type of object being generated</typeparam>
1717
/// <param name="builderList">The NBuilder list of builders</param>
1818
/// <returns>The built list of objects</returns>
19-
public static IList<TEntity> BuildDataList<TEntity, TBuilder>(this IOperable<TBuilder> builderList)
20-
where TBuilder : IDataBuilder<TEntity>
21-
where TEntity : class
19+
public static IList<TObject> BuildDataList<TObject, TBuilder>(this IOperable<TBuilder> builderList)
20+
where TBuilder : IDataBuilder<TObject>
21+
where TObject : class
2222
{
2323
return builderList.Build().Select(b => b.Build()).ToList();
2424
}
@@ -27,14 +27,14 @@ public static IList<TEntity> BuildDataList<TEntity, TBuilder>(this IOperable<TBu
2727
/// Builds a list of entities given an NBuilder list expression of data builders.
2828
/// </summary>
2929
/// <typeparam name="TBuilder">The type of the builder being built using NBuilder</typeparam>
30-
/// <typeparam name="TEntity">The type of object being generated</typeparam>
30+
/// <typeparam name="TObject">The type of object being generated</typeparam>
3131
/// <param name="builderList">The NBuilder list of builders</param>
3232
/// <returns>The built list of objects</returns>
33-
public static IList<TEntity> BuildDataList<TEntity, TBuilder>(this IListBuilder<TBuilder> builderList)
34-
where TBuilder : IDataBuilder<TEntity>
35-
where TEntity : class
33+
public static IList<TObject> BuildDataList<TObject, TBuilder>(this IListBuilder<TBuilder> builderList)
34+
where TBuilder : IDataBuilder<TObject>
35+
where TObject : class
3636
{
37-
return builderList.All().BuildDataList<TEntity, TBuilder>();
37+
return builderList.All().BuildDataList<TObject, TBuilder>();
3838
}
3939
}
4040
}

NTestDataBuilder/ProxyBuilder.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ public ProxyBuilder(Dictionary<string, object> properties)
2828
/// <returns>The proxy object</returns>
2929
public T Build()
3030
{
31-
var proxyEntity = Substitute.For<T>();
32-
var entityProperties = typeof(T).GetProperties(BindingFlags.Public | BindingFlags.Instance);
33-
foreach (var property in entityProperties.Where(property => _properties.ContainsKey(property.Name)))
31+
var proxy = Substitute.For<T>();
32+
var properties = typeof(T).GetProperties(BindingFlags.Public | BindingFlags.Instance);
33+
foreach (var property in properties.Where(property => _properties.ContainsKey(property.Name)))
3434
{
35-
property.GetValue(proxyEntity, null).Returns(_properties[property.Name]);
35+
property.GetValue(proxy, null).Returns(_properties[property.Name]);
3636
}
3737

38-
return proxyEntity;
38+
return proxy;
3939
}
4040
}
4141
}

0 commit comments

Comments
 (0)