Skip to content

Commit

Permalink
Convert to auto-implemented getter-only properties (pt. 19)
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikSchierboom committed Mar 16, 2016
1 parent 5de1a83 commit 67bc524
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 38 deletions.
Expand Up @@ -7,25 +7,16 @@ namespace Ploeh.TestTypeFoundation
{
public abstract class AbstractTypeWithConstructorWithMultipleParameters<T1, T2>
{
private readonly T1 property1;
private readonly T2 property2;

protected AbstractTypeWithConstructorWithMultipleParameters(
T1 parameter1,
T2 parameter2)
{
this.property1 = parameter1;
this.property2 = parameter2;
this.Property1 = parameter1;
this.Property2 = parameter2;
}

public T1 Property1
{
get { return property1; }
}
public T1 Property1 { get; }

public T2 Property2
{
get { return property2; }
}
public T2 Property2 { get; }
}
}
Expand Up @@ -4,21 +4,16 @@ namespace Ploeh.TestTypeFoundation
{
public abstract class AbstractTypeWithNonDefaultConstructor<T>
{
private readonly T property;

protected AbstractTypeWithNonDefaultConstructor(T value)
{
if (value == null)
{
throw new ArgumentNullException(nameof(value));
}

this.property = value;
this.Property = value;
}

public T Property
{
get { return this.property; }
}
public T Property { get; }
}
}
9 changes: 2 additions & 7 deletions Src/TestTypeFoundation/CompositeType.cs
Expand Up @@ -6,8 +6,6 @@ namespace Ploeh.TestTypeFoundation
{
public class CompositeType : AbstractType
{
private readonly IEnumerable<AbstractType> types;

public CompositeType(IEnumerable<AbstractType> types)
: this(types.ToArray())
{
Expand All @@ -20,12 +18,9 @@ public CompositeType(params AbstractType[] types)
throw new ArgumentNullException(nameof(types));
}

this.types = types;
this.Types = types;
}

public IEnumerable<AbstractType> Types
{
get { return this.types; }
}
public IEnumerable<AbstractType> Types { get; }
}
}
6 changes: 2 additions & 4 deletions Src/TestTypeFoundation/GenericType.cs
Expand Up @@ -4,18 +4,16 @@ namespace Ploeh.TestTypeFoundation
{
public class GenericType<T> where T : class
{
private readonly T t;

public GenericType(T t)
{
if (t == null)
{
throw new ArgumentNullException(nameof(t));
}

this.t = t;
this.Value = t;
}

T Value { get { return this.t; }}
private T Value { get; }
}
}
9 changes: 2 additions & 7 deletions Src/TestTypeFoundation/GuardedConstructorHost.cs
Expand Up @@ -4,21 +4,16 @@ namespace Ploeh.TestTypeFoundation
{
public class GuardedConstructorHost<T> where T : class
{
private readonly T item;

public GuardedConstructorHost(T item)
{
if (item == null)
{
throw new ArgumentNullException(nameof(item));
}

this.item = item;
this.Item = item;
}

public T Item
{
get { return this.item; }
}
public T Item { get; }
}
}

0 comments on commit 67bc524

Please sign in to comment.