Skip to content

Commit

Permalink
changing Locate to default for issue #29
Browse files Browse the repository at this point in the history
  • Loading branch information
ipjohnson committed Apr 22, 2017
1 parent 757df5c commit ee227e4
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/SimpleFixture/Attributes/AttributeHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ private static object GetValueForParameter(MethodInfo testMethod, ParameterInfo
{
parameterValue =
fixture.Generate(new DataRequest(null, fixture, parameter.ParameterType, DependencyType.Root,
parameter.Name, true, null, parameter));
parameter.Name, false, null, parameter));
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/SimpleFixture/Impl/ConstraintHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,8 @@ public bool GetUnTypedValue(out object value, Type type, object constraintValue,

if (!returnValue || value == null)
{
value = defaultValue;

return returnValue;
}

Expand Down
25 changes: 17 additions & 8 deletions tests/SimpleFixture.Tests.MSTest/AutoDataTestCaseAttributeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,51 +4,60 @@
using FluentAssertions;
using SimpleFixture.Attributes;
using System.Linq;
using SimpleFixture.Conventions;

namespace SimpleFixture.Tests.MSTest
{
[TestClass]
public class AutoDataTestCaseAttributeTests
{
[AutoDataTestCase]
public void AutoData_ProvidesFixture(Fixture fixture)
public void MSTest_AutoData_ProvidesFixture(Fixture fixture)
{
fixture.Should().NotBeNull();
}

[AutoDataTestCase]
public void AutoData_ProvidesGeneratedData(string firstName, int value)
public void MSTest_AutoData_ProvidesData(string someString, int value)
{
firstName.All(char.IsLetter).Should().BeTrue();
someString.Should().Be(StringConvention.LocateValue);
value.Should().Be(IntConvention.LocateValue);
}

[AutoDataTestCase]
public void MSTest_AutoData_ProvidesGeneratedData([Generate]string firstName, [Generate]int value)
{
firstName.All(Char.IsLetter).Should().BeTrue();
firstName.Should().NotBe(StringConvention.LocateValue);
}

[AutoDataTestCase]
public void AutoData_Freeze(Fixture fixture, [Freeze]int froozen)
public void MSTest_AutoData_Freeze(Fixture fixture, [Freeze]int froozen)
{
fixture.Generate<int>().Should().Be(froozen);
}

[AutoDataTestCase]
public void AutoData_FreezeValue(Fixture fixture, [Freeze(Value = 8)]int froozen)
public void MSTest_AutoData_FreezeValue(Fixture fixture, [Freeze(Value = 8)]int froozen)
{
froozen.Should().Be(8);
fixture.Generate<int>().Should().Be(froozen);
}

[AutoDataTestCase]
public void AutoData_LocateData(Fixture fixture, [Locate]int locate)
public void MSTest_AutoData_LocateData(Fixture fixture, [Locate]int locate)
{
fixture.Locate<int>().Should().Be(locate);
}

[AutoDataTestCase]
public void AutoData_LocateValue(Fixture fixture, [Locate(Value = 8)]int locate)
public void MSTest_AutoData_LocateValue(Fixture fixture, [Locate(Value = 8)]int locate)
{
locate.Should().Be(8);
}

[AutoDataTestCase(8)]
public void AutoData_MixInData(SomeClass someClass, int value)
public void MSTest_AutoData_MixInData(SomeClass someClass, int value)
{
someClass.Should().NotBeNull();
value.Should().Be(8);
Expand Down

0 comments on commit ee227e4

Please sign in to comment.