Skip to content

Commit

Permalink
Change 'Instance' to 'Member'
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveDunn committed Apr 9, 2023
1 parent 31b0fc2 commit 3f58ab7
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 47 deletions.
2 changes: 1 addition & 1 deletion samples/Intellenum.Examples/SyntaxExamples/NoDefaulting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace Intellenum.Examples.SyntaxExamples.NoDefaulting
{
/*
You shouldn't be allowed to `default` a Intellenums as you should always
chose a valid instance.
chose a valid member.
*/

public class Naughty
Expand Down
12 changes: 6 additions & 6 deletions samples/Intellenum.Examples/TypicalScenarios/ExplicitCasting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ internal class ExplicitCastingScenario : IScenario
public Task Run()
{
// We can create an instance with an explicit cast. If there is validation, it is still run.
Result score1 = (Result)2;
Result score2 = Result.FromValue(2);
Result result1 = (Result)2;
Result result2 = Result.FromValue(2);

Console.WriteLine(score1 == score2); // true
Console.WriteLine(score1 == Result.Won); // true
Console.WriteLine(result1 == result2); // true
Console.WriteLine(result1 == Result.Won); // true

// We can cast an instance to the underlying type too
int score3 = (int) score2;
Console.WriteLine(score3 == score2); // true
int score3 = (int) result2;
Console.WriteLine(score3 == result2); // true

return Task.CompletedTask;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
using System.Threading.Tasks;
// ReSharper disable RedundantCast

namespace Intellenum.Examples.TypicalScenarios.Instances
namespace Intellenum.Examples.TypicalScenarios.Members
{
internal class InstanceExamples : IScenario
internal class MemberExamples : IScenario
{
public Task Run()
{
Expand All @@ -24,7 +24,7 @@ public Task Run()
[Intellenum]
public partial class ImpliedFieldName
{
public static readonly ImpliedFieldName Instance1 = new(1);
public static readonly ImpliedFieldName Member1 = new(1);
}


Expand All @@ -48,12 +48,12 @@ public partial class VendorType
[Intellenum]
[Member("Salt", 1)]
[Member("Pepper", 2)]
public partial class CondimentMixedInstances
public partial class CondimentMixedMembers
{
public static readonly CondimentMixedInstances Mayo = new CondimentMixedInstances("Mayo", 5);
public static readonly CondimentMixedInstances Ketchup = new CondimentMixedInstances("Ketchup", 6);
public static readonly CondimentMixedMembers Mayo = new CondimentMixedMembers("Mayo", 5);
public static readonly CondimentMixedMembers Ketchup = new CondimentMixedMembers("Ketchup", 6);

static CondimentMixedInstances()
static CondimentMixedMembers()
{
Member("Vinegar", 3);
Member("Mustard", 4);
Expand Down
18 changes: 9 additions & 9 deletions tests/ConsumerTests/ImpliedFieldNameTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,29 @@ public class ImpliedFieldNameTests
[Fact]
public void General()
{
ImpliedFieldName.Instance1.Value.Should().Be(1);
ImpliedFieldName.Instance2.Value.Should().Be(2);
ImpliedFieldName.Instance3.Value.Should().Be(3);
ImpliedFieldName.Member1.Value.Should().Be(1);
ImpliedFieldName.Member2.Value.Should().Be(2);
ImpliedFieldName.Member3.Value.Should().Be(3);

ImpliedFieldName.IsDefined(1).Should().BeTrue();
ImpliedFieldName.IsDefined(2).Should().BeTrue();
ImpliedFieldName.IsDefined(3).Should().BeTrue();

ImpliedFieldName.TryFromName("Instance1", out var i1).Should().BeTrue();
ImpliedFieldName.TryFromName("Member1", out var i1).Should().BeTrue();
i1.Value.Should().Be(1);

ImpliedFieldName.TryFromName("INSTANCE 3!!", out var i3).Should().BeTrue();
ImpliedFieldName.TryFromName("MEMBER 3!!", out var i3).Should().BeTrue();
i3.Value.Should().Be(3);

ImpliedFieldName.IsDefined(3).Should().BeTrue();
ImpliedFieldName.IsNamedDefined("INSTANCE 3!!").Should().BeTrue();
ImpliedFieldName.IsNamedDefined("MEMBER 3!!").Should().BeTrue();
}
}

[Intellenum]
public partial class ImpliedFieldName
{
public static readonly ImpliedFieldName Instance1 = new(1);
public static readonly ImpliedFieldName Instance2 = new(2);
public static readonly ImpliedFieldName Instance3 = new("INSTANCE 3!!", 3);
public static readonly ImpliedFieldName Member1 = new(1);
public static readonly ImpliedFieldName Member2 = new(2);
public static readonly ImpliedFieldName Member3 = new("MEMBER 3!!", 3);
}
18 changes: 0 additions & 18 deletions tests/ConsumerTests/Instances/InstanceFieldTests.cs

This file was deleted.

18 changes: 18 additions & 0 deletions tests/ConsumerTests/Members/InstanceFieldTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
namespace ConsumerTests.Members;

public class InstanceFieldTests
{
[Fact]
public void Type_with_two_members()
{
MyIntWithMembersInvalidAndUnspecified.Invalid.Value.Should().Be(-1);
MyIntWithMembersInvalidAndUnspecified.Unspecified.Value.Should().Be(-2);
}

[Fact]
public void Type_with_underlying_decimal_with_two_members()
{
MyDecimalWithMembersInvalidAndUnspecified.Invalid.Value.Should().Be(-1.23m);
MyDecimalWithMembersInvalidAndUnspecified.Unspecified.Value.Should().Be(-2.34m);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using FluentAssertions.Execution;

namespace ConsumerTests.Instances;
namespace ConsumerTests.Members;

[Intellenum(typeof(DateTime))]
[Member(name: "iso8601_1", value: "2022-12-13")]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
namespace ConsumerTests.Instances;
namespace ConsumerTests.Members;

[Intellenum(typeof(int))]
[Member(name: "Invalid", value: -1)]
[Member(name: "Unspecified", value: -2)]
public partial class MyIntWithTwoInstanceOfInvalidAndUnspecified
public partial class MyIntWithMembersInvalidAndUnspecified
{
}

[Intellenum(typeof(decimal))]
[Member(name: "Invalid", value: "-1.23")]
[Member(name: "Unspecified", value: "-2.34")]
public partial class MyDecimalWithTwoInstanceOfInvalidAndUnspecified
public partial class MyDecimalWithMembersInvalidAndUnspecified
{
}

[Intellenum(typeof(int))]
[Member(name: "Invalid", value: -1)]
[Member(name: "Unspecified", value: -2)]
public partial class MyStructVoIntWithTwoInstanceOfInvalidAndUnspecified
public partial class MyStructVoIntWithMembersInvalidAndUnspecified
{
}

[Intellenum(typeof(int))]
[Member(name: "Invalid", value: -1)]
[Member(name: "Unspecified", value: -2)]
public partial class MyRecordClassVoIntWithTwoInstanceOfInvalidAndUnspecified
public partial class MyRecordClassVoIntWithMembersInvalidAndUnspecified
{
}

0 comments on commit 3f58ab7

Please sign in to comment.