From ee227e410ebe6911b19bf7f48162d3d88077d028 Mon Sep 17 00:00:00 2001 From: ipjohnson Date: Sat, 22 Apr 2017 14:52:09 -0600 Subject: [PATCH] changing Locate to default for issue #29 --- .../Attributes/AttributeHelper.cs | 2 +- src/SimpleFixture/Impl/ConstraintHelper.cs | 2 ++ .../AutoDataTestCaseAttributeTests.cs | 25 +++++++++++++------ 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/SimpleFixture/Attributes/AttributeHelper.cs b/src/SimpleFixture/Attributes/AttributeHelper.cs index 3c07eba..88c0fb6 100644 --- a/src/SimpleFixture/Attributes/AttributeHelper.cs +++ b/src/SimpleFixture/Attributes/AttributeHelper.cs @@ -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)); } } diff --git a/src/SimpleFixture/Impl/ConstraintHelper.cs b/src/SimpleFixture/Impl/ConstraintHelper.cs index cbd5001..072f116 100644 --- a/src/SimpleFixture/Impl/ConstraintHelper.cs +++ b/src/SimpleFixture/Impl/ConstraintHelper.cs @@ -222,6 +222,8 @@ public bool GetUnTypedValue(out object value, Type type, object constraintValue, if (!returnValue || value == null) { + value = defaultValue; + return returnValue; } diff --git a/tests/SimpleFixture.Tests.MSTest/AutoDataTestCaseAttributeTests.cs b/tests/SimpleFixture.Tests.MSTest/AutoDataTestCaseAttributeTests.cs index 06fa471..c055952 100644 --- a/tests/SimpleFixture.Tests.MSTest/AutoDataTestCaseAttributeTests.cs +++ b/tests/SimpleFixture.Tests.MSTest/AutoDataTestCaseAttributeTests.cs @@ -4,6 +4,7 @@ using FluentAssertions; using SimpleFixture.Attributes; using System.Linq; +using SimpleFixture.Conventions; namespace SimpleFixture.Tests.MSTest { @@ -11,44 +12,52 @@ namespace SimpleFixture.Tests.MSTest 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().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().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().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);